Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,9 @@ private void aggregateSchemaCombinators(ComposedSchema sourceSchema, Schema targ
if (resolved.getMinContains() != null) {
targetSchema.setMinContains(resolved.getMinContains());
}
if (resolved.getAdditionalProperties() != null) {
targetSchema.setAdditionalProperties(resolved.getAdditionalProperties());
}
}

if (requiredProperties.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.AssertJUnit.assertNull;
Expand Down Expand Up @@ -772,5 +773,56 @@ public void testIssue1552AdditionalProps() throws Exception {
"openapi31: false\n");
}


@Test
public void testAdditionalPropertiesWithAllOfV1() {
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
SwaggerParseResult result = new OpenAPIParser().readLocation(
"additionalProperties_allOf_v1.yaml", null, options);
assertNotNull(result.getOpenAPI());
Schema schema = result.getOpenAPI().getComponents().getSchemas().get("TestSchema");
assertNotNull(schema);
assertNotNull(schema.getAdditionalProperties());
assertTrue((Boolean) schema.getAdditionalProperties());
}
@Test
public void testAdditionalPropertiesWithAllOfV2() {
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
SwaggerParseResult result = new OpenAPIParser().readLocation(
"additionalProperties_allOf_v2.yaml", null, options);
assertNotNull(result.getOpenAPI());
Schema schema = result.getOpenAPI().getComponents().getSchemas().get("TestSchema");
assertNotNull(schema);
assertNotNull(schema.getAdditionalProperties());
assertTrue((Boolean) schema.getAdditionalProperties());
}

@Test
public void testAdditionalPropertiesWithAllOfV3() {
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
SwaggerParseResult result = new OpenAPIParser().readLocation(
"additionalProperties_allOf_v3.yaml", null, options);
assertNotNull(result.getOpenAPI());
Schema schema = result.getOpenAPI().getComponents().getSchemas().get("TestSchema");
assertNotNull(schema);
assertNotNull(schema.getAdditionalProperties());
assertTrue((Boolean) schema.getAdditionalProperties());
}

@Test
public void testAdditionalPropertiesWithAllOfV4() {
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
SwaggerParseResult result = new OpenAPIParser().readLocation(
"additionalProperties_allOf_v4.yaml", null, options);
assertNotNull(result.getOpenAPI());
Schema schema = result.getOpenAPI().getComponents().getSchemas().get("TestSchema");
assertNotNull(schema);
assertNotNull(schema.getAdditionalProperties());
assertFalse((Boolean) schema.getAdditionalProperties());
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
openapi: 3.0.1
info:
title: Test API
version: 1.0.0
paths:
/test:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestSchema'
components:
schemas:
ObjectWithAdditionalProperties:
type: object
additionalProperties: true
properties:
name:
type: string
TestSchema:
allOf:
- $ref: '#/components/schemas/ObjectWithAdditionalProperties'
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
openapi: 3.0.1
info:
title: Test API
version: 1.0.0
paths:
/test:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestSchema'
components:
schemas:
ObjectWithAdditionalProperties:
type: object
additionalProperties: true
TestSchema:
allOf:
- $ref: '#/components/schemas/ObjectWithAdditionalProperties'
- type: object
properties:
name:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
openapi: 3.0.1
info:
title: Test API
version: 1.0.0
paths:
/test:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestSchema'
components:
schemas:
ObjectWithAdditionalProperties:
type: object
additionalProperties: true
TestSchema:
allOf:
- type: object
properties:
name:
type: string
additionalProperties: false
- $ref: '#/components/schemas/ObjectWithAdditionalProperties'
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
openapi: 3.0.1
info:
title: Test API
version: 1.0.0
paths:
/test:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestSchema'
components:
schemas:
ObjectWithAdditionalProperties:
type: object
additionalProperties: true
TestSchema:
allOf:
- $ref: '#/components/schemas/ObjectWithAdditionalProperties'
- type: object
properties:
name:
type: string
additionalProperties: false