Skip to content

Commit 80f521e

Browse files
committed
[3.1] Fixed lack of check for ´booleanSchemaValue`
1 parent aacbdf8 commit 80f521e

File tree

1 file changed

+8
-2
lines changed
  • modules/openapi-generator/src/main/java/org/openapitools/codegen/utils

1 file changed

+8
-2
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,13 @@ public static boolean isModelWithPropertiesOnly(Schema schema) {
808808
(null != schema.getProperties() && !schema.getProperties().isEmpty()) &&
809809
// no additionalProperties is set
810810
(schema.getAdditionalProperties() == null ||
811-
(schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()));
811+
// additionalProperties is boolean and set to false
812+
(schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()) ||
813+
// additionalProperties is a schema with its boolean value set to false
814+
(schema.getAdditionalProperties() instanceof JsonSchema &&
815+
((JsonSchema) schema.getAdditionalProperties()).getBooleanSchemaValue() != null &&
816+
!((JsonSchema) schema.getAdditionalProperties()).getBooleanSchemaValue())
817+
);
812818
}
813819

814820
public static boolean hasValidation(Schema sc) {
@@ -2415,7 +2421,7 @@ public static void copyMetadata(Schema from, Schema to) {
24152421
* For example, a schema that only has a `description` without any `properties` or `$ref` defined.
24162422
*
24172423
* @param schema the schema
2418-
* @return if the schema is only metadata and not an actual type
2424+
* @return if the schema is only metadata and not an actual type
24192425
*/
24202426
public static boolean isMetadataOnlySchema(Schema schema) {
24212427
return !(schema.get$ref() != null ||

0 commit comments

Comments
 (0)