Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs - issue #1190 - fix ArraySchema with additionalProperties #1208

Merged
merged 1 commit into from
Oct 4, 2019
Merged
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 @@ -2100,10 +2100,12 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){
: additionalPropertiesBoolean;

if(additionalProperties != null) {
schema =
additionalProperties.equals( Boolean.FALSE)
? new ObjectSchema()
: new MapSchema();
if (schema == null) {
schema =
additionalProperties.equals(Boolean.FALSE)
? new ObjectSchema()
: new MapSchema();
}
schema.setAdditionalProperties( additionalProperties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ public class OpenAPIV3ParserTest {
protected int serverPort = getDynamicPort();
protected WireMockServer wireMockServer;

@Test
public void testIssue1190() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);
SwaggerParseResult parseResult = openApiParser.readLocation("issue1190/issue1190.yaml", null, options);

OpenAPI openAPI = parseResult.getOpenAPI();
assertNotNull(openAPI.getComponents().getSchemas().get("SomeObj_lorem"));
}



@Test
public void testIssue1147() {
ParseOptions options = new ParseOptions();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
openapi: 3.0.0
info:
version: 1.0.0
title: Issue 1190
license:
name: Apache-2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/example:
get:
operationId: example
responses:
'200':
description: successful operation
content:
'application/json':
schema:
$ref: "#/components/schemas/SomeObj"
components:
schemas:
SomeObj:
type: object
properties:
lorem:
type: array
minItems: 1
additionalProperties: false
items:
type: object
properties:
firstName:
type: string
lastName:
type: string