@@ -1486,20 +1486,20 @@ public DefaultCodegen() {
1486
1486
1487
1487
// option to change how we process + set the data in the 'additionalProperties' keyword.
1488
1488
CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption .newBoolean (
1489
- CodegenConstants .DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT ,
1490
- CodegenConstants .DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_DESC ).defaultValue (Boolean .TRUE .toString ());
1489
+ CodegenConstants .DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT ,
1490
+ CodegenConstants .DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT_DESC ).defaultValue (Boolean .TRUE .toString ());
1491
1491
Map <String , String > disallowAdditionalPropertiesIfNotPresentOpts = new HashMap <>();
1492
1492
disallowAdditionalPropertiesIfNotPresentOpts .put ("false" ,
1493
- "The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications." );
1493
+ "The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications." );
1494
1494
disallowAdditionalPropertiesIfNotPresentOpts .put ("true" ,
1495
- "when the 'additionalProperties' keyword is not present in a schema, " +
1496
- "the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. " +
1497
- "Note: this mode is not compliant with the JSON schema specification. " +
1498
- "This is the original openapi-generator behavior." );
1495
+ "when the 'additionalProperties' keyword is not present in a schema, " +
1496
+ "the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. " +
1497
+ "Note: this mode is not compliant with the JSON schema specification. " +
1498
+ "This is the original openapi-generator behavior." );
1499
1499
disallowAdditionalPropertiesIfNotPresentOpt .setEnum (disallowAdditionalPropertiesIfNotPresentOpts );
1500
1500
cliOptions .add (disallowAdditionalPropertiesIfNotPresentOpt );
1501
1501
this .setDisallowAdditionalPropertiesIfNotPresent (true );
1502
-
1502
+
1503
1503
// initialize special character mapping
1504
1504
initalizeSpecialCharacterMapping ();
1505
1505
@@ -2640,7 +2640,7 @@ private Discriminator recursiveGetDiscriminator(Schema sc, OpenAPI openAPI) {
2640
2640
Integer hasDiscriminatorCnt = 0 ;
2641
2641
Integer hasNullTypeCnt = 0 ;
2642
2642
Set <String > discriminatorsPropNames = new HashSet <>();
2643
- for (Schema oneOf : composedSchema .getOneOf ()) {
2643
+ for (Schema oneOf : composedSchema .getOneOf ()) {
2644
2644
if (ModelUtils .isNullType (oneOf )) {
2645
2645
// The null type does not have a discriminator. Skip.
2646
2646
hasNullTypeCnt ++;
@@ -2654,7 +2654,7 @@ private Discriminator recursiveGetDiscriminator(Schema sc, OpenAPI openAPI) {
2654
2654
}
2655
2655
if (discriminatorsPropNames .size () > 1 ) {
2656
2656
throw new RuntimeException ("The oneOf schemas have conflicting discriminator property names. " +
2657
- "oneOf schemas must have the same property name, but found " + String .join (", " , discriminatorsPropNames ));
2657
+ "oneOf schemas must have the same property name, but found " + String .join (", " , discriminatorsPropNames ));
2658
2658
}
2659
2659
if ((hasDiscriminatorCnt + hasNullTypeCnt ) == composedSchema .getOneOf ().size () && discriminatorsPropNames .size () == 1 ) {
2660
2660
disc .setPropertyName (foundDisc .getPropertyName ());
@@ -2669,7 +2669,7 @@ private Discriminator recursiveGetDiscriminator(Schema sc, OpenAPI openAPI) {
2669
2669
Integer hasDiscriminatorCnt = 0 ;
2670
2670
Integer hasNullTypeCnt = 0 ;
2671
2671
Set <String > discriminatorsPropNames = new HashSet <>();
2672
- for (Schema anyOf : composedSchema .getAnyOf ()) {
2672
+ for (Schema anyOf : composedSchema .getAnyOf ()) {
2673
2673
if (ModelUtils .isNullType (anyOf )) {
2674
2674
// The null type does not have a discriminator. Skip.
2675
2675
hasNullTypeCnt ++;
@@ -2720,7 +2720,7 @@ protected List<MappedModel> getOneOfAnyOfDescendants(String composedSchemaName,
2720
2720
if (schemaList == null ) {
2721
2721
continue ;
2722
2722
}
2723
- for (Schema sc : schemaList ) {
2723
+ for (Schema sc : schemaList ) {
2724
2724
if (ModelUtils .isNullType (sc )) {
2725
2725
continue ;
2726
2726
}
@@ -2875,7 +2875,7 @@ protected CodegenDiscriminator createDiscriminator(String schemaName, Schema sch
2875
2875
* Handle the model for the 'additionalProperties' keyword in the OAS schema.
2876
2876
*
2877
2877
* @param codegenModel The codegen representation of the schema.
2878
- * @param schema the input OAS schema.
2878
+ * @param schema The input OAS schema.
2879
2879
*/
2880
2880
protected void addAdditionPropertiesToCodeGenModel (CodegenModel codegenModel , Schema schema ) {
2881
2881
addParentContainer (codegenModel , codegenModel .name , schema );
@@ -3503,7 +3503,7 @@ protected void handleMethodResponse(Operation operation,
3503
3503
op .returnType = cm .dataType ;
3504
3504
op .returnFormat = cm .dataFormat ;
3505
3505
op .hasReference = schemas != null && schemas .containsKey (op .returnBaseType );
3506
-
3506
+
3507
3507
// lookup discriminator
3508
3508
Schema schema = schemas .get (op .returnBaseType );
3509
3509
if (schema != null ) {
@@ -3965,8 +3965,8 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
3965
3965
r .containerType = cp .containerType ;
3966
3966
r .isMapContainer = "map" .equals (cp .containerType );
3967
3967
r .isListContainer = "list" .equalsIgnoreCase (cp .containerType ) ||
3968
- "array" .equalsIgnoreCase (cp .containerType ) ||
3969
- "set" .equalsIgnoreCase (cp .containerType );
3968
+ "array" .equalsIgnoreCase (cp .containerType ) ||
3969
+ "set" .equalsIgnoreCase (cp .containerType );
3970
3970
} else {
3971
3971
r .simpleType = true ;
3972
3972
}
@@ -4317,7 +4317,7 @@ public boolean isDataTypeBinary(String dataType) {
4317
4317
return false ;
4318
4318
}
4319
4319
}
4320
-
4320
+
4321
4321
// TODO revise below as it should be replaced by ModelUtils.isFileSchema(parameterSchema)
4322
4322
public boolean isDataTypeFile (String dataType ) {
4323
4323
if (dataType != null ) {
@@ -5795,6 +5795,7 @@ private void addBodyModelSchema(CodegenParameter codegenParameter, String name,
5795
5795
codegenParameter .baseType = codegenModel .classname ;
5796
5796
codegenParameter .dataType = getTypeDeclaration (codegenModel .classname );
5797
5797
codegenParameter .description = codegenModel .description ;
5798
+ codegenParameter .isNullable = codegenModel .isNullable ;
5798
5799
imports .add (codegenParameter .baseType );
5799
5800
} else {
5800
5801
CodegenProperty codegenProperty = fromProperty ("property" , schema );
@@ -5808,6 +5809,7 @@ private void addBodyModelSchema(CodegenParameter codegenParameter, String name,
5808
5809
codegenParameter .baseType = codegenParameter .baseName ;
5809
5810
codegenParameter .dataType = getTypeDeclaration (codegenModelName );
5810
5811
codegenParameter .description = codegenProperty .getDescription ();
5812
+ codegenParameter .isNullable = codegenProperty .isNullable ;
5811
5813
} else {
5812
5814
if (ModelUtils .isMapSchema (schema )) {// http body is map
5813
5815
LOGGER .error ("Map should be supported. Please report to openapi-generator github repo about the issue." );
@@ -5916,6 +5918,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
5916
5918
codegenParameter .baseType = getSchemaType (inner );
5917
5919
codegenParameter .isContainer = Boolean .TRUE ;
5918
5920
codegenParameter .isMapContainer = Boolean .TRUE ;
5921
+ codegenParameter .isNullable = codegenProperty .isNullable ;
5919
5922
5920
5923
setParameterBooleanFlagWithCodegenProperty (codegenParameter , codegenProperty );
5921
5924
@@ -5958,6 +5961,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
5958
5961
codegenParameter .baseType = getSchemaType (inner );
5959
5962
codegenParameter .isContainer = Boolean .TRUE ;
5960
5963
codegenParameter .isListContainer = Boolean .TRUE ;
5964
+ codegenParameter .isNullable = codegenProperty .isNullable ;
5961
5965
5962
5966
setParameterBooleanFlagWithCodegenProperty (codegenParameter , codegenProperty );
5963
5967
// set nullable
@@ -5981,6 +5985,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
5981
5985
codegenParameter .baseType = codegenProperty .baseType ;
5982
5986
codegenParameter .dataType = codegenProperty .dataType ;
5983
5987
codegenParameter .description = codegenProperty .description ;
5988
+ codegenParameter .isNullable = codegenProperty .isNullable ;
5984
5989
codegenParameter .paramName = toParamName (codegenParameter .baseName );
5985
5990
}
5986
5991
setParameterBooleanFlagWithCodegenProperty (codegenParameter , codegenProperty );
@@ -6010,6 +6015,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, S
6010
6015
codegenParameter .minLength = codegenProperty .minLength ;
6011
6016
codegenParameter .maxLength = codegenProperty .maxLength ;
6012
6017
codegenParameter .pattern = codegenProperty .pattern ;
6018
+ codegenParameter .isNullable = codegenProperty .isNullable ;
6013
6019
6014
6020
if (codegenProperty .complexType != null ) {
6015
6021
imports .add (codegenProperty .complexType );
0 commit comments