File tree Expand file tree Collapse file tree
openapi-processor-core/src
main/kotlin/io/openapiprocessor/core/writer/java
testInt/resources/tests/params-enum
test/kotlin/io/openapiprocessor/core/writer/java Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,13 +13,15 @@ import io.openapiprocessor.core.support.capitalizeFirstChar
1313class ModelClassNameCreator (private val suffix : String ) {
1414
1515 fun createName (dataTypeName : String ): String {
16+ val classTypeName = toClass(dataTypeName)
17+
1618 if (dataTypeName.isEmpty())
17- return dataTypeName
19+ return classTypeName
1820
1921 if (dataTypeName.endsWith(suffix.capitalizeFirstChar()))
20- return dataTypeName
22+ return classTypeName
2123
22- return " $dataTypeName ${suffix.capitalizeFirstChar()} "
24+ return " $classTypeName ${suffix.capitalizeFirstChar()} "
2325 }
2426
2527}
Original file line number Diff line number Diff line change @@ -20,4 +20,8 @@ class ModelClassNameCreatorSpec : StringSpec({
2020 creator.createName("FooX ") shouldBe " FooX"
2121 }
2222
23+ " create valid java class name" {
24+ val creator = ModelClassNameCreator ("")
25+ creator.createName("foo-foo") shouldBe " FooFoo"
26+ }
2327})
Original file line number Diff line number Diff line change 22 - generated/api/EnumApi.java
33 - generated/model/Bar.java
44 - generated/model/Foo.java
5+ - generated/model/FooFoo.java
Original file line number Diff line number Diff line change 44import annotation .Parameter ;
55import generated .model .Bar ;
66import generated .model .Foo ;
7+ import generated .model .FooFoo ;
78import generated .support .Generated ;
89
910@ Generated (value = "openapi-processor-core" , version = "test" )
@@ -14,4 +15,7 @@ void getEndpoint(
1415 @ Parameter Foo foo ,
1516 @ Parameter Bar bar );
1617
18+ @ Mapping ("/endpoint-dashed" )
19+ void getEndpointDashed (@ Parameter FooFoo fooFoo );
20+
1721}
Original file line number Diff line number Diff line change 1+ package generated .model ;
2+
3+ import com .fasterxml .jackson .annotation .JsonCreator ;
4+ import com .fasterxml .jackson .annotation .JsonValue ;
5+ import generated .support .Generated ;
6+
7+ @ Generated (value = "openapi-processor-core" , version = "test" )
8+ public enum FooFoo {
9+ FOO ("foo" ),
10+ FOO_2 ("foo-2" ),
11+ FOO_FOO ("foo-foo" );
12+
13+ private final String value ;
14+
15+ FooFoo (String value ) {
16+ this .value = value ;
17+ }
18+
19+ @ JsonValue
20+ public String getValue () {
21+ return this .value ;
22+ }
23+
24+ @ JsonCreator
25+ public static FooFoo fromValue (String value ) {
26+ for (FooFoo val : FooFoo .values ()) {
27+ if (val .value .equals (value )) {
28+ return val ;
29+ }
30+ }
31+ throw new IllegalArgumentException (value );
32+ }
33+
34+ }
Original file line number Diff line number Diff line change @@ -30,6 +30,25 @@ paths:
3030 ' 204 ' :
3131 description : empty
3232
33+ /endpoint-dashed :
34+ get :
35+ tags :
36+ - enum
37+ parameters :
38+ - name : foo-foo
39+ description : enum parameter
40+ in : query
41+ required : true
42+ schema :
43+ type : string
44+ enum :
45+ - foo
46+ - foo-2
47+ - foo-foo
48+ responses :
49+ ' 204 ' :
50+ description : empty
51+
3352components :
3453 schemas :
3554
Original file line number Diff line number Diff line change @@ -30,6 +30,25 @@ paths:
3030 ' 204 ' :
3131 description : empty
3232
33+ /endpoint-dashed :
34+ get :
35+ tags :
36+ - enum
37+ parameters :
38+ - name : foo-foo
39+ description : enum parameter
40+ in : query
41+ required : true
42+ schema :
43+ type : string
44+ enum :
45+ - foo
46+ - foo-2
47+ - foo-foo
48+ responses :
49+ ' 204 ' :
50+ description : empty
51+
3352components :
3453 schemas :
3554
You can’t perform that action at this time.
0 commit comments