@@ -28,15 +28,13 @@ public class MethodParamDocBuilder {
28
28
private final String rawType ;
29
29
private final ParamType paramType ;
30
30
private final Element element ;
31
- private Optional <ConsumesPrism > consumeOp ;
31
+ private final Optional <ConsumesPrism > consumeOp ;
32
32
33
33
public MethodParamDocBuilder (MethodDocBuilder methodDoc , ElementReader param ) {
34
-
35
34
this .ctx = methodDoc .getContext ();
36
35
this .javadoc = methodDoc .getJavadoc ();
37
36
this .operation = methodDoc .getOperation ();
38
37
this .consumeOp = methodDoc .consumeOp ();
39
-
40
38
this .paramType = param .paramType ();
41
39
this .paramName = param .paramName ();
42
40
this .varName = param .varName ();
@@ -48,7 +46,6 @@ public MethodParamDocBuilder(MethodDocBuilder methodDoc, ElementReader param) {
48
46
* Build the OpenAPI documentation for the method parameter.
49
47
*/
50
48
public void build () {
51
-
52
49
if (paramType == ParamType .FORM || paramType == ParamType .BODY ) {
53
50
addMetaRequestBody (ctx , javadoc , operation );
54
51
@@ -57,7 +54,7 @@ public void build() {
57
54
param .setName (varName );
58
55
param .setDescription (javadoc .getParams ().get (paramName ));
59
56
60
- Schema schema = ctx .toSchema (rawType , element );
57
+ Schema <?> schema = ctx .toSchema (rawType , element );
61
58
if (paramType == ParamType .FORMPARAM ) {
62
59
ctx .addFormParam (operation , varName , schema );
63
60
@@ -70,24 +67,22 @@ public void build() {
70
67
}
71
68
72
69
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 );
76
72
var mediaType =
77
73
consumeOp
78
74
.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 ));
89
76
90
77
ctx .addRequestBody (operation , schema , mediaType , description );
91
78
}
92
79
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
+
93
88
}
0 commit comments