Search in sources :

Example 36 with BodyParameter

use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.

the class SimpleReaderTest method testParam.

private Model testParam(Swagger swagger, String path, String name, String description) {
    BodyParameter param = (BodyParameter) getPostParameters(swagger, path).get(0);
    assertEquals(param.getIn(), "body");
    assertEquals(param.getName(), name);
    assertEquals(param.getDescription(), description);
    return param.getSchema();
}
Also used : BodyParameter(io.swagger.models.parameters.BodyParameter)

Example 37 with BodyParameter

use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.

the class GenericsTest method checkCollectionsOfStringsAsBodyParameter.

@Test(description = "check collection of strings as body parameter")
public void checkCollectionsOfStringsAsBodyParameter() {
    Operation op = getOperation("testStringsInBody");
    assertEquals(op.getParameters().size(), 1);
    BodyParameter p = getBodyParameter(op, 0);
    ArrayModel strArray = (ArrayModel) p.getSchema();
    assertEquals(strArray.getItems().getType(), "string");
}
Also used : Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) ArrayModel(io.swagger.models.ArrayModel) Test(org.testng.annotations.Test)

Example 38 with BodyParameter

use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.

the class GenericsTest method checkCollectionsOfEnumerationsAsBodyParameter.

@Test(description = "check collection of enumerations as body parameter")
public void checkCollectionsOfEnumerationsAsBodyParameter() {
    Operation op = getOperation("testEnumsInBody");
    assertEquals(op.getParameters().size(), 1);
    BodyParameter p = getBodyParameter(op, 0);
    ArrayModel enumArray = (ArrayModel) p.getSchema();
    assertEquals(((StringProperty) enumArray.getItems()).getEnum(), enumValues);
}
Also used : Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) ArrayModel(io.swagger.models.ArrayModel) Test(org.testng.annotations.Test)

Example 39 with BodyParameter

use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.

the class PostParamTest method findPostOperationWithObjectsCollection.

@Test(description = "find a Post operation with collection of objects")
public void findPostOperationWithObjectsCollection() {
    Path petPath = getPath("collectionOfObjects");
    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);
}
Also used : Path(io.swagger.models.Path) Model(io.swagger.models.Model) ArrayModel(io.swagger.models.ArrayModel) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) ArrayModel(io.swagger.models.ArrayModel) StringProperty(io.swagger.models.properties.StringProperty) RefProperty(io.swagger.models.properties.RefProperty) Property(io.swagger.models.properties.Property) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Example 40 with BodyParameter

use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.

the class PostParamTest method findAPostOperationWithStringsList.

@Test(description = "find a Post operation with list of strings")
public void findAPostOperationWithStringsList() {
    Path petPath = getPath("listOfStrings");
    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 StringProperty);
}
Also used : Path(io.swagger.models.Path) Model(io.swagger.models.Model) ArrayModel(io.swagger.models.ArrayModel) StringProperty(io.swagger.models.properties.StringProperty) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) ArrayModel(io.swagger.models.ArrayModel) StringProperty(io.swagger.models.properties.StringProperty) RefProperty(io.swagger.models.properties.RefProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Aggregations

BodyParameter (io.swagger.models.parameters.BodyParameter)46 Test (org.testng.annotations.Test)34 Operation (io.swagger.models.Operation)20 Parameter (io.swagger.models.parameters.Parameter)16 ArrayModel (io.swagger.models.ArrayModel)15 Model (io.swagger.models.Model)15 PathParameter (io.swagger.models.parameters.PathParameter)14 Path (io.swagger.models.Path)13 QueryParameter (io.swagger.models.parameters.QueryParameter)13 StringProperty (io.swagger.models.properties.StringProperty)13 Swagger (io.swagger.models.Swagger)11 Property (io.swagger.models.properties.Property)11 RefProperty (io.swagger.models.properties.RefProperty)11 ModelImpl (io.swagger.models.ModelImpl)7 RefModel (io.swagger.models.RefModel)7 HeaderParameter (io.swagger.models.parameters.HeaderParameter)7 SerializableParameter (io.swagger.models.parameters.SerializableParameter)6 ArrayProperty (io.swagger.models.properties.ArrayProperty)5 PendingBodyParameter (io.servicecomb.swagger.extend.parameter.PendingBodyParameter)4 Response (io.swagger.models.Response)4