use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class InlineModelResolverTest method testIssue1018.
@Test
public void testIssue1018() throws Exception {
ParseOptions options = new ParseOptions();
options.setFlatten(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("flatten.json", null, options);
assertNotNull(openAPI);
assertNotNull(openAPI.getComponents().getSchemas().get("ReturnInformation_manufacturer_signin_credentials").getRequired());
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class InlineModelResolverTest method testInlineItemsSchema.
@Test(description = "https://github.com/swagger-api/swagger-parser/issues/1527")
public void testInlineItemsSchema() throws Exception {
ParseOptions options = new ParseOptions();
options.setFlatten(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("flatten.json", null, options);
assertNotNull(openAPI);
assertNotNull(openAPI.getComponents().getSchemas().get("inline_response_200"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testValidateExternalRefsTrue.
@Test(description = "option true, adds Original Location to messages when ref is relative/local")
public void testValidateExternalRefsTrue() {
ParseOptions options = new ParseOptions();
options.setValidateExternalRefs(true);
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("./swos-443/root.yaml", null, options);
OpenAPI openAPI = result.getOpenAPI();
assertNotNull(openAPI);
assertNotNull(result.getMessages());
assertEquals(result.getMessages().size(), 19);
assertTrue(result.getMessages().contains("attribute components.requestBodies.NewItem.asdasd is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.requestBodies.NewItem.descasdasdription is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.responses.GeneralError.descrsaiption is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.responses.GeneralError.asdas is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.responses.GeneralError.description is missing (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.schemas.Examples.nonExpected is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.parameters.skipParam.[skip].in is not of type `[query|header|path|cookie]` (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.securitySchemes.api_key.namex is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.securitySchemes.api_key.name is missing (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.callbacks.webhookVerificationEvent.postx is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.headers.X-Rate-Limit-Limit.descriptasdd is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.links.unsubscribe.parametersx is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.examples.response-example.summaryx is unexpected (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.examples.response-example. value and externalValue are both present (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.callbacks.failed.wrongField is not of type `object` (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute paths.~1refPet(get).responses is missing (./ref.yaml)"));
// error message in main file
assertTrue(result.getMessages().contains("attribute components.schemas.InvalidSchema.invalid is unexpected"));
assertTrue(result.getMessages().contains("attribute components.schemas.ErrorModel.properties is not of type `object` (./ref.yaml)"));
assertTrue(result.getMessages().contains("attribute components.schemas.Examples.properties is not of type `object` (./ref.yaml)"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1367.
@Test
public void testIssue1367() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveCombinators(true);
options.setResolveFully(true);
options.setFlatten(true);
SwaggerParseResult parseResult = openApiParser.readLocation("issue-1367.yaml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();
assertTrue(((Schema) openAPI.getComponents().getSchemas().get("TestDTO").getProperties().get("choice")).getEnum() != null);
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1518.
@Test
public void testIssue1518() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("issue-1518/api.json", null, options);
OpenAPI openAPI = result.getOpenAPI();
assertTrue(((Schema) openAPI.getComponents().getSchemas().get("Analemmata").getProperties().get("tashotSipe")).get$ref().equals("#/components/schemas/TashotSipe"));
assertTrue(openAPI.getComponents().getSchemas().get("analemmata") == null);
}
Aggregations