use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testAnotherResourceWithSubresources.
@Test(description = "test another resource with subresources")
public void testAnotherResourceWithSubresources() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(TestResource.class);
Paths paths = openAPI.getPaths();
assertEquals(paths.size(), 3);
PathItem pathItem = paths.get("/test/status");
assertNotNull(pathItem);
Operation operation = pathItem.getGet();
assertNotNull(operation);
assertTrue(operation.getResponses().getDefault().getContent().keySet().contains("application/json"));
Schema schema = operation.getResponses().getDefault().getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getType(), "string");
pathItem = paths.get("/test/more/otherStatus");
assertNotNull(pathItem);
operation = pathItem.getGet();
assertNotNull(operation);
assertTrue(operation.getResponses().getDefault().getContent().keySet().contains("application/json"));
assertFalse(operation.getResponses().getDefault().getContent().keySet().contains("application/xml"));
schema = operation.getResponses().getDefault().getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getType(), "string");
pathItem = paths.get("/test/evenmore/otherStatus");
assertNotNull(pathItem);
operation = pathItem.getGet();
assertNotNull(operation);
assertTrue(operation.getResponses().getDefault().getContent().keySet().contains("application/json"));
assertFalse(operation.getResponses().getDefault().getContent().keySet().contains("application/xml"));
schema = operation.getResponses().getDefault().getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getType(), "string");
assertEquals(operation.getRequestBody().getContent().get("application/json").getSchema().get$ref(), "#/components/schemas/Pet");
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testSubscriptionIdParam.
@Test(description = "Get the Param of an operation")
public void testSubscriptionIdParam() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(BasicFieldsResource.class);
assertNotNull(openAPI);
Paths openAPIPaths = openAPI.getPaths();
assertNotNull(openAPIPaths);
PathItem pathItem = openAPIPaths.get(PATH_1_REF);
assertNotNull(pathItem);
Operation operation = pathItem.getGet();
assertNotNull(operation);
List<Parameter> parameters = operation.getParameters();
assertNotNull(parameters);
assertEquals(PARAMETER_NUMBER, parameters.size());
Parameter parameter = parameters.get(0);
assertNotNull(parameter);
assertEquals(PARAMETER_IN, parameter.getIn());
assertEquals(PARAMETER_NAME, parameter.getName());
assertEquals(PARAMETER_DESCRIPTION, parameter.getDescription());
assertEquals(Boolean.TRUE, parameter.getRequired());
assertEquals(Boolean.TRUE, parameter.getAllowEmptyValue());
assertEquals(Boolean.TRUE, parameter.getAllowReserved());
Schema schema = parameter.getSchema();
assertNotNull(schema);
assertEquals(SCHEMA_TYPE, schema.getType());
assertEquals(SCHEMA_FORMAT, schema.getFormat());
assertEquals(SCHEMA_DESCRIPTION, schema.getDescription());
assertEquals(Boolean.TRUE, schema.getReadOnly());
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method test2646.
@Test(description = "test ticket #2646 method annotated with @Produce")
public void test2646() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(BookStoreTicket2646.class);
Paths paths = openAPI.getPaths();
assertEquals(paths.size(), 2);
PathItem pathItem = paths.get("/bookstore");
assertNotNull(pathItem);
Operation operation = pathItem.getGet();
assertNotNull(operation);
assertTrue(operation.getResponses().getDefault().getContent().keySet().contains("application/json"));
pathItem = paths.get("/bookstore/{id}");
assertNotNull(pathItem);
operation = pathItem.getDelete();
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 testSimpleReadClass.
@Test(description = "test a simple resource class")
public void testSimpleReadClass() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(BasicFieldsResource.class);
Paths paths = openAPI.getPaths();
assertEquals(paths.size(), 6);
PathItem pathItem = paths.get(PATH_1_REF);
assertNotNull(pathItem);
assertNull(pathItem.getPost());
Operation operation = pathItem.getGet();
assertNotNull(operation);
assertEquals(OPERATION_SUMMARY, operation.getSummary());
assertEquals(OPERATION_DESCRIPTION, operation.getDescription());
}
use of io.swagger.v3.oas.models.Paths in project swagger-core by swagger-api.
the class ReaderTest method testResourceWithClassBasedSubresources.
@Test(description = "scan resource with class-based sub-resources")
public void testResourceWithClassBasedSubresources() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(SubResourceHead.class);
Paths paths = openAPI.getPaths();
assertEquals(paths.size(), 3);
PathItem pathItem = paths.get("/head/tail/hello");
assertNotNull(pathItem);
Operation operation = pathItem.getGet();
assertNotNull(operation);
assertTrue(operation.getResponses().getDefault().getContent().keySet().contains("*/*"));
Schema schema = operation.getResponses().getDefault().getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getType(), "string");
pathItem = paths.get("/head/tail/{string}");
assertNotNull(pathItem);
operation = pathItem.getGet();
assertNotNull(operation);
assertTrue(operation.getResponses().getDefault().getContent().keySet().contains("*/*"));
schema = operation.getResponses().getDefault().getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getType(), "string");
pathItem = paths.get("/head/noPath");
assertNotNull(pathItem);
operation = pathItem.getGet();
assertNotNull(operation);
assertTrue(operation.getResponses().getDefault().getContent().keySet().contains("*/*"));
schema = operation.getResponses().getDefault().getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getType(), "string");
}
Aggregations