use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1335.
@Test
public void testIssue1335() {
final ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("src/test/resources/issue1335.yaml", null, options);
assertNotNull(result.getOpenAPI().getComponents().getExamples().get("ex1"));
}
use of io.swagger.v3.parser.OpenAPIV3Parser 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());
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testDuplicateHttpStatusCodesYaml.
@Test
public void testDuplicateHttpStatusCodesYaml() {
final String location = "src/test/resources/duplicateHttpStatusCodes.yaml";
final ParseOptions options = new ParseOptions();
options.setResolve(true);
final OpenAPIV3Parser parser = new OpenAPIV3Parser();
final SwaggerParseResult result = parser.readLocation(location, null, options);
List<String> messages = result.getMessages();
assertEquals(1, messages.size());
assertEquals(messages.get(0), "Duplicate field 200 in `src/test/resources/duplicateHttpStatusCodes.yaml`");
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method test30.
@Test
public void test30(@Injectable final List<AuthorizationValue> auths) throws Exception {
String pathFile = FileUtils.readFileToString(new File("src/test/resources/oas3.yaml.template"));
pathFile = pathFile.replace("${dynamicPort}", String.valueOf(this.serverPort));
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readContents(pathFile, auths, options);
Assert.assertNotNull(result);
Assert.assertNotNull(result.getOpenAPI());
assertEquals(result.getOpenAPI().getOpenapi(), "3.0.1");
assertEquals(result.getOpenAPI().getComponents().getSchemas().get("OrderRef").getType(), "object");
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIDeserializerTest method testResponses.
@Test
public void testResponses() {
String yaml = "openapi: 3.0.0\n" + "servers: []\n" + "info:\n" + " version: ''\n" + " title: ''\n" + "paths: {}\n" + "components:\n" + " responses:\n" + " foo:\n" + " description: description\n" + " bar: baz\n" + " x-foo: bar";
OpenAPIV3Parser parser = new OpenAPIV3Parser();
SwaggerParseResult result = parser.readContents(yaml, null, null);
List<String> messageList = result.getMessages();
Set<String> messages = new HashSet<>(messageList);
assertTrue(messages.contains("attribute components.responses.foo.bar is unexpected"));
assertEquals(result.getOpenAPI().getComponents().getResponses().get("foo").getExtensions().get("x-foo").toString(), "bar");
}
Aggregations