Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ public void buildParamName(Append writer) {
}

public void buildApiDocumentation(MethodDocBuilder methodDoc) {
if (elementParam.paramType() != ParamType.BEANPARAM) {
if (elementParam.paramType() != ParamType.BEANPARAM && elementParam.paramType() != ParamType.FORM) {
elementParam.buildApiDocumentation(methodDoc);
} else {
asElement(elementParam.element().asType()).getEnclosedElements().stream()
.filter(e -> e.getKind() == ElementKind.FIELD)
.map(VariableElement.class::cast)
.forEach(e -> buildDoc(methodDoc, e));
.forEach(e -> buildDoc(methodDoc, e, elementParam.paramType() == ParamType.FORM));
}
}

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.example.myapp.web.test;

import io.avaje.http.api.Header;

public class MyForm {

public String name;
public String email;
public String url;
@Header
public String headString;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import io.avaje.http.api.Controller;
import io.avaje.http.api.Delete;
import io.avaje.http.api.Form;
import io.avaje.http.api.Get;
import io.avaje.http.api.Header;
import io.avaje.http.api.MediaType;
Expand Down Expand Up @@ -107,4 +108,10 @@ String testDefaultStatus(Context ctx) {
String testPathParam(String type, @QueryParam String lastName, @QueryParam("q-2") String param2, @Header String contentLength, @Header("x-oh") String otherHeader) {
return "only partial info";
}

@Form
@Post("/form")
String testForm(MyForm form) {
return "only partial info";
}
}
Loading