use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1071.
@Test
public void testIssue1071() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult parseResult = new OpenAPIV3Parser().readLocation("issue-1071.yaml", null, options);
OpenAPI apispec = parseResult.getOpenAPI();
assertNotNull(apispec);
Schema test = apispec.getPaths().get("/mapschema").getGet().getResponses().get("200").getContent().get("application/json").getSchema();
assertTrue(test instanceof MapSchema);
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method shouldParseExternalSchemaModelHavingReferenceToItsLocalModel.
@Test
public void shouldParseExternalSchemaModelHavingReferenceToItsLocalModel() {
// given
String location = "src/test/resources/issue-1040/api.yaml";
OpenAPIV3Parser tested = new OpenAPIV3Parser();
// when
OpenAPI result = tested.read(location);
// then
Components components = result.getComponents();
Schema modelSchema = components.getSchemas().get("Value");
assertThat(modelSchema, notNullValue());
assertThat(modelSchema.getProperties().get("id"), instanceOf(Schema.class));
assertThat(((Schema) modelSchema.getProperties().get("id")).get$ref(), equalTo("#/components/schemas/ValueId"));
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testValidationIssue.
@Test
public void testValidationIssue() {
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolveFully(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("src/test/resources/validation/path-parameter-validation.yaml", null, parseOptions);
assertThat(result.getMessages().size(), CoreMatchers.is(0));
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue931.
@Test
public void testIssue931() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("Issue_931.json", null, options);
assertNotNull(result.getOpenAPI());
assertTrue(result.getMessages().size() > 0);
assertEquals(result.getMessages().get(0).contains("doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"), true);
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testAnonymousModelAllOf.
@Test
public void testAnonymousModelAllOf() {
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("issue203/issue203AllOf.yaml", null, options);
OpenAPI openAPI = result.getOpenAPI();
assertEquals(openAPI.getComponents().getSchemas().get("Supplier").getXml().getName(), "supplierObject");
}
Aggregations