use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testSecuritySchemeWithRef.
@Test(description = "SecurityScheme with REf")
public void testSecuritySchemeWithRef() {
Components components = new Components();
components.addSecuritySchemes("Security", new SecurityScheme().description("Security Example").name("Security").type(SecurityScheme.Type.OAUTH2).$ref("myOauth2Security").in(SecurityScheme.In.HEADER));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(RefSecurityResource.class);
String yaml = "openapi: 3.0.1\n" + "info:\n" + " description: info\n" + "paths:\n" + " /:\n" + " get:\n" + " description: description\n" + " operationId: Operation Id\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " security:\n" + " - security_key:\n" + " - write:pets\n" + " - read:pets\n" + "components:\n" + " securitySchemes:\n" + " Security:\n" + " type: oauth2\n" + " description: Security Example\n" + " myOauth2Security:\n" + " type: oauth2\n" + " description: myOauthSecurity Description\n" + " $ref: '#/components/securitySchemes/Security'\n" + " in: header\n" + " flows:\n" + " implicit:\n" + " authorizationUrl: http://x.com\n" + " scopes:\n" + " write:pets: modify pets in your account\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method test2644.
@Test(description = "test ticket #2644 annotated interface")
public void test2644() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket2644ConcreteImplementation.class);
Paths paths = openAPI.getPaths();
assertEquals(paths.size(), 1);
PathItem pathItem = paths.get("/resources");
assertNotNull(pathItem);
Operation operation = pathItem.getGet();
assertNotNull(operation);
assertTrue(operation.getResponses().getDefault().getContent().keySet().contains("*/*"));
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testResponseWithFilter.
@Test(description = "Responses with filter")
public void testResponseWithFilter() {
Components components = new Components();
components.addResponses("invalidJWT", new ApiResponse().description("when JWT token invalid/expired"));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(SimpleResponsesResource.class);
OpenAPISpecFilter filterImpl = new RefResponseFilter();
SpecFilter f = new SpecFilter();
openAPI = f.filter(openAPI, filterImpl, null, null, null);
String yaml = "openapi: 3.0.1\n" + "info:\n" + " description: info\n" + "paths:\n" + " /:\n" + " get:\n" + " summary: Simple get operation\n" + " description: Defines a simple get operation with no inputs and a complex output\n" + " object\n" + " operationId: getWithPayloadResponse\n" + " responses:\n" + " \"200\":\n" + " description: voila!\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/SampleResponseSchema'\n" + " default:\n" + " description: boo\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/GenericError'\n" + " \"401\":\n" + " $ref: '#/components/responses/invalidJWT'\n" + " deprecated: true\n" + "components:\n" + " schemas:\n" + " GenericError:\n" + " type: object\n" + " SampleResponseSchema:\n" + " type: object\n" + " responses:\n" + " invalidJWT:\n" + " description: when JWT token invalid/expired";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testTicket2340.
@Test(description = "Responses with array schema")
public void testTicket2340() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket2340Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /test/test:\n" + " post:\n" + " operationId: getAnimal\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/Animal'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: string\n" + "components:\n" + " schemas:\n" + " Animal:\n" + " required:\n" + " - type\n" + " type: object\n" + " properties:\n" + " type:\n" + " type: string\n" + " discriminator:\n" + " propertyName: type\n" + " Cat:\n" + " type: object\n" + " allOf:\n" + " - $ref: '#/components/schemas/Animal'\n" + " - type: object\n" + " properties:\n" + " lives:\n" + " type: integer\n" + " format: int32\n" + " Dog:\n" + " type: object\n" + " allOf:\n" + " - $ref: '#/components/schemas/Animal'\n" + " - type: object\n" + " properties:\n" + " barkVolume:\n" + " type: number\n" + " format: double\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testTicket3587.
@Test(description = "Parameter examples ordering")
public void testTicket3587() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket3587Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /test/test:\n" + " get:\n" + " operationId: parameterExamplesOrderingTest\n" + " parameters:\n" + " - in: query\n" + " schema:\n" + " type: string\n" + " examples:\n" + " Example One:\n" + " description: Example One\n" + " Example Two:\n" + " description: Example Two\n" + " Example Three:\n" + " description: Example Three\n" + " - in: query\n" + " schema:\n" + " type: string\n" + " examples:\n" + " Example Three:\n" + " description: Example Three\n" + " Example Two:\n" + " description: Example Two\n" + " Example One:\n" + " description: Example One\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}";
SerializationMatchers.assertEqualsToYamlExact(openAPI, yaml);
}
Aggregations