Skip to content

Commit b2add98

Browse files
authored
Merge branch 'master' into valid-warning
2 parents 4fad803 + 53aabd2 commit b2add98

File tree

4 files changed

+227
-175
lines changed

4 files changed

+227
-175
lines changed

http-generator-core/src/main/java/io/avaje/http/generator/core/MethodParam.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ public void buildParamName(Append writer) {
3232
}
3333

3434
public void buildApiDocumentation(MethodDocBuilder methodDoc) {
35-
if (elementParam.paramType() != ParamType.BEANPARAM) {
35+
if (elementParam.paramType() != ParamType.BEANPARAM && elementParam.paramType() != ParamType.FORM) {
3636
elementParam.buildApiDocumentation(methodDoc);
3737
} else {
3838
asElement(elementParam.element().asType()).getEnclosedElements().stream()
3939
.filter(e -> e.getKind() == ElementKind.FIELD)
4040
.map(VariableElement.class::cast)
41-
.forEach(e -> buildDoc(methodDoc, e));
41+
.forEach(e -> buildDoc(methodDoc, e, elementParam.paramType() == ParamType.FORM));
4242
}
4343
}
4444

45-
private static void buildDoc(MethodDocBuilder methodDoc, VariableElement e) {
45+
private static void buildDoc(MethodDocBuilder methodDoc, VariableElement e, boolean form) {
4646
final var typeMirror = e.asType();
47-
new ElementReader(e, Util.parse(typeMirror.toString()), Util.typeDef(typeMirror), ParamType.QUERYPARAM, false)
47+
new ElementReader(e, Util.parse(typeMirror.toString()), Util.typeDef(typeMirror), form ? ParamType.FORMPARAM : ParamType.QUERYPARAM, form)
4848
.buildApiDocumentation(methodDoc);
4949
}
5050

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package org.example.myapp.web.test;
22

3+
import io.avaje.http.api.Header;
4+
35
public class MyForm {
46

57
public String name;
68
public String email;
79
public String url;
10+
@Header
11+
public String headString;
812
}

tests/test-javalin-jsonb/src/main/java/org/example/myapp/web/test/OpenAPIController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import io.avaje.http.api.Controller;
66
import io.avaje.http.api.Delete;
7+
import io.avaje.http.api.Form;
78
import io.avaje.http.api.Get;
89
import io.avaje.http.api.Header;
910
import io.avaje.http.api.MediaType;
@@ -107,4 +108,10 @@ String testDefaultStatus(Context ctx) {
107108
String testPathParam(String type, @QueryParam String lastName, @QueryParam("q-2") String param2, @Header String contentLength, @Header("x-oh") String otherHeader) {
108109
return "only partial info";
109110
}
111+
112+
@Form
113+
@Post("/form")
114+
String testForm(MyForm form) {
115+
return "only partial info";
116+
}
110117
}

0 commit comments

Comments
 (0)