use of org.jpox.samples.one_one.unidir_2.Reader in project swagger-core by swagger-api.
the class RequestBodyTest method testRequestBodyAnnotationPriority.
@Test(description = "scan class with requesbody annotation")
public void testRequestBodyAnnotationPriority() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(RequestBodyResource.class);
PathItem userPathItem = openAPI.getPaths().get(USER_PATH);
io.swagger.v3.oas.models.parameters.RequestBody getRequestBody = userPathItem.getGet().getRequestBody();
assertNotNull(getRequestBody);
assertEquals(getRequestBody.getDescription(), REQUEST_BODY_IN_ANNOTATION);
io.swagger.v3.oas.models.parameters.RequestBody postRequestBody = userPathItem.getPost().getRequestBody();
assertNotNull(postRequestBody);
assertEquals(postRequestBody.getDescription(), REQUEST_BODY_IN_ANNOTATION);
io.swagger.v3.oas.models.parameters.RequestBody putRequestBody = userPathItem.getPut().getRequestBody();
assertNotNull(putRequestBody);
assertEquals(putRequestBody.getDescription(), REQUEST_BODY_IN_METHOD);
io.swagger.v3.oas.models.parameters.RequestBody deleteRequestBody = userPathItem.getDelete().getRequestBody();
assertNotNull(deleteRequestBody);
assertEquals(deleteRequestBody.getDescription(), REQUEST_BODY_IN_METHOD);
io.swagger.v3.oas.models.parameters.RequestBody patchRequestBody = userPathItem.getPatch().getRequestBody();
assertNotNull(patchRequestBody);
assertEquals(patchRequestBody.getDescription(), REQUEST_BODY_IN_METHOD);
userPathItem = openAPI.getPaths().get(USER_PATH + "/deleteUserMethod_Param_RequestBody");
deleteRequestBody = userPathItem.getDelete().getRequestBody();
assertNotNull(deleteRequestBody);
assertEquals(deleteRequestBody.getDescription(), REQUEST_BODY_IN_PARAMETER);
userPathItem = openAPI.getPaths().get(USER_PATH + "/deleteUserOperation_Method_Param_RequestBody");
deleteRequestBody = userPathItem.getDelete().getRequestBody();
assertNotNull(deleteRequestBody);
assertEquals(deleteRequestBody.getDescription(), REQUEST_BODY_IN_PARAMETER);
userPathItem = openAPI.getPaths().get(USER_PATH + "/deleteUserOperation_RequestBody");
deleteRequestBody = userPathItem.getDelete().getRequestBody();
assertNotNull(deleteRequestBody);
assertEquals(deleteRequestBody.getDescription(), REQUEST_BODY_IN_PARAMETER);
userPathItem = openAPI.getPaths().get(USER_PATH + "/deleteUserOperation_Method_Param");
deleteRequestBody = userPathItem.getDelete().getRequestBody();
assertNotNull(deleteRequestBody);
assertEquals(deleteRequestBody.getDescription(), REQUEST_BODY_IN_METHOD);
}
use of org.jpox.samples.one_one.unidir_2.Reader in project swagger-core by swagger-api.
the class AbstractAnnotationTest method compareAsYaml.
public void compareAsYaml(final Class<?> cls, final String yaml) throws IOException {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(cls);
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of org.jpox.samples.one_one.unidir_2.Reader in project swagger-core by swagger-api.
the class ParametersTest method testJacksonFeatures.
@Test(description = "JsonUnwrapped, JsonIgnore, JsonValue should be honoured")
public void testJacksonFeatures() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ResourceWithJacksonBean.class);
io.swagger.v3.oas.models.media.Schema o = openAPI.getComponents().getSchemas().get("JacksonBean");
assertEquals(o.getProperties().keySet(), Stream.of("identity", "bean", "code", "message", "precodesuf", "premessagesuf").collect(Collectors.toSet()));
}
use of org.jpox.samples.one_one.unidir_2.Reader in project swagger-core by swagger-api.
the class ParametersTest method scanClassAndFieldLevelAnnotations.
@Test(description = "scan class level and field level annotations")
public void scanClassAndFieldLevelAnnotations() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ResourceWithKnownInjections.class);
List<io.swagger.v3.oas.models.parameters.Parameter> resourceParameters = openAPI.getPaths().get("/resource/{id}").getGet().getParameters();
assertNotNull(resourceParameters);
assertEquals(resourceParameters.size(), 3);
assertEquals(resourceParameters.get(0).getName(), "id");
assertEquals(resourceParameters.get(1).getName(), "fieldParam");
assertEquals(resourceParameters.get(2).getName(), "methodParam");
}
use of org.jpox.samples.one_one.unidir_2.Reader in project swagger-core by swagger-api.
the class JaxrsApplicationAndResourcePackagesAnnotationScannerTest method shouldScanForClassesWhenApplicationIsNotSet.
@Test(description = "scan classes from Application when it is not set")
public void shouldScanForClassesWhenApplicationIsNotSet() throws Exception {
SwaggerConfiguration config = new SwaggerConfiguration().openAPI(new OpenAPI().info(new Info().description("TEST INFO DESC")));
OpenApiContext ctx = new GenericOpenApiContext<>().openApiConfiguration(config).openApiReader(new Reader(config)).openApiScanner(scanner.openApiConfiguration(config)).init();
OpenAPI openApi = ctx.read();
assertNotNull(openApi);
assertNull(openApi.getPaths());
}
Aggregations