Skip to content

Commit b61e410

Browse files
committed
[3.1] Fixed isMapSchema
1 parent b3cf336 commit b61e410

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,9 @@ public static boolean isMapSchema(Schema schema) {
559559
}
560560

561561
// additionalProperties explicitly set to false
562-
if (schema.getAdditionalProperties() instanceof Boolean && Boolean.FALSE.equals(schema.getAdditionalProperties())) {
562+
if ((schema.getAdditionalProperties() instanceof Boolean && Boolean.FALSE.equals(schema.getAdditionalProperties())) ||
563+
(schema.getAdditionalProperties() instanceof Schema && Boolean.FALSE.equals(((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue()))
564+
) {
563565
return false;
564566
}
565567

modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ public void test30Schemas() {
353353
Assert.assertNull(anyof1Property.getType());
354354
Assert.assertTrue(ModelUtils.hasAnyOf(anyof1Property));
355355
Assert.assertTrue(ModelUtils.isAnyOf(anyof1Property));
356+
357+
Schema objectSchema = ModelUtils.getSchema(openAPI, "ObjectSchema");
358+
Assert.assertFalse(ModelUtils.isMapSchema(objectSchema));
356359
}
357360

358361
// 3.1 spec tests
@@ -392,7 +395,7 @@ public void test31Schemas() {
392395
Assert.assertTrue(ModelUtils.isAnyOf(anyof2));
393396

394397
Schema objectSchema = ModelUtils.getSchema(openAPI, "ObjectSchema");
395-
Assert.assertTrue(ModelUtils.isMapSchema(objectSchema));
398+
Assert.assertFalse(ModelUtils.isMapSchema(objectSchema));
396399

397400
Schema complexComposedSchema = ModelUtils.getSchema(openAPI, "ComplexComposedSchema");
398401
Assert.assertTrue(ModelUtils.isComplexComposedSchema(complexComposedSchema));

modules/openapi-generator/src/test/resources/3_0/schema.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ components:
6565
oneOf:
6666
- type: string
6767
- type: integer
68+
ObjectSchema:
69+
type: object
70+
additionalProperties: false
71+
properties:
72+
name:
73+
type: string
74+
address:
75+
type: string
6876
anyof1:
6977
anyOf:
7078
- type: string

0 commit comments

Comments
 (0)