File tree Expand file tree Collapse file tree 3 files changed +59
-27
lines changed
http-generator-core/src/main/java/io/avaje/http/generator/core/openapi
tests/test-javalin-jsonb/src/main/resources/public Expand file tree Collapse file tree 3 files changed +59
-27
lines changed Original file line number Diff line number Diff line change 2222import io .avaje .http .generator .core .SecuritySchemesPrism ;
2323import io .avaje .http .generator .core .TagPrism ;
2424import io .avaje .http .generator .core .TagsPrism ;
25+ import io .avaje .http .generator .core .Util ;
2526import io .swagger .v3 .oas .models .Components ;
2627import io .swagger .v3 .oas .models .OpenAPI ;
2728import io .swagger .v3 .oas .models .Operation ;
@@ -77,12 +78,17 @@ private OpenAPI initOpenAPI() {
7778 }
7879
7980 Schema toSchema (String rawType , Element element ) {
80- TypeElement typeElement = elements .getTypeElement (rawType );
81+ final var typeElement = elements .getTypeElement (rawType );
82+ final var varElement =
83+ elements .getTypeElement (Util .trimAnnotations (element .asType ().toString ()));
84+
8185 if (typeElement == null ) {
8286 // primitive types etc
8387 return schemaBuilder .toSchema (element .asType ());
88+ } else if (varElement != null ) {
89+ return schemaBuilder .toSchema (element );
8490 } else {
85- return schemaBuilder .toSchema (typeElement . asType () );
91+ return schemaBuilder .toSchema (typeElement );
8692 }
8793 }
8894
Original file line number Diff line number Diff line change @@ -132,6 +132,17 @@ private static TypeMirror typeArgument(TypeMirror type) {
132132 return typeArguments .get (0 );
133133 }
134134
135+ Schema <?> toSchema (Element element ) {
136+ var schema = toSchema (element .asType ());
137+
138+ setLengthMinMax (element , schema );
139+ setFormatFromValidation (element , schema );
140+ if (isNotNullable (element )) {
141+ schema .setNullable (Boolean .FALSE );
142+ }
143+ return schema ;
144+ }
145+
135146 Schema <?> toSchema (TypeMirror type ) {
136147 if (types .isAssignable (type , completableFutureType )) {
137148 type = typeArgument (type );
Original file line number Diff line number Diff line change 692692 "description" : " " ,
693693 "parameters" : [
694694 {
695- "name" : " bean " ,
696- "in" : " bean " ,
695+ "name" : " name " ,
696+ "in" : " query " ,
697697 "schema" : {
698- "$ref" : " #/components/schemas/GetBeanForm"
698+ "maxLength" : 150 ,
699+ "minLength" : 2 ,
700+ "type" : " string" ,
701+ "nullable" : false
702+ }
703+ },
704+ {
705+ "name" : " email" ,
706+ "in" : " query" ,
707+ "schema" : {
708+ "maxLength" : 100 ,
709+ "type" : " string" ,
710+ "format" : " email"
711+ }
712+ },
713+ {
714+ "name" : " addresses" ,
715+ "in" : " query" ,
716+ "schema" : {
717+ "type" : " array" ,
718+ "items" : {
719+ "type" : " string"
720+ }
721+ }
722+ },
723+ {
724+ "name" : " head" ,
725+ "in" : " header" ,
726+ "schema" : {
727+ "type" : " string"
699728 }
700729 }
701730 ],
14401469 }
14411470 }
14421471 }
1472+ },
1473+ }
1474+ }
1475+ }
1476+ }
14431477 },
14441478 "/test/int" : {
14451479 "put" : {
18051839 }
18061840 }
18071841 },
1808- "GetBeanForm" : {
1809- "type" : " object" ,
1810- "properties" : {
1811- "name" : {
1812- "maxLength" : 150 ,
1813- "minLength" : 2 ,
1814- "type" : " string" ,
1815- "nullable" : false
1816- },
1817- "email" : {
1818- "maxLength" : 100 ,
1819- "type" : " string" ,
1820- "format" : " email"
1821- },
1822- "addresses" : {
1823- "type" : " array" ,
1824- "items" : {
1825- "type" : " string"
1826- }
1827- }
1828- }
1829- },
18301842 "HelloDto" : {
18311843 "type" : " object" ,
18321844 "properties" : {
18761888 }
18771889 }
18781890 },
1891+ "InputStream" : {
1892+ "type" : " object"
1893+ },
18791894 "MyForm" : {
18801895 "type" : " object" ,
18811896 "properties" : {
You can’t perform that action at this time.
0 commit comments