Search in sources :

Example 21 with Operation

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

the class PostParamTest method findAPostOperationWithStringsArray.

@Test(description = "find a Post operation with an array of strings")
public void findAPostOperationWithStringsArray() {
    Path petPath = getPath("arrayOfStrings");
    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)

Example 22 with Operation

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

the class PostParamTest method findAPostOperationWithStringsCollection.

@Test(description = "find a Post operation with collection of strings")
public void findAPostOperationWithStringsCollection() {
    Path petPath = getPath("collectionOfStrings");
    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)

Example 23 with Operation

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);
}
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) Test(org.testng.annotations.Test)

Example 24 with Operation

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);
}
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 25 with Operation

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);
}
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)

Aggregations

Operation (io.swagger.models.Operation)106 Test (org.testng.annotations.Test)78 Swagger (io.swagger.models.Swagger)39 Path (io.swagger.models.Path)30 BodyParameter (io.swagger.models.parameters.BodyParameter)24 Property (io.swagger.models.properties.Property)24 Response (io.swagger.models.Response)23 Parameter (io.swagger.models.parameters.Parameter)17 RefProperty (io.swagger.models.properties.RefProperty)16 ArrayModel (io.swagger.models.ArrayModel)15 Model (io.swagger.models.Model)14 StringProperty (io.swagger.models.properties.StringProperty)13 ArrayProperty (io.swagger.models.properties.ArrayProperty)12 ReaderContext (io.swagger.servlet.ReaderContext)12 QueryParameter (io.swagger.models.parameters.QueryParameter)10 MapProperty (io.swagger.models.properties.MapProperty)10 NicknamedOperation (io.swagger.resources.NicknamedOperation)10 PathParameter (io.swagger.models.parameters.PathParameter)8 ApiOperation (io.swagger.annotations.ApiOperation)7 Method (java.lang.reflect.Method)7