Search in sources :

Example 61 with QueryParameter

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

the class OverriddenTypeTests method implicitParamTest.

@Test(description = "add a user-specified type with implicit annotation")
public void implicitParamTest() {
    Swagger swagger = new Reader(new Swagger()).read(Resource469.class);
    QueryParameter qp = (QueryParameter) swagger.getPath("/test2").getGet().getParameters().get(0);
    assertEquals(qp.getType(), "string");
    assertEquals(qp.getFormat(), "password");
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Example 62 with QueryParameter

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

the class OverriddenTypeTests method passwordParameterTest.

@Test(description = "add a user-specified format")
public void passwordParameterTest() {
    Swagger swagger = new Reader(new Swagger()).read(Resource469.class);
    QueryParameter qp = (QueryParameter) swagger.getPath("/test").getGet().getParameters().get(0);
    assertEquals(qp.getFormat(), "password");
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Example 63 with QueryParameter

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

the class SimpleReaderTest method scanClassWithImplicitExampleClassQuery.

@Test(description = "scan a resource with implicit operation query example (dataTypeClass)")
public void scanClassWithImplicitExampleClassQuery() {
    Swagger swagger = getSwagger(ClassWithExamplePostClass.class);
    Parameter param = swagger.getPaths().get("/external/info2").getGet().getParameters().get(0);
    QueryParameter bp = (QueryParameter) param;
    assertNotNull(bp.getExample());
    Object value = bp.getExample();
    assertEquals("77", value);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) SerializableParameter(io.swagger.models.parameters.SerializableParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) QueryParameter(io.swagger.models.parameters.QueryParameter) BodyParameter(io.swagger.models.parameters.BodyParameter) Test(org.testng.annotations.Test)

Example 64 with QueryParameter

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

the class ReaderTest method scanImplicitParam.

@Test(description = "scan implicit params")
public void scanImplicitParam() {
    Swagger swagger = getSwagger(ResourceWithImplicitParams.class);
    List<Parameter> params = swagger.getPath("/testString").getPost().getParameters();
    assertNotNull(params);
    assertEquals(params.size(), 7);
    assertEquals(params.get(0).getName(), "sort");
    assertEquals(params.get(0).getIn(), "query");
    PathParameter pathParam = (PathParameter) params.get(1);
    assertEquals(pathParam.getName(), "type");
    assertEquals(pathParam.getIn(), "path");
    assertEquals(pathParam.getEnum().size(), 3);
    assertEquals(pathParam.getType(), "string");
    HeaderParameter headerParam = (HeaderParameter) params.get(2);
    assertEquals(headerParam.getName(), "size");
    assertEquals(headerParam.getIn(), "header");
    assertEquals(headerParam.getMinimum(), new BigDecimal(1.0));
    FormParameter formParam = (FormParameter) params.get(3);
    assertEquals(formParam.getName(), "width");
    assertEquals(formParam.getIn(), "formData");
    assertEquals(formParam.getMaximum(), new BigDecimal(1.0));
    assertEquals(params.get(4).getName(), "width");
    assertEquals(params.get(4).getIn(), "formData");
    QueryParameter queryParam = (QueryParameter) params.get(5);
    assertEquals(queryParam.getName(), "height");
    assertEquals(queryParam.getIn(), "query");
    assertEquals(queryParam.getMinimum(), new BigDecimal(3.0));
    assertEquals(queryParam.getMaximum(), new BigDecimal(4.0));
    BodyParameter bodyParam = (BodyParameter) params.get(6);
    assertEquals(bodyParam.getName(), "body");
    assertEquals(bodyParam.getIn(), "body");
    assertTrue(bodyParam.getRequired());
}
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) HeaderParameter(io.swagger.models.parameters.HeaderParameter) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) FormParameter(io.swagger.models.parameters.FormParameter) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 65 with QueryParameter

use of io.swagger.models.parameters.QueryParameter in project java-chassis by ServiceComb.

the class SpringmvcDefaultParameterProcessor method process.

@Override
public void process(OperationGenerator operationGenerator, int paramIdx) {
    String paramName = ParamUtils.getParameterName(operationGenerator.getProviderMethod(), paramIdx);
    QueryParameter queryParameter = new QueryParameter();
    queryParameter.setName(paramName);
    ParamUtils.setParameterType(operationGenerator.getSwagger(), operationGenerator.getProviderMethod(), paramIdx, queryParameter);
    operationGenerator.addProviderParameter(queryParameter);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter)

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