Search in sources :

Example 41 with AuthorizationValue

use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testRefAndInlineAllOf.

@Test
public void testRefAndInlineAllOf(@Injectable final List<AuthorizationValue> auths) throws Exception {
    ParseOptions options = new ParseOptions();
    options.setResolve(true);
    options.setResolveFully(true);
    OpenAPI openAPI = new OpenAPIV3Parser().read("src/test/resources/allOfAndRef.yaml", auths, options);
    Assert.assertNotNull(openAPI);
    Assert.assertTrue(openAPI.getComponents().getSchemas().size() == 2);
    Assert.assertNotNull(openAPI.getComponents().getSchemas().get("UserEx"));
    Assert.assertNotNull(openAPI.getComponents().getSchemas().get("User"));
    Assert.assertTrue(openAPI.getPaths().get("/refToAllOf").getGet().getResponses().get("200").getContent().get("application/json").getSchema().getProperties().size() == 2);
}
Also used : ParseOptions(io.swagger.v3.parser.core.models.ParseOptions) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.testng.annotations.Test)

Example 42 with AuthorizationValue

use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testRemoteParameterIssue1094.

@Test
public void testRemoteParameterIssue1094(@Injectable final List<AuthorizationValue> auths) throws Exception {
    OpenAPI result = new OpenAPIV3Parser().read("issue-1094/swagger.yaml");
    Assert.assertNotNull(result);
    Assert.assertNotNull(result.getComponents().getSchemas().get("PlmnId"));
}
Also used : OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.testng.annotations.Test)

Example 43 with AuthorizationValue

use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testRemoteParameterIssue1103.

@Test
public void testRemoteParameterIssue1103(@Injectable final List<AuthorizationValue> auths) throws Exception {
    OpenAPI result = new OpenAPIV3Parser().read("issue-1103/remote-parameter-swagger.yaml");
    Assert.assertNotNull(result);
    Assert.assertEquals(result.getPaths().get("/Translation/{lang}").getPut().getParameters().get(0).getName(), "lang");
}
Also used : OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.testng.annotations.Test)

Example 44 with AuthorizationValue

use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.

the class RelativeReferenceTest method testIssue213.

@Test
public void testIssue213() throws Exception {
    new Expectations() {

        {
            RemoteUrl.urlToString("http://foo.bar.com/swagger.json", Arrays.asList(new AuthorizationValue[] {}));
            times = 1;
            result = spec;
            RemoteUrl.urlToString("http://foo.bar.com/path/samplePath.yaml", Arrays.asList(new AuthorizationValue[] {}));
            times = 1;
            result = samplePath;
        }
    };
    OpenAPI swagger = new OpenAPIV3Parser().read("http://foo.bar.com/swagger.json");
    assertNotNull(swagger);
    assertNotNull(swagger.getPaths().get("/samplePath"));
    assertNotNull(swagger.getPaths().get("/samplePath").getGet());
    assertNotNull(swagger.getPaths().get("/samplePath").getGet().getRequestBody());
    RequestBody body = swagger.getPaths().get("/samplePath").getGet().getRequestBody();
    assertNotNull(body.getContent().get("application/json").getSchema());
}
Also used : Expectations(mockit.Expectations) AuthorizationValue(io.swagger.v3.parser.core.models.AuthorizationValue) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) OpenAPI(io.swagger.v3.oas.models.OpenAPI) RequestBody(io.swagger.v3.oas.models.parameters.RequestBody) Test(org.testng.annotations.Test)

Example 45 with AuthorizationValue

use of io.swagger.v3.parser.core.models.AuthorizationValue in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testComposedRefResolvingIssue628.

@Test
public void testComposedRefResolvingIssue628(@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);
    Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Cat"));
    Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Dog"));
    Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Pet"));
    Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Lion"));
    Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Bear"));
}
Also used : ParseOptions(io.swagger.v3.parser.core.models.ParseOptions) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)44 OpenAPIV3Parser (io.swagger.v3.parser.OpenAPIV3Parser)40 ParseOptions (io.swagger.v3.parser.core.models.ParseOptions)34 OpenAPI (io.swagger.v3.oas.models.OpenAPI)31 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)21 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)18 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)18 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)17 Schema (io.swagger.v3.oas.models.media.Schema)17 StringSchema (io.swagger.v3.oas.models.media.StringSchema)17 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)16 AuthorizationValue (io.swagger.v3.parser.core.models.AuthorizationValue)13 ByteArraySchema (io.swagger.v3.oas.models.media.ByteArraySchema)8 MapSchema (io.swagger.v3.oas.models.media.MapSchema)8 HashSet (java.util.HashSet)7 BinarySchema (io.swagger.v3.oas.models.media.BinarySchema)5 DateSchema (io.swagger.v3.oas.models.media.DateSchema)5 DateTimeSchema (io.swagger.v3.oas.models.media.DateTimeSchema)5 ArrayList (java.util.ArrayList)5 Expectations (mockit.Expectations)5