Search in sources :

Example 41 with PathParameter

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

the class SimpleReaderTest method verifyTopLevelPathParams.

@Test(description = "verify top-level path params per #1085")
public void verifyTopLevelPathParams() {
    Swagger swagger = getSwagger(Resource1085.class);
    Parameter param = getGetParameters(swagger, "/external/info/{id}").get(0);
    assertEquals(param.getName(), "id");
    assertTrue(param instanceof PathParameter);
}
Also used : 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) PathParameter(io.swagger.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Example 42 with PathParameter

use of io.swagger.models.parameters.PathParameter 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 43 with PathParameter

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

the class ImplicitParametersTest method detailedTest.

@Test
public void detailedTest() throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyImplicitParameters(context, operation, findMethod(context, "testMethod3"));
    final List<Parameter> parameters = operation.getParameters();
    final Parameter parameter1 = parameters.get(0);
    Assert.assertNotNull(parameter1);
    Assert.assertTrue(parameter1 instanceof PathParameter);
    Assert.assertEquals(parameter1.getName(), "param1");
    Assert.assertEquals(parameter1.getIn(), "path");
    Assert.assertEquals(parameter1.getDescription(), "Param 1");
    Assert.assertTrue(parameter1.getRequired());
    final Parameter parameter5 = parameters.get(4);
    Assert.assertNotNull(parameter5);
    Assert.assertTrue(parameter5 instanceof BodyParameter);
    Assert.assertEquals(parameter5.getName(), "param5");
    Assert.assertEquals(parameter5.getIn(), "body");
    Assert.assertEquals(parameter5.getDescription(), "Param 5");
    Assert.assertFalse(parameter5.getRequired());
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Example 44 with PathParameter

use of io.swagger.models.parameters.PathParameter in project carbon-apimgt by wso2.

the class APIDefinitionFromSwagger20 method getParameterFromURITemplateParam.

private Parameter getParameterFromURITemplateParam(URITemplateParam uriTemplateParam) {
    switch(uriTemplateParam.getParamType()) {
        case BODY:
            return getDefaultBodyParameter();
        case PATH:
            PathParameter pathParameter = new PathParameter();
            pathParameter.setName(uriTemplateParam.getName());
            pathParameter.setType(uriTemplateParam.getDataType());
            return pathParameter;
        case QUERY:
            QueryParameter queryParameter = new QueryParameter();
            queryParameter.setName(uriTemplateParam.getName());
            queryParameter.setType(uriTemplateParam.getDataType());
            return queryParameter;
        case FORM_DATA:
            FormParameter formParameter = new FormParameter();
            formParameter.setName(uriTemplateParam.getName());
            formParameter.setType(uriTemplateParam.getDataType());
            return formParameter;
        default:
            return null;
    }
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) PathParameter(io.swagger.models.parameters.PathParameter) FormParameter(io.swagger.models.parameters.FormParameter)

Example 45 with PathParameter

use of io.swagger.models.parameters.PathParameter in project incubator-servicecomb-java-chassis by apache.

the class TestPathProcessorCreator method testCreate.

@Test
public void testCreate() {
    ParamValueProcessorCreator creator = ParamValueProcessorCreatorManager.INSTANCE.findValue(PathProcessorCreator.PARAMTYPE);
    Parameter parameter = new PathParameter();
    parameter.setName("path");
    ParamValueProcessor processor = creator.create(parameter, String.class);
    Assert.assertEquals(PathProcessor.class, processor.getClass());
}
Also used : PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) PathParameter(io.swagger.models.parameters.PathParameter) Test(org.junit.Test)

Aggregations

PathParameter (io.swagger.models.parameters.PathParameter)51 QueryParameter (io.swagger.models.parameters.QueryParameter)35 Parameter (io.swagger.models.parameters.Parameter)32 Test (org.testng.annotations.Test)32 BodyParameter (io.swagger.models.parameters.BodyParameter)26 HeaderParameter (io.swagger.models.parameters.HeaderParameter)16 Swagger (io.swagger.models.Swagger)14 StringProperty (io.swagger.models.properties.StringProperty)12 FormParameter (io.swagger.models.parameters.FormParameter)11 Operation (io.swagger.models.Operation)10 SerializableParameter (io.swagger.models.parameters.SerializableParameter)10 Response (io.swagger.models.Response)8 IntegerProperty (io.swagger.models.properties.IntegerProperty)8 RefProperty (io.swagger.models.properties.RefProperty)8 Path (io.swagger.models.Path)6 ArrayProperty (io.swagger.models.properties.ArrayProperty)6 HashMap (java.util.HashMap)6 ModelImpl (io.swagger.models.ModelImpl)5 RefModel (io.swagger.models.RefModel)5 ArrayList (java.util.ArrayList)5