File tree 4 files changed +30
-2
lines changed
openapi-processor-core/src
main/kotlin/io/openapiprocessor/core
test/kotlin/io/openapiprocessor/core/processor/mapping/v2
4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -16,5 +16,9 @@ enum class JsonPropertyAnnotationMode(private val mode: String) {
16
16
* add @JsonProperty, if the java property name is NOT identical to the OpenAPI property name
17
17
* or set to read/write only.
18
18
*/
19
- Auto (" auto" )
19
+ Auto (" auto" );
20
+
21
+ companion object {
22
+ fun findBy (mode : String ): JsonPropertyAnnotationMode = entries.first { it.mode == mode }
23
+ }
20
24
}
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ class OptionsConverter(private val checkObsoleteProcessorOptions: Boolean = fals
73
73
options.formatCode = mapping.options.formatCode
74
74
options.generatedAnnotation = mapping.options.generatedAnnotation
75
75
options.generatedDate = mapping.options.generatedDate
76
+ options.jsonPropertyAnnotation = JsonPropertyAnnotationMode .findBy(
77
+ mapping.options.jsonPropertyAnnotation)
76
78
77
79
with (mapping.compatibility) {
78
80
options.beanValidationValidOnReactive = beanValidationValidOnReactive
Original file line number Diff line number Diff line change @@ -70,5 +70,10 @@ data class Options(
70
70
/* *
71
71
* enable/disable the @Generated date (optional)
72
72
*/
73
- val generatedDate : Boolean = true
73
+ val generatedDate : Boolean = true ,
74
+
75
+ /* *
76
+ * generate @JsonProperty annotation always|auto (optional)
77
+ */
78
+ val jsonPropertyAnnotation : String = " always"
74
79
)
Original file line number Diff line number Diff line change @@ -201,4 +201,21 @@ class MappingReaderSpec: StringSpec ({
201
201
extList[0 ].type shouldBe " fooA @ custom.Annotation"
202
202
extList[1 ].type shouldBe " fooB @ custom.Annotation"
203
203
}
204
+
205
+ " reads json property annotation" {
206
+ val yaml = """
207
+ |openapi-processor-mapping: v8
208
+ |options:
209
+ | package-name: no.warning
210
+ | json-property-annotation: auto
211
+ """ .trimMargin()
212
+
213
+ val reader = MappingReader ()
214
+
215
+ // when:
216
+ val mapping = reader.read (yaml) as Mapping
217
+
218
+ // then:
219
+ mapping.options.jsonPropertyAnnotation shouldBe " auto"
220
+ }
204
221
})
You can’t perform that action at this time.
0 commit comments