Search in sources :

Example 56 with QueryParameter

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

the class ReaderTest method scanParametersFromBaseResource.

@Test(description = "it should scan parameters from base resource class")
public void scanParametersFromBaseResource() {
    Swagger swagger = getSwagger(BookResource.class);
    assertNotNull(swagger);
    List<Parameter> parameters = getGet(swagger, "/{id}/v1/books/{name}").getParameters();
    assertEquals(parameters.size(), 4);
    Parameter description = parameters.get(0);
    assertTrue(description instanceof PathParameter);
    assertEquals(description.getName(), "description");
    assertEquals(description.getDescription(), "Overridden description");
    Parameter id = parameters.get(1);
    assertTrue(id instanceof PathParameter);
    assertEquals(id.getName(), "id");
    assertEquals(id.getDescription(), "The Identifier of entity");
    Parameter test = parameters.get(2);
    assertTrue(test instanceof QueryParameter);
    assertEquals(test.getName(), "test");
    assertEquals(test.getDescription(), "Test Query Param");
    Parameter name = parameters.get(3);
    assertTrue(name instanceof PathParameter);
    assertEquals(name.getName(), "name");
    assertEquals(name.getDescription(), "The books name");
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) FormParameter(io.swagger.models.parameters.FormParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) QueryParameter(io.swagger.models.parameters.QueryParameter) HeaderParameter(io.swagger.models.parameters.HeaderParameter) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Example 57 with QueryParameter

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

the class SimpleReaderTest method scanDefaultValueAndRequiredOptions.

@Test(description = "scan defaultValue and required per #937")
public void scanDefaultValueAndRequiredOptions() {
    Swagger swagger = getSwagger(Resource937.class);
    QueryParameter param = (QueryParameter) getGetParameters(swagger, "/external/info").get(0);
    assertFalse(param.getRequired());
    assertEquals(param.getDefaultValue(), "dogs");
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) Test(org.testng.annotations.Test)

Example 58 with QueryParameter

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

the class GenericsTest method checkCollectionsOfStrings.

@Test(description = "check collections of strings")
public void checkCollectionsOfStrings() {
    Operation op = getOperation("testStringContainers");
    assertEquals(op.getParameters().size(), 5);
    QueryParameter set = getQueryParameter(op, 0);
    testCollection(set, "set", "string", null);
    assertEquals(((StringProperty) set.getItems()).getEnum(), Arrays.asList("1", "2", "3"));
    testCollection(getQueryParameter(op, 1), "list", "string", null);
    testCollection(getQueryParameter(op, 2), "list2D", "string", null);
    testCollection(getQueryParameter(op, 3), "array", "string", null);
    testScalar(getQueryParameter(op, 4), "scalar", "string", null);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 59 with QueryParameter

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

the class OverriddenTypeTests method integerTypeOverrideTest.

@Test(description = "overrides a system-detected type")
public void integerTypeOverrideTest() {
    Swagger swagger = new Reader(new Swagger()).read(Resource469.class);
    QueryParameter qp = (QueryParameter) swagger.getPath("/test").getPut().getParameters().get(0);
    assertEquals(qp.getType(), "string");
    assertEquals(qp.getFormat(), "blah");
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Example 60 with QueryParameter

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

the class OverriddenTypeTests method integerFormatOverrideTest.

@Test(description = "overrides a system-detected format")
public void integerFormatOverrideTest() {
    Swagger swagger = new Reader(new Swagger()).read(Resource469.class);
    QueryParameter qp = (QueryParameter) swagger.getPath("/test").getPost().getParameters().get(0);
    assertEquals(qp.getFormat(), "int64");
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Aggregations

QueryParameter (io.swagger.models.parameters.QueryParameter)92 Test (org.testng.annotations.Test)58 Parameter (io.swagger.models.parameters.Parameter)42 PathParameter (io.swagger.models.parameters.PathParameter)34 BodyParameter (io.swagger.models.parameters.BodyParameter)28 Swagger (io.swagger.models.Swagger)25 HeaderParameter (io.swagger.models.parameters.HeaderParameter)15 Test (org.junit.Test)12 Operation (io.swagger.models.Operation)11 FormParameter (io.swagger.models.parameters.FormParameter)11 SerializableParameter (io.swagger.models.parameters.SerializableParameter)10 StringProperty (io.swagger.models.properties.StringProperty)10 HashMap (java.util.HashMap)10 Path (io.swagger.models.Path)9 RefModel (io.swagger.models.RefModel)9 Type (java.lang.reflect.Type)9 BigDecimal (java.math.BigDecimal)9 RefProperty (io.swagger.models.properties.RefProperty)8 Response (io.swagger.models.Response)7 Method (java.lang.reflect.Method)7