use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithSingleString.
@Test(description = "find a Post operation with single string")
public void findAPostOperationWithSingleString() {
Path petPath = getPath("singleString");
assertNotNull(petPath);
assertNull(petPath.getGet());
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
assertTrue(petPostBodyParam.getSchema() instanceof Model);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithObjectsArray.
@Test(description = "find a Post operation with an array of objects")
public void findAPostOperationWithObjectsArray() {
Path petPath = getPath("arrayOfObjects");
assertNotNull(petPath);
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
Model inputModel = petPostBodyParam.getSchema();
assertTrue(inputModel instanceof ArrayModel);
ArrayModel ap = (ArrayModel) inputModel;
Property inputSchema = ap.getItems();
assertTrue(inputSchema instanceof RefProperty);
RefProperty rm = (RefProperty) inputSchema;
assertEquals(rm.getSimpleRef(), PET);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class PostParamTest method findPostOperationWithObjectsList.
@Test(description = "find a Post operation with list of objects")
public void findPostOperationWithObjectsList() {
Path petPath = getPath("listOfObjects");
assertNotNull(petPath);
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
Model inputModel = petPostBodyParam.getSchema();
assertTrue(inputModel instanceof ArrayModel);
ArrayModel ap = (ArrayModel) inputModel;
Property inputSchema = ap.getItems();
assertTrue(inputSchema instanceof RefProperty);
RefProperty rm = (RefProperty) inputSchema;
assertEquals(rm.getSimpleRef(), PET);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class PostParamTest method findPostOperationWithSingleObject.
@Test(description = "find a Post operation with single object")
public void findPostOperationWithSingleObject() {
Path petPath = getPath("singleObject");
assertNotNull(petPath);
assertNull(petPath.getGet());
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
assertTrue(petPostBodyParam.getSchema() instanceof Model);
assertEquals(swagger.getDefinitions().get(PET).getProperties().get("status").getAccess(), "public");
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class ChildTypeTest method testChildTypeResponseOnOperation.
@Test(description = "Tests child type response schema ref is correctly set up when specified on the operation")
public void testChildTypeResponseOnOperation() {
Operation op = swagger.getPath("/childType/testChildTypeResponseOnOperation").getGet();
Property schema = op.getResponses().get("200").getSchema();
assertEquals(schema.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) schema).getSimpleRef(), "Sub1Bean");
}
Aggregations