use of io.swagger.v3.oas.models.info.Info in project swagger-parser by swagger-api.
the class OpenAPIDeserializerTest method testLicense.
@Test
public void testLicense() {
String yaml = "openapi: 3.0.0\n" + "servers: []\n" + "info:\n" + " license:\n" + " invalid: true\n" + " x-valid:\n" + " isValid: true\n" + " version: ''\n";
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 info.license.invalid is unexpected"));
assertTrue(messages.contains("attribute info.title is missing"));
assertTrue(messages.contains("attribute paths is missing"));
assertEquals(((Map) result.getOpenAPI().getInfo().getLicense().getExtensions().get("x-valid")).get("isValid"), true);
}
use of io.swagger.v3.oas.models.info.Info in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue450.
@Test
public void testIssue450() {
String desc = "An array of Pets";
String xTag = "x-my-tag";
String xVal = "An extension tag";
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" + "components:\n" + " schemas:\n" + " PetArray:\n" + " type: array\n" + " items:\n" + " $ref: '#/components/schemas/Pet'\n" + " description: An array of Pets\n" + " x-my-tag: An extension tag\n" + " Pet:\n" + " type: object\n" + " properties:\n" + " id:\n" + " type: string";
SwaggerParseResult result = new OpenAPIV3Parser().readContents(yaml, null, null);
assertNotNull(result.getOpenAPI());
final OpenAPI openAPI = result.getOpenAPI();
Schema petArray = openAPI.getComponents().getSchemas().get("PetArray");
assertNotNull(petArray);
assertTrue(petArray instanceof ArraySchema);
assertEquals(petArray.getDescription(), desc);
assertNotNull(petArray.getExtensions());
assertNotNull(petArray.getExtensions().get(xTag));
assertEquals(petArray.getExtensions().get(xTag), xVal);
}
use of io.swagger.v3.oas.models.info.Info in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testModelParameters.
@Test
public void testModelParameters() throws Exception {
String yaml = "openapi: '2.0'\n" + "info:\n" + " version: \"0.0.0\"\n" + " title: test\n" + "paths:\n" + " /foo:\n" + " get:\n" + " parameters:\n" + " - name: amount\n" + " in: body\n" + " schema:\n" + " type: integer\n" + " format: int64\n" + " description: amount of money\n" + " default: 1000\n" + " maximum: 100000\n" + " responses:\n" + " 200:\n" + " description: ok";
OpenAPIV3Parser parser = new OpenAPIV3Parser();
OpenAPI openAPI = (parser.readContents(yaml, null, null)).getOpenAPI();
}
use of io.swagger.v3.oas.models.info.Info in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testCodegenIssue4555.
@Test
public void testCodegenIssue4555() throws Exception {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
String yaml = "openapi: 3.0.0\n" + "info:\n" + " title: test\n" + " version: \"0.0.1\"\n" + "\n" + "paths:\n" + " '/contents/{id}':\n" + " parameters:\n" + " - name: id\n" + " in: path\n" + " description: test\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " get:\n" + " description: test\n" + " responses:\n" + " '200':\n" + " description: OK\n" + " schema: null\n" + " $ref: '#/components/schemas/Content'\n" + "components:\n" + " schemas:\n" + " Content:\n" + " type: object\n" + " title: \t\ttest";
final SwaggerParseResult result = parser.readContents(yaml, null, null);
// can't parse with tabs!
assertNull(result.getOpenAPI());
}
use of io.swagger.v3.oas.models.info.Info 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());
}
Aggregations