File tree Expand file tree Collapse file tree 6 files changed +72
-2
lines changed
main/java/io/avaje/http/generator/core
test/java/io/avaje/http/generator/core
tests/test-javalin-jsonb/src/main
java/org/example/myapp/web Expand file tree Collapse file tree 6 files changed +72
-2
lines changed Original file line number Diff line number Diff line change @@ -316,12 +316,12 @@ static class EnumHandler extends ObjectHandler {
316
316
317
317
@ Override
318
318
public String toMethod () {
319
- return "(" + type .shortType () + ") toEnum(" + type .shortType () + ".class, " ;
319
+ return "(" + type .shortTypeNested () + ") toEnum(" + type .shortTypeNested () + ".class, " ;
320
320
}
321
321
322
322
@ Override
323
323
public String asMethod () {
324
- return "(" + type .shortType () + ") asEnum(" + type .shortType () + ".class, " ;
324
+ return "(" + type .shortTypeNested () + ") asEnum(" + type .shortTypeNested () + ".class, " ;
325
325
}
326
326
}
327
327
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ static UType parse(String type) {
31
31
*/
32
32
String shortType ();
33
33
34
+ /**
35
+ * Return the short type taking nested type into account.
36
+ */
37
+ default String shortTypeNested () {
38
+ return shortType ();
39
+ }
40
+
34
41
/**
35
42
* Return the short name.
36
43
*/
@@ -152,6 +159,11 @@ public String shortType() {
152
159
return Util .shortName (rawType );
153
160
}
154
161
162
+ @ Override
163
+ public String shortTypeNested () {
164
+ return Util .shortName (rawType , true );
165
+ }
166
+
155
167
@ Override
156
168
public String shortName () {
157
169
return Util .initLower (shortType ()).replace ("." , "$" );
Original file line number Diff line number Diff line change 2
2
3
3
import org .junit .jupiter .api .Test ;
4
4
5
+ import static org .assertj .core .api .Assertions .assertThat ;
5
6
import static org .junit .jupiter .api .Assertions .*;
6
7
7
8
class UTypeTest {
@@ -17,4 +18,12 @@ void isJavaLangPackage_expect_false() {
17
18
assertFalse (UType .isJavaLangPackage ("java.lang.other.Foo" ));
18
19
assertFalse (UType .isJavaLangPackage ("not.lang.Foo" ));
19
20
}
21
+
22
+ @ Test
23
+ void parseNestedEnum () {
24
+ UType uType = UType .parse ("my.pack.Foo.NestedEnum" );
25
+ assertThat (uType .mainType ()).isEqualTo ("my.pack.Foo.NestedEnum" );
26
+ assertThat (uType .shortType ()).isEqualTo ("Foo.NestedEnum" );
27
+ assertThat (uType .shortTypeNested ()).isEqualTo ("NestedEnum" );
28
+ }
20
29
}
Original file line number Diff line number Diff line change 25
25
import io .javalin .http .Context ;
26
26
import io .swagger .v3 .oas .annotations .Hidden ;
27
27
import jakarta .inject .Inject ;
28
+ import org .example .myapp .web .other .Foo ;
28
29
29
30
/**
30
31
* Hello resource manager.
@@ -183,4 +184,10 @@ String controlStatusCode(Context ctx) {
183
184
ctx .status (201 );
184
185
return "controlStatusCode" ;
185
186
}
187
+
188
+ @ Produces (value = "text/plain" )
189
+ @ Get ("takesNestedEnum" )
190
+ String takesNestedEnum (Foo .NestedEnum myEnum ) {
191
+ return "takesNestedEnum-" + myEnum ;
192
+ }
186
193
}
Original file line number Diff line number Diff line change
1
+ package org .example .myapp .web .other ;
2
+
3
+ public class Foo {
4
+ public enum NestedEnum {
5
+ A , B , C
6
+ }
7
+ }
Original file line number Diff line number Diff line change 646
646
}
647
647
}
648
648
},
649
+ "/hello/takesNestedEnum" : {
650
+ "get" : {
651
+ "tags" : [
652
+
653
+ ],
654
+ "summary" : " " ,
655
+ "description" : " " ,
656
+ "parameters" : [
657
+ {
658
+ "name" : " myEnum" ,
659
+ "in" : " query" ,
660
+ "schema" : {
661
+ "type" : " string" ,
662
+ "enum" : [
663
+ " A" ,
664
+ " B" ,
665
+ " C"
666
+ ]
667
+ }
668
+ }
669
+ ],
670
+ "responses" : {
671
+ "200" : {
672
+ "description" : " " ,
673
+ "content" : {
674
+ "text/plain" : {
675
+ "schema" : {
676
+ "type" : " string"
677
+ }
678
+ }
679
+ }
680
+ }
681
+ }
682
+ }
683
+ },
649
684
"/hello/withMatrix/{year_segment}/{other}" : {
650
685
"get" : {
651
686
"tags" : [
You can’t perform that action at this time.
0 commit comments