use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testResolveEmpty.
@Test
public void testResolveEmpty(@Injectable final List<AuthorizationValue> auths) throws Exception {
String pathFile = FileUtils.readFileToString(new File("src/test/resources/empty-oas.yaml"));
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
SwaggerParseResult result = new OpenAPIV3Parser().readContents(pathFile, auths, options);
Assert.assertNotNull(result);
Assert.assertNotNull(result.getOpenAPI());
}
use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class RelativeReferenceTest method testIssueServerUrlValidation.
@Test
public void testIssueServerUrlValidation() throws Exception {
new Expectations() {
{
RemoteUrl.urlToString("http://foo.bar.com/swagger.json", Arrays.asList(new AuthorizationValue[] {}));
times = 1;
result = spec;
}
};
SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser().readLocation("http://foo.bar.com/swagger.json", null, new ParseOptions());
assertNotNull(swaggerParseResult.getOpenAPI());
assertTrue(swaggerParseResult.getMessages().isEmpty());
}
use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testInlineModelResolver.
@Test
public void testInlineModelResolver(@Injectable final List<AuthorizationValue> auths) throws Exception {
String pathFile = FileUtils.readFileToString(new File("src/test/resources/flatten.json"));
pathFile = pathFile.replace("${dynamicPort}", String.valueOf(this.serverPort));
ParseOptions options = new ParseOptions();
options.setFlatten(true);
SwaggerParseResult result = new OpenAPIV3Parser().readContents(pathFile, auths, options);
Assert.assertNotNull(result);
OpenAPI openAPI = result.getOpenAPI();
Assert.assertNotNull(openAPI);
Schema user = openAPI.getComponents().getSchemas().get("User");
assertNotNull(user);
Schema address = (Schema) user.getProperties().get("address");
assertTrue((address.get$ref() != null));
Schema userAddress = openAPI.getComponents().getSchemas().get("User_address");
assertNotNull(userAddress);
assertNotNull(userAddress.getProperties().get("city"));
assertNotNull(userAddress.getProperties().get("street"));
}
use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testRemotePathItemIssue1103.
@Test
public void testRemotePathItemIssue1103(@Injectable final List<AuthorizationValue> auths) throws Exception {
OpenAPI result = new OpenAPIV3Parser().read("issue-1103/remote-pathItem-swagger.yaml");
Assert.assertNotNull(result);
Assert.assertNotNull(result.getPaths().get("/Translation/{lang}"));
Assert.assertEquals(result.getPaths().get("/Translation/{lang}").getPut().getParameters().get(0).getName(), "lang");
}
use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testComposedSchemaAdjacent.
@Test
public void testComposedSchemaAdjacent(@Injectable final List<AuthorizationValue> auths) throws Exception {
ParseOptions options = new ParseOptions();
options.setResolve(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("src/test/resources/composedSchemaRef.yaml", auths, options);
Assert.assertNotNull(openAPI);
Assert.assertTrue(openAPI.getComponents().getSchemas().size() == 5);
Schema schema = openAPI.getPaths().get("/path").getGet().getResponses().get("200").getContent().get("application/json").getSchema();
Assert.assertTrue(schema instanceof ComposedSchema);
ComposedSchema composedSchema = (ComposedSchema) schema;
Assert.assertTrue(composedSchema.getOneOf().size() == 2);
Assert.assertTrue(composedSchema.getAllOf().size() == 1);
}
Aggregations