Skip to content

Commit a379a2b

Browse files
committed
int api path with file
1 parent 7d77778 commit a379a2b

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

src/main/groovy/io/openapiprocessor/gradle/OpenApiProcessorExtension.groovy

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
package io.openapiprocessor.gradle
77

8-
98
import org.gradle.api.Action
109
import org.gradle.api.Project
10+
import org.gradle.api.file.RegularFile
11+
import org.gradle.api.file.RegularFileProperty
1112
import org.gradle.api.provider.MapProperty
1213
import org.gradle.api.provider.Property
1314

@@ -39,6 +40,12 @@ import org.gradle.api.provider.Property
3940
*/
4041
abstract class OpenApiProcessorExtension extends OpenApiProcessorExtensionBase {
4142

43+
/**
44+
* the path to the openapi yaml file. Used for all processors if not set in a nested processor
45+
* configuration.
46+
*/
47+
RegularFileProperty api
48+
4249
/**
4350
* check automatically for updates. Can be "never"|"daily"|"always". Default is "never".
4451
*/
@@ -66,11 +73,13 @@ abstract class OpenApiProcessorExtension extends OpenApiProcessorExtensionBase {
6673
private Project project
6774

6875
OpenApiProcessorExtension (Project project) {
69-
this.project = project
70-
checkUpdates = project.objects.property(String)
71-
processors = project.objects.mapProperty (String, Processor)
76+
api = project.objects.fileProperty()
7277

78+
checkUpdates = project.objects.property(String)
7379
checkUpdates.set("never")
80+
81+
processors = project.objects.mapProperty (String, Processor)
82+
this.project = project
7483
}
7584

7685
/**
@@ -146,14 +155,22 @@ abstract class OpenApiProcessorExtension extends OpenApiProcessorExtensionBase {
146155
* set apiPath.
147156
*/
148157
void apiPath(String apiPath) {
149-
this.apiPath.fileValue(new File(apiPath))
158+
this.api.fileValue(new File(apiPath))
150159
}
151160

152161
/**
153162
* set apiPath.
154163
*/
155164
void apiPath(GString apiPath) {
156-
this.apiPath.fileValue(new File(apiPath))
165+
this.api.fileValue(new File(apiPath))
166+
}
167+
168+
void setApiPath(File apiPath) {
169+
api.set(apiPath)
170+
}
171+
172+
void setApiPath(RegularFile apiPath) {
173+
api.set(apiPath)
157174
}
158175

159176
void checkUpdates(String check) {

src/main/java/io/openapiprocessor/gradle/OpenApiProcessorExtensionBase.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,5 @@
55

66
package io.openapiprocessor.gradle;
77

8-
import org.gradle.api.file.RegularFileProperty;
9-
108
abstract class OpenApiProcessorExtensionBase {
11-
/**
12-
* the path to the openapi yaml file. Used for all processors if not set in a nested processor
13-
* configuration.
14-
*/
15-
RegularFileProperty apiPath;
169
}

src/test/groovy/io/openapiprocessor/gradle/OpenApiProcessorExtensionSpec.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class OpenApiProcessorExtensionSpec extends Specification {
2424
ex.apiPath("openapi.yaml")
2525

2626
expect:
27-
ex.apiPath.get().asFile == project.file("openapi.yaml")
27+
ex.api.get().asFile == project.file("openapi.yaml")
2828
ex.checkUpdates.get() == "never"
2929
}
3030

@@ -93,7 +93,7 @@ class OpenApiProcessorExtensionSpec extends Specification {
9393
}
9494
9595
then:
96-
ex.apiPath.get().asFile == project.file('projectDir/src/api/openapi.yaml')
96+
ex.api.get().asFile == project.file('projectDir/src/api/openapi.yaml')
9797
}
9898
9999
void "assign apiPath from GString" () {
@@ -105,7 +105,7 @@ class OpenApiProcessorExtensionSpec extends Specification {
105105
}
106106
107107
then:
108-
ex.apiPath.get().asFile == project.file('projectDir/src/api/openapi.yaml')
108+
ex.api.get().asFile == project.file('projectDir/src/api/openapi.yaml')
109109
}
110110
111111
void "assign apiPath from RegularFile" () {
@@ -115,6 +115,6 @@ class OpenApiProcessorExtensionSpec extends Specification {
115115
}
116116
117117
then:
118-
ex.apiPath.get().asFile == project.file("src/api/openapi.yaml")
118+
ex.api.get().asFile == project.file("src/api/openapi.yaml")
119119
}
120120
}

0 commit comments

Comments
 (0)