@@ -1286,6 +1286,7 @@ public String toDefaultValue(Schema schema) {
1286
1286
1287
1287
/**
1288
1288
* Return property value depending on property type.
1289
+ *
1289
1290
* @param schema property type
1290
1291
* @return property value
1291
1292
*/
@@ -1450,7 +1451,8 @@ private static String getPrimitiveType(Schema schema) {
1450
1451
} else if (ModelUtils .isDoubleSchema (schema )) {
1451
1452
return SchemaTypeUtil .DOUBLE_FORMAT ;
1452
1453
} else {
1453
- LOGGER .warn ("Unknown `format` detected for " + schema .getName () + ": " + schema .getFormat ());
1454
+ LOGGER .warn ("Unknown `format` {} detected for type `number`. Defaulting to `number`" , schema .getFormat ());
1455
+ return "number" ;
1454
1456
}
1455
1457
} else if (ModelUtils .isIntegerSchema (schema )) {
1456
1458
if (ModelUtils .isLongSchema (schema )) {
@@ -1891,7 +1893,7 @@ public String getterAndSetterCapitalize(String name) {
1891
1893
*/
1892
1894
public CodegenProperty fromProperty (String name , Schema p ) {
1893
1895
if (p == null ) {
1894
- LOGGER .error ("Undefined property/schema for `{}`. Default to type:string." , name );
1896
+ LOGGER .error ("Undefined property/schema for `{}`. Default to type:string." , name );
1895
1897
return null ;
1896
1898
}
1897
1899
LOGGER .debug ("debugging fromProperty for " + name + " : " + p );
@@ -2041,7 +2043,7 @@ public CodegenProperty fromProperty(String name, Schema p) {
2041
2043
if (innerSchema == null ) {
2042
2044
LOGGER .error ("Undefined array inner type for `{}`. Default to String." , p .getName ());
2043
2045
innerSchema = new StringSchema ().description ("//TODO automatically added by openapi-generator due to undefined type" );
2044
- ((ArraySchema )p ).setItems (innerSchema );
2046
+ ((ArraySchema ) p ).setItems (innerSchema );
2045
2047
}
2046
2048
} else if (ModelUtils .isMapSchema (p )) {
2047
2049
Schema innerSchema = ModelUtils .unaliasSchema (this .openAPI , ModelUtils .getAdditionalProperties (p ));
@@ -2123,7 +2125,7 @@ public CodegenProperty fromProperty(String name, Schema p) {
2123
2125
if (innerSchema == null ) {
2124
2126
LOGGER .error ("Undefined array inner type for `{}`. Default to String." , p .getName ());
2125
2127
innerSchema = new StringSchema ().description ("//TODO automatically added by openapi-generator due to undefined type" );
2126
- ((ArraySchema )p ).setItems (innerSchema );
2128
+ ((ArraySchema ) p ).setItems (innerSchema );
2127
2129
}
2128
2130
CodegenProperty cp = fromProperty (itemName , innerSchema );
2129
2131
updatePropertyForArray (property , cp );
@@ -2515,8 +2517,8 @@ public CodegenOperation fromOperation(String path,
2515
2517
CodegenParameter bodyParam = null ;
2516
2518
RequestBody requestBody = operation .getRequestBody ();
2517
2519
if (requestBody != null ) {
2518
- if ("application/x-www-form-urlencoded" . equalsIgnoreCase ( getContentType ( requestBody ) ) ||
2519
- "multipart/form-data" . equalsIgnoreCase ( getContentType ( requestBody ) )) {
2520
+ if (getContentType ( requestBody ). toLowerCase ( Locale . ROOT ). startsWith ( "application/x-www-form-urlencoded" ) ||
2521
+ getContentType ( requestBody ). toLowerCase ( Locale . ROOT ). startsWith ( "multipart/form-data" )) {
2520
2522
// process form parameters
2521
2523
formParams = fromRequestBodyToFormParameters (requestBody , imports );
2522
2524
for (CodegenParameter cp : formParams ) {
@@ -4194,7 +4196,8 @@ public void writePropertyBack(String propertyKey, boolean value) {
4194
4196
4195
4197
protected String getContentType (RequestBody requestBody ) {
4196
4198
if (requestBody == null || requestBody .getContent () == null || requestBody .getContent ().isEmpty ()) {
4197
- return null ;
4199
+ LOGGER .warn ("Cannot determine the content type. Default to UNKNOWN_CONTENT_TYPE." );
4200
+ return "UNKNOWN_CONTENT_TYPE" ;
4198
4201
}
4199
4202
return new ArrayList <>(requestBody .getContent ().keySet ()).get (0 );
4200
4203
}
@@ -4275,7 +4278,9 @@ public boolean hasFormParameter(OpenAPI openAPI, Operation operation) {
4275
4278
}
4276
4279
4277
4280
for (String consume : consumesInfo ) {
4278
- if ("application/x-www-form-urlencoded" .equalsIgnoreCase (consume ) || "multipart/form-data" .equalsIgnoreCase (consume )) {
4281
+ if (consume != null &&
4282
+ consume .toLowerCase (Locale .ROOT ).startsWith ("application/x-www-form-urlencoded" ) ||
4283
+ consume .toLowerCase (Locale .ROOT ).startsWith ("multipart/form-data" )) {
4279
4284
return true ;
4280
4285
}
4281
4286
}
@@ -4849,7 +4854,7 @@ public List<CodegenServerVariable> fromServerVariables(Map<String, ServerVariabl
4849
4854
}
4850
4855
4851
4856
private void setParameterNullable (CodegenParameter parameter , CodegenProperty property ) {
4852
- if (parameter == null || property == null ) {
4857
+ if (parameter == null || property == null ) {
4853
4858
return ;
4854
4859
}
4855
4860
parameter .isNullable = property .isNullable ;
@@ -4898,7 +4903,7 @@ public boolean isEnableMinimalUpdate() {
4898
4903
/**
4899
4904
* Set the boolean value indicating the state of the option for updating only changed files
4900
4905
*
4901
- * @param enableMinimalUpdate true to enable minimal update
4906
+ * @param enableMinimalUpdate true to enable minimal update
4902
4907
*/
4903
4908
@ Override
4904
4909
public void setEnableMinimalUpdate (boolean enableMinimalUpdate ) {
0 commit comments