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

Add unit test for 'any type' conversion #1379

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 @@ -12,6 +12,7 @@
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.IntegerSchema;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.media.ObjectSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
Expand Down Expand Up @@ -96,6 +97,7 @@ public class V2ConverterTest {
private static final String ISSUE_1113_YAML = "issue-1113.yaml";
private static final String ISSUE_1164_YAML = "issue-1164.yaml";
private static final String ISSUE_1261_YAML = "issue-1261.yaml";
private static final String ISSUE_1378_YAML = "issue-1378.yaml";

private static final String API_BATCH_PATH = "/api/batch/";
private static final String PETS_PATH = "/pets";
Expand Down Expand Up @@ -852,6 +854,20 @@ public void testissue1261() throws Exception {

}

@Test(description = "OpenAPI v2 converter - Schema without the 'type' keyword")
public void testissue1378() throws Exception {
OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_1378_YAML);
assertNotNull(oas);
Schema schema = (Schema) oas.getComponents().getSchemas().get("Foo");
assertNotNull(schema);
assertNotNull(schema.getProperties());
assertNotNull(schema.getProperties().get("p1"));
assertNotNull(schema.getProperties().get("p2"));
assertTrue(schema.getProperties().get("p1") instanceof ObjectSchema);
assertTrue(schema.getProperties().get("p2").getClass().equals(Schema.class));
assertNull(((Schema)schema.getProperties().get("p2")).getType());
}

@Test()
public void testInlineDefinitionProperty() throws Exception {
SwaggerConverter converter = new SwaggerConverter();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
swagger: '2.0'
info:
title: AnyType test
version: '1.0.0'
paths: {}
definitions:
Foo:
type: object
properties:
p1:
type: object
p2:
description: test