@@ -28,15 +28,13 @@ public class MethodParamDocBuilder {
2828 private final String rawType ;
2929 private final ParamType paramType ;
3030 private final Element element ;
31- private Optional <ConsumesPrism > consumeOp ;
31+ private final Optional <ConsumesPrism > consumeOp ;
3232
3333 public MethodParamDocBuilder (MethodDocBuilder methodDoc , ElementReader param ) {
34-
3534 this .ctx = methodDoc .getContext ();
3635 this .javadoc = methodDoc .getJavadoc ();
3736 this .operation = methodDoc .getOperation ();
3837 this .consumeOp = methodDoc .consumeOp ();
39-
4038 this .paramType = param .paramType ();
4139 this .paramName = param .paramName ();
4240 this .varName = param .varName ();
@@ -48,7 +46,6 @@ public MethodParamDocBuilder(MethodDocBuilder methodDoc, ElementReader param) {
4846 * Build the OpenAPI documentation for the method parameter.
4947 */
5048 public void build () {
51-
5249 if (paramType == ParamType .FORM || paramType == ParamType .BODY ) {
5350 addMetaRequestBody (ctx , javadoc , operation );
5451
@@ -57,7 +54,7 @@ public void build() {
5754 param .setName (varName );
5855 param .setDescription (javadoc .getParams ().get (paramName ));
5956
60- Schema schema = ctx .toSchema (rawType , element );
57+ Schema <?> schema = ctx .toSchema (rawType , element );
6158 if (paramType == ParamType .FORMPARAM ) {
6259 ctx .addFormParam (operation , varName , schema );
6360
@@ -70,24 +67,22 @@ public void build() {
7067 }
7168
7269 private void addMetaRequestBody (DocContext ctx , Javadoc javadoc , Operation operation ) {
73-
74- Schema schema = ctx .toSchema (rawType , element );
75- String description = javadoc .getParams ().get (paramName );
70+ final var schema = ctx .toSchema (rawType , element );
71+ final var description = javadoc .getParams ().get (paramName );
7672 var mediaType =
7773 consumeOp
7874 .map (ConsumesPrism ::value )
79- .orElseGet (
80- () -> {
81- boolean asForm = (paramType == ParamType .FORM );
82- var mime = asForm ? APP_FORM : APP_JSON ;
83-
84- if (schema instanceof StringSchema ) {
85- mime = APP_TXT ;
86- }
87- return mime ;
88- });
75+ .orElseGet (() -> requestMedia (schema ));
8976
9077 ctx .addRequestBody (operation , schema , mediaType , description );
9178 }
9279
80+ private String requestMedia (Schema <?> schema ) {
81+ if (schema instanceof StringSchema ) {
82+ return APP_TXT ;
83+ }
84+ boolean asForm = (paramType == ParamType .FORM );
85+ return asForm ? APP_FORM : APP_JSON ;
86+ }
87+
9388}
0 commit comments