Search in sources :

Example 61 with Yaml

use of io.swagger.v3.core.util.Yaml in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testIssue243.

@Test
public void testIssue243() {
    String yaml = "openapi: 3.0.0\n" + "servers: []\n" + "info:\n" + "  version: 0.0.0\n" + "  title: Simple API\n" + "paths:\n" + "  /:\n" + "    get:\n" + "      responses:\n" + "        '200':\n" + "          description: OK\n" + "          content:\n" + "            '*/*':\n" + "              schema:\n" + "                $ref: '#/components/schemas/Simple'\n" + "components:\n" + "  schemas:\n" + "    Simple:\n" + "      type: string";
    SwaggerParseResult result = new OpenAPIV3Parser().readContents(yaml, null, null);
    assertNotNull(result.getOpenAPI());
}
Also used : SwaggerParseResult(io.swagger.v3.parser.core.models.SwaggerParseResult) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) Test(org.testng.annotations.Test)

Example 62 with Yaml

use of io.swagger.v3.core.util.Yaml in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testResolveFullyMap.

@Test
public void testResolveFullyMap() {
    ParseOptions options = new ParseOptions();
    options.setResolveFully(false);
    OpenAPI openAPI = new OpenAPIV3Parser().readLocation("resolve-fully-map.yaml", null, options).getOpenAPI();
    String yaml = Yaml.pretty(openAPI);
    assertTrue(yaml.contains("$ref"));
    options = new ParseOptions();
    options.setResolveFully(true);
    openAPI = new OpenAPIV3Parser().readLocation("resolve-fully-map.yaml", null, options).getOpenAPI();
    yaml = Yaml.pretty(openAPI);
    assertFalse(yaml.contains("$ref"));
}
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 63 with Yaml

use of io.swagger.v3.core.util.Yaml in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testIssue1309.

@Test
public void testIssue1309() {
    OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
    ParseOptions options = new ParseOptions();
    options.setResolve(true);
    SwaggerParseResult parseResult = openApiParser.readLocation("issue-1309.yaml", null, options);
    OpenAPI openAPI = parseResult.getOpenAPI();
    assertNotNull(openAPI);
    assertEquals(parseResult.getMessages().get(0), "attribute components.schemas.customer-not-found.examples is unexpected");
}
Also used : ParseOptions(io.swagger.v3.parser.core.models.ParseOptions) SwaggerParseResult(io.swagger.v3.parser.core.models.SwaggerParseResult) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.testng.annotations.Test)

Example 64 with Yaml

use of io.swagger.v3.core.util.Yaml in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testIssue1398.

@Test
public void testIssue1398() {
    ParseOptions options = new ParseOptions();
    SwaggerParseResult result = new OpenAPIV3Parser().readLocation("issue1398.yaml", null, options);
    assertEquals(result.getMessages().get(0), "attribute paths.'/pet/{petId}'(get).parameters.[petId].schemas.multipleOf value must be > 0");
}
Also used : ParseOptions(io.swagger.v3.parser.core.models.ParseOptions) SwaggerParseResult(io.swagger.v3.parser.core.models.SwaggerParseResult) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) Test(org.testng.annotations.Test)

Example 65 with Yaml

use of io.swagger.v3.core.util.Yaml in project swagger-parser by swagger-api.

the class OpenAPIV3ParserTest method testRegressionIssue1236.

@Test
public void testRegressionIssue1236() {
    final ParseOptions options = new ParseOptions();
    options.setResolve(true);
    SwaggerParseResult result = new OpenAPIV3Parser().readLocation("src/test/resources/testRegressionIssue1236.yaml", null, options);
    assertTrue(result.getMessages().size() == 0);
}
Also used : ParseOptions(io.swagger.v3.parser.core.models.ParseOptions) SwaggerParseResult(io.swagger.v3.parser.core.models.SwaggerParseResult) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)188 OpenAPI (io.swagger.v3.oas.models.OpenAPI)151 OpenAPIV3Parser (io.swagger.v3.parser.OpenAPIV3Parser)121 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)94 ParseOptions (io.swagger.v3.parser.core.models.ParseOptions)62 Schema (io.swagger.v3.oas.models.media.Schema)58 StringSchema (io.swagger.v3.oas.models.media.StringSchema)49 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)47 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)43 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)42 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)38 ByteArraySchema (io.swagger.v3.oas.models.media.ByteArraySchema)35 MapSchema (io.swagger.v3.oas.models.media.MapSchema)33 BinarySchema (io.swagger.v3.oas.models.media.BinarySchema)25 DateSchema (io.swagger.v3.oas.models.media.DateSchema)25 DateTimeSchema (io.swagger.v3.oas.models.media.DateTimeSchema)25 Parameter (io.swagger.v3.oas.models.parameters.Parameter)18 QueryParameter (io.swagger.v3.oas.models.parameters.QueryParameter)18 Components (io.swagger.v3.oas.models.Components)15 Info (io.swagger.v3.oas.models.info.Info)14