use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testResolveDuplicatedOperationId.
@Test(description = "Get a Duplicated Operation Id")
public void testResolveDuplicatedOperationId() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(DuplicatedOperationIdResource.class);
Paths paths = openAPI.getPaths();
assertNotNull(paths);
Operation firstOperation = paths.get(PATH_REF).getGet();
Operation secondOperation = paths.get(PATH_2_REF).getGet();
Operation thirdOperation = paths.get(PATH_REF).getPost();
assertNotNull(firstOperation);
assertNotNull(secondOperation);
assertNotNull(thirdOperation);
assertNotEquals(firstOperation.getOperationId(), secondOperation.getOperationId());
assertNotEquals(firstOperation.getOperationId(), thirdOperation.getOperationId());
assertNotEquals(secondOperation.getOperationId(), thirdOperation.getOperationId());
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testTicket2848.
@Test(description = "array schema required property")
public void testTicket2848() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket2848Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /:\n" + " get:\n" + " operationId: getter\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/Town'\n" + "components:\n" + " schemas:\n" + " Town:\n" + " required:\n" + " - streets\n" + " type: object\n" + " properties:\n" + " streets:\n" + " minItems: 1\n" + " uniqueItems: true\n" + " type: array\n" + " items:\n" + " type: string\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testParameterWithRef.
@Test(description = "Parameter with ref")
public void testParameterWithRef() {
Components components = new Components();
components.addParameters("id", new Parameter().description("Id Description").schema(new IntegerSchema()).in(ParameterIn.QUERY.toString()).example(1).required(true));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(RefParameterResource.class);
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 a payload complex input object\n" + " operationId: sendPayload\n" + " parameters:\n" + " - $ref: '#/components/parameters/id'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " deprecated: true\n" + "components:\n" + " parameters: \n" + " id:\n" + " in: query\n" + " description: Id Description\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " example: 1\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.jaxrs2.Reader 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.jaxrs2.Reader 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("*/*"));
}
Aggregations