use of io.swagger.models.parameters.PathParameter in project java-chassis by ServiceComb.
the class TestPath method testUrlPathBuilder.
@Test
public void testUrlPathBuilder() throws Exception {
Map<String, RestParam> paramMap = new HashMap<>();
Parameter pathParameter = new PathParameter();
pathParameter.setName("id");
RestParam oRestParam = new RestParam(pathParameter, int.class);
paramMap.put(oRestParam.getParamName(), oRestParam);
Parameter queryParameter = new QueryParameter();
queryParameter.setName("q");
oRestParam = new RestParam(queryParameter, String.class);
paramMap.put(oRestParam.getParamName(), oRestParam);
URLPathBuilder oURLPathBuilder = new URLPathBuilder("/root/{id}", paramMap);
Map<String, Object> parameters = new HashMap<>();
parameters.put("id", 100);
parameters.put("q", "query");
Assert.assertEquals("/root/100?q=query", oURLPathBuilder.createRequestPath(parameters));
Assert.assertEquals("/root/100", oURLPathBuilder.createPathString(parameters));
}
use of io.swagger.models.parameters.PathParameter in project java-chassis by ServiceComb.
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());
}
use of io.swagger.models.parameters.PathParameter in project carbon-apimgt by wso2.
the class OAS2Parser method createOperation.
/**
* Creates a new operation object using the URI template object
*
* @param resource API resource data
* @return a new operation object using the URI template object
*/
private Operation createOperation(SwaggerData.Resource resource) {
Operation operation = new Operation();
List<String> pathParams = getPathParamNames(resource.getPath());
for (String pathParam : pathParams) {
PathParameter pathParameter = new PathParameter();
pathParameter.setName(pathParam);
pathParameter.setType("string");
operation.addParameter(pathParameter);
}
updateOperationManagedInfo(resource, operation);
Response response = new Response();
response.setDescription("OK");
operation.addResponse(APIConstants.SWAGGER_RESPONSE_200, response);
return operation;
}
use of io.swagger.models.parameters.PathParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method implicitParameterLongTypeProcessorTest.
@Test(description = "test for issue #1873 fixing.")
public void implicitParameterLongTypeProcessorTest() throws NoSuchMethodException {
final ApiImplicitParams params = getClass().getDeclaredMethod("implicitParametrizedMethodLongType").getAnnotation(ApiImplicitParams.class);
final PathParameter param0 = (PathParameter) ParameterProcessor.applyAnnotations(null, new PathParameter(), String.class, Collections.<Annotation>singletonList(params.value()[0]));
assertEquals(param0.getName(), "id");
assertEquals(param0.getIn(), "path");
assertEquals(param0.getRequired(), true);
assertEquals(param0.getType(), "integer");
assertEquals(param0.getFormat(), "int64");
}
use of io.swagger.models.parameters.PathParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method implicitArrayParameterProcessorTest.
@Test(description = "parse implicit parameters from method")
public void implicitArrayParameterProcessorTest() throws NoSuchMethodException {
final ApiImplicitParams params = getClass().getDeclaredMethod("implicitArrayParametrizedMethod").getAnnotation(ApiImplicitParams.class);
final PathParameter param0 = (PathParameter) ParameterProcessor.applyAnnotations(null, new PathParameter(), String.class, Collections.<Annotation>singletonList(params.value()[0]));
assertEquals(param0.getType(), "array");
assertEquals(param0.getItems().getType(), "string");
}
Aggregations