diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 241b3f881ef0..bb92904b92c6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2974,12 +2974,6 @@ protected void updateModelForObject(CodegenModel m, Schema schema) { } protected void updateModelForAnyType(CodegenModel m, Schema schema) { - // The 'null' value is allowed when the OAS schema is 'any type'. - // See https://github.com/OAI/OpenAPI-Specification/issues/1389 - if (Boolean.FALSE.equals(schema.getNullable())) { - LOGGER.error("Schema '{}' is any type, which includes the 'null' value. 'nullable' cannot be set to 'false'", m.name); - } - // m.isNullable = true; if (ModelUtils.isMapSchema(schema)) { // an object or anyType composed schema that has additionalProperties set addAdditionPropertiesToCodeGenModel(m, schema); @@ -3714,12 +3708,6 @@ protected void updatePropertyForObject(CodegenProperty property, Schema p) { } protected void updatePropertyForAnyType(CodegenProperty property, Schema p) { - // The 'null' value is allowed when the OAS schema is 'any type'. - // See https://github.com/OAI/OpenAPI-Specification/issues/1389 - if (Boolean.FALSE.equals(p.getNullable())) { - LOGGER.warn("Schema '{}' is any type, which includes the 'null' value. 'nullable' cannot be set to 'false'", p.getName()); - } - property.isNullable = property.isNullable || !(ModelUtils.isComposedSchema(p)) || p.getAllOf() == null || diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java index d0b71a23d1c3..461311648c0c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java @@ -2182,13 +2182,22 @@ protected Schema processNormalize31Spec(Schema schema, Set visitedSchema normalizeExclusiveMinMax31(schema); if (schema instanceof JsonSchema && - schema.get$schema() == null && - schema.getTypes() == null && schema.getType() == null) { + schema.get$schema() == null && schema.getTypes() == null && schema.getType() == null) { // convert any type in v3.1 to empty schema (any type in v3.0 spec), any type example: // components: // schemas: // any_type: {} - return new Schema(); + Schema sc = new Schema<>(); + + // copy description, title, etc + ModelUtils.copyMetadata(schema, sc); + + // additional properties set? + if (schema.getAdditionalProperties() != null) { + sc.setAdditionalProperties(schema.getAdditionalProperties()); + } + + return sc; } // return schema if nothing in 3.1 spec types to normalize diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java index 40058b1e90f2..cea929c90965 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java @@ -2620,8 +2620,9 @@ public static boolean isNullTypeSchema(OpenAPI openAPI, Schema schema) { return false; } - // schema with properties - if (schema.getProperties() != null) { + // schema with properties or additional properties + if (schema.getProperties() != null || + (schema.getAdditionalProperties() != null && !Boolean.FALSE.equals(schema.getBooleanSchemaValue()))) { return false; } @@ -2726,7 +2727,7 @@ public static void copyMetadata(Schema from, Schema to) { to.setExample(from.getExample()); } if (from.getExamples() != null) { - to.setExample(from.getExamples()); + to.setExamples(from.getExamples()); } if (from.getReadOnly() != null) { to.setReadOnly(from.getReadOnly());