@@ -2000,18 +2000,33 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
2000
2000
List <Schema > foundSchemas = new ArrayList <>();
2001
2001
2002
2002
for (String contentType : body .getContent ().keySet ()) {
2003
+ boolean isForm = "application/x-www-form-urlencoded" .equalsIgnoreCase (contentType ) || "multipart/form-data" .equalsIgnoreCase (contentType );
2003
2004
2004
2005
String schemaName = null ;
2005
2006
Schema schema = body .getContent ().get (contentType ).getSchema ();
2006
- if (StringUtils .isNotBlank (schema .get$ref ())) {
2007
+ if (schema != null && StringUtils .isNotBlank (schema .get$ref ())) {
2007
2008
schemaName = OpenAPIUtil .getSimpleRef (schema .get$ref ());
2008
2009
schema = schemas .get (schemaName );
2009
2010
}
2010
-
2011
- if ("application/x-www-form-urlencoded" .equalsIgnoreCase (contentType ) || "multipart/form-data" .equalsIgnoreCase (contentType )) {
2012
- final CodegenContent codegenContent = new CodegenContent (contentType );
2013
- codegenContent .getContentExtensions ().put (CodegenConstants .IS_FORM_EXT_NAME , Boolean .TRUE );
2014
-
2011
+ final CodegenContent codegenContent = new CodegenContent (contentType );
2012
+ codegenContent .getContentExtensions ().put (CodegenConstants .IS_FORM_EXT_NAME , isForm );
2013
+
2014
+ if (schema == null ) {
2015
+ CodegenParameter codegenParameter = CodegenModelFactory .newInstance (CodegenModelType .PARAMETER );
2016
+ codegenParameter .description = body .getDescription ();
2017
+ codegenParameter .unescapedDescription = body .getDescription ();
2018
+ codegenParameter .baseName = REQUEST_BODY_NAME ;
2019
+ codegenParameter .paramName = REQUEST_BODY_NAME ;
2020
+ codegenParameter .dataType = "Object" ;
2021
+ codegenParameter .baseType = "Object" ;
2022
+
2023
+ codegenParameter .required = body .getRequired () != null ? body .getRequired () : Boolean .FALSE ;
2024
+ if (!isForm ) {
2025
+ codegenParameter .getVendorExtensions ().put (CodegenConstants .IS_BODY_PARAM_EXT_NAME , Boolean .TRUE );
2026
+ }
2027
+ continue ;
2028
+ }
2029
+ if (isForm ) {
2015
2030
final Map <String , Schema > propertyMap = schema .getProperties ();
2016
2031
boolean isMultipart = contentType .equalsIgnoreCase ("multipart/form-data" );
2017
2032
if (propertyMap != null && !propertyMap .isEmpty ()) {
@@ -2049,7 +2064,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
2049
2064
}
2050
2065
}
2051
2066
foundSchemas .add (schema );
2052
- final CodegenContent codegenContent = new CodegenContent (contentType );
2053
2067
codegenContent .getParameters ().add (bodyParam .copy ());
2054
2068
codegenContents .add (codegenContent );
2055
2069
}
0 commit comments