File tree Expand file tree Collapse file tree 3 files changed +36
-5
lines changed
http-generator-core/src/main/java/io/avaje/http/generator/core
tests/test-javalin-jsonb/src/main/java/org/example/myapp/web Expand file tree Collapse file tree 3 files changed +36
-5
lines changed Original file line number Diff line number Diff line change 11package io .avaje .http .generator .core ;
22
3- import static io .avaje .http .generator .core .ProcessingContext .*;
43import static io .avaje .http .generator .core .ParamType .RESPONSE_HANDLER ;
4+ import static io .avaje .http .generator .core .ProcessingContext .platform ;
5+ import static io .avaje .http .generator .core .ProcessingContext .typeElement ;
56
67import java .util .List ;
78import java .util .Objects ;
@@ -245,7 +246,7 @@ void writeParamName(Append writer) {
245246 * Build the OpenAPI documentation for this parameter.
246247 */
247248 void buildApiDocumentation (MethodDocBuilder methodDoc ) {
248- if (!isPlatformContext () && !isParamMap ) {
249+ if (!isPlatformContext () && !isParamMap && paramType != ParamType . BEANPARAM ) {
249250 new MethodParamDocBuilder (methodDoc , this ).build ();
250251 }
251252 }
Original file line number Diff line number Diff line change 11package io .avaje .http .generator .core ;
22
3- import io .avaje .http .generator .core .openapi . MethodDocBuilder ;
3+ import static io .avaje .http .generator .core .ProcessingContext . asElement ;
44
5+ import javax .lang .model .element .ElementKind ;
56import javax .lang .model .element .VariableElement ;
67
8+ import io .avaje .http .generator .core .openapi .MethodDocBuilder ;
9+
710public class MethodParam {
811
912 private final ElementReader elementParam ;
@@ -29,8 +32,26 @@ public void buildParamName(Append writer) {
2932 }
3033
3134 public void buildApiDocumentation (MethodDocBuilder methodDoc ) {
32- elementParam .buildApiDocumentation (methodDoc );
33- }
35+ if (elementParam .paramType () != ParamType .BEANPARAM )
36+ elementParam .buildApiDocumentation (methodDoc );
37+ else {
38+ asElement (elementParam .element ().asType ()).getEnclosedElements ().stream ()
39+ .filter (e -> e .getKind () == ElementKind .FIELD )
40+ .map (VariableElement .class ::cast )
41+ .forEach (
42+ e -> {
43+ final var typeMirror = e .asType ();
44+
45+ new ElementReader (
46+ e ,
47+ Util .parse (typeMirror .toString ()),
48+ Util .typeDef (typeMirror ),
49+ ParamType .QUERYPARAM ,
50+ false )
51+ .buildApiDocumentation (methodDoc );
52+ });
53+ }
54+ }
3455
3556 public boolean isBody () {
3657 return elementParam .paramType () == ParamType .BODY ;
Original file line number Diff line number Diff line change 77import javax .validation .constraints .NotNull ;
88import javax .validation .constraints .Size ;
99
10+ import io .avaje .http .api .Header ;
1011import io .avaje .jsonb .Json ;
1112
1213@ Json
@@ -22,6 +23,8 @@ public class GetBeanForm {
2223 private String email ;
2324
2425 private List <String > addresses ;
26+ @ Header
27+ private String head ;
2528
2629 public String getName () {
2730 return name ;
@@ -56,4 +59,10 @@ public List<String> getAddresses() {
5659 public void setAddresses (List <String > addresses ) {
5760 this .addresses = addresses ;
5861 }
62+
63+ public String getHead () {
64+ return head ;}
65+
66+ public void setHead (String head ) {
67+ this .head = head ;}
5968}
You can’t perform that action at this time.
0 commit comments