use of io.swagger.models.parameters.BodyParameter 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.parameters.BodyParameter 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.parameters.BodyParameter 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.parameters.BodyParameter in project swagger-core by swagger-api.
the class ChildTypeTest method testChildTypeParameter.
@Test(description = "Tests schema ref is correctly set up for child type parameter")
public void testChildTypeParameter() {
Operation op = swagger.getPath("/childType/testChildTypeParameter").getPost();
BodyParameter parameter = getBodyParameter(op, 0);
Model schema = parameter.getSchema();
assertEquals(schema.getClass().getName(), RefModel.class.getName());
assertEquals(((RefModel) schema).getSimpleRef(), "Sub1Bean");
}
use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.
the class GenericsTest method check2DArrayAsBodyParameter.
@Test(description = "check 2D array as body parameter")
public void check2DArrayAsBodyParameter() {
Operation op = getOperation("test2DInBody");
assertEquals(op.getParameters().size(), 1);
BodyParameter p = getBodyParameter(op, 0);
ArrayModel ddArray = (ArrayModel) p.getSchema();
assertEquals(((RefProperty) ((ArrayProperty) ddArray.getItems()).getItems()).getSimpleRef(), "Tag");
}
Aggregations