Skip to content

Commit b114e39

Browse files
committed
better name (#176)
1 parent b17621a commit b114e39

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/OptionsConverter.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ class OptionsConverter(private val checkObsoleteProcessorOptions: Boolean = fals
7474
val (enablePathPrefix, pathPrefixServerIndex) = checkServerUrl(mapping.options)
7575
options.basePathOptions.enabled = enablePathPrefix
7676
options.basePathOptions.serverUrl = pathPrefixServerIndex
77-
options.basePathOptions.profileName = mapping.options.basePath.profileName
77+
options.basePathOptions.propertiesName = mapping.options.basePath.profileName
78+
// to write the base path resource we need standard layout
79+
if (options.basePathOptions.enabled && !options.targetDirOptions.standardLayout) {
80+
log.warn("base-path is enabled, forcing target-dir.layout = standard")
81+
options.targetDirOptions.layout = TargetDirLayout.STANDARD
82+
}
7883

7984
options.javadoc = mapping.options.javadoc
8085
options.oneOfInterface = mapping.options.oneOfInterface

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/options/BasePathOptions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BasePathOptions {
1717
var serverUrl: Int? = null
1818

1919
/**
20-
* profile name for base path.
20+
* properties name for base path.
2121
*/
22-
var profileName: String = "api.properties"
22+
var propertiesName: String = "api.properties"
2323
}

openapi-processor-core/src/main/resources/mapping/v9/mapping.yaml.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@
120120
"true", "false", "0", "1"
121121
]
122122
},
123-
"profile-name": {
124-
"description": "name of the resource profile properties file with the base path configuration",
123+
"properties-name": {
124+
"description": "name of the resource properties file with the base path configuration",
125125
"default": "api.properties",
126126
"examples": ["api.properties", "openapi.properties"]
127127
}

openapi-processor-core/src/test/kotlin/io/openapiprocessor/core/converter/OptionsConverterSpec.kt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class OptionsConverterSpec: StringSpec({
3636
options.formatCode.shouldBeFalse()
3737
options.basePathOptions.enabled shouldBe false
3838
options.basePathOptions.serverUrl shouldBe null
39-
options.basePathOptions.profileName shouldBe "api.properties"
39+
options.basePathOptions.propertiesName shouldBe "api.properties"
4040

4141
options.globalMappings.shouldNotBeNull()
4242
options.endpointMappings.shouldNotBeNull()
@@ -132,7 +132,7 @@ class OptionsConverterSpec: StringSpec({
132132
options.formatCode.shouldBeFalse()
133133
options.basePathOptions.enabled shouldBe true
134134
options.basePathOptions.serverUrl shouldBe 0
135-
options.basePathOptions.profileName shouldBe "openapi.properties"
135+
options.basePathOptions.propertiesName shouldBe "openapi.properties"
136136

137137
options.beanValidationValidOnReactive.shouldBeFalse()
138138
options.identifierWordBreakFromDigitToLetter.shouldBeFalse()
@@ -206,7 +206,26 @@ class OptionsConverterSpec: StringSpec({
206206

207207
options.basePathOptions.enabled shouldBe su.enabled
208208
options.basePathOptions.serverUrl shouldBe su.index
209-
options.basePathOptions.profileName shouldBe "openapi.properties"
209+
options.basePathOptions.propertiesName shouldBe "openapi.properties"
210210
}
211211
}
212+
213+
"enabling base path resource will automatically enable target-dir layout standard" {
214+
val converter = OptionsConverter()
215+
converter.log = mockk<Logger>(relaxed = true)
216+
217+
val options = converter.convertOptions(mapOf(
218+
"mapping" to """
219+
openapi-processor-mapping: v9
220+
options:
221+
package-name: pkg
222+
base-path:
223+
server-url: true
224+
profile-name: openapi.properties
225+
""".trimIndent()
226+
))
227+
228+
options.basePathOptions.enabled shouldBe true
229+
options.targetDirOptions.layout.isStandard() shouldBe true
230+
}
212231
})

0 commit comments

Comments
 (0)