use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testSecurityRequirement.
@Test(description = "Security Requirement")
public void testSecurityRequirement() {
Reader reader = new Reader(new OpenAPI());
Method[] methods = SecurityResource.class.getDeclaredMethods();
Operation securityOperation = reader.parseMethod(Arrays.stream(methods).filter((method -> method.getName().equals("getSecurity"))).findFirst().get(), null, null);
assertNotNull(securityOperation);
List<SecurityRequirement> securityRequirements = securityOperation.getSecurity();
assertNotNull(securityRequirements);
assertEquals(SECURITY_REQUIREMENT_NUMBER, securityRequirements.size());
List<String> scopes = securityRequirements.get(0).get(SECURITY_KEY);
assertNotNull(scopes);
assertEquals(SCOPE_NUMBER, scopes.size());
assertEquals(SCOPE_VALUE1, scopes.get(0));
assertEquals(SCOPE_VALUE2, scopes.get(1));
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testTicket2144.
@Test(description = "non consistent overridden generic resource methods")
public void testTicket2144() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ItemResource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /item/{id}:\n" + " get:\n" + " operationId: getById\n" + " parameters:\n" + " - name: id\n" + " in: path\n" + " required: true\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/ItemWithChildren'\n" + " /item/nogeneric/{id}:\n" + " get:\n" + " operationId: getByIdNoGeneric\n" + " parameters:\n" + " - name: id\n" + " in: path\n" + " required: true\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/ItemWithChildren'\n" + " /item/nogenericsamereturn/{id}:\n" + " get:\n" + " operationId: getByIdNoGenericSameReturn\n" + " parameters:\n" + " - name: id\n" + " in: path\n" + " required: true\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/BaseDTO'\n" + " /item/genericparam:\n" + " post:\n" + " operationId: genericParam\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/ItemWithChildren'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/BaseDTO'\n" + "components:\n" + " schemas:\n" + " ItemWithChildren:\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string\n" + " names:\n" + " type: string\n" + " BaseDTO:\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testTicket2763.
@Test(description = "Responses with array schema")
public void testTicket2763() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket2763Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /array:\n" + " get:\n" + " operationId: getArrayResponses\n" + " responses:\n" + " default:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " items:\n" + " $ref: https://openebench.bsc.es/monitor/tool/tool.json\n" + " /schema:\n" + " get:\n" + " operationId: getSchemaResponses\n" + " responses:\n" + " default:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: https://openebench.bsc.es/monitor/tool/tool.json";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testTicket3149.
@Test(description = "overridden generic resource interface default methods")
public void testTicket3149() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(MainResource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /test:\n" + " post:\n" + " tags:\n" + " - Test inheritance on default implementation in interfaces\n" + " operationId: firstEndpoint\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/SampleDTO'\n" + " responses:\n" + " \"201\":\n" + " description: Created\n" + " \"400\":\n" + " description: Bad Request\n" + " \"403\":\n" + " description: Forbidden\n" + " \"404\":\n" + " description: Not Found\n" + " /test/{id}:\n" + " get:\n" + " tags:\n" + " - Test inheritance on default implementation in interfaces\n" + " operationId: secondEnpoint\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/SampleOtherDTO'\n" + " responses:\n" + " \"200\":\n" + " description: OK\n" + " \"400\":\n" + " description: Bad Request\n" + " \"403\":\n" + " description: Forbidden\n" + " \"404\":\n" + " description: Not Found\n" + " /test/original/{id}:\n" + " get:\n" + " tags:\n" + " - Test inheritance on default implementation in interfaces\n" + " operationId: originalEndpoint\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/SampleOtherDTO'\n" + " responses:\n" + " \"200\":\n" + " description: OK\n" + " \"400\":\n" + " description: Bad Request\n" + " \"403\":\n" + " description: Forbidden\n" + " \"404\":\n" + " description: Not Found\n" + "components:\n" + " schemas:\n" + " SampleDTO:\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string\n" + " SampleOtherDTO:\n" + " type: object\n" + " properties:\n" + " label:\n" + " type: string";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testTicket3426.
@Test(description = "overridden generic resource methods operationId")
public void testTicket3426() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket3426Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /inheritExample/{input}:\n" + " get:\n" + " operationId: get\n" + " parameters:\n" + " - name: input\n" + " in: path\n" + " required: true\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " type: string";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
Aggregations