use of io.swagger.models.parameters.QueryParameter 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;
}
}
use of io.swagger.models.parameters.QueryParameter in project minijax by minijax.
the class ScannerTest method scanBeanParamResource.
@Test
public void scanBeanParamResource() {
final Swagger swagger = getSwagger(ResourceWithBeanParams.class);
final List<Parameter> params = getParameters(swagger, "/bean/{id}");
final HeaderParameter headerParam1 = (HeaderParameter) params.get(0);
assertEquals(1, headerParam1.getDefaultValue());
assertEquals("test order annotation 1", headerParam1.getName());
final HeaderParameter headerParam2 = (HeaderParameter) params.get(1);
assertEquals(2, headerParam2.getDefaultValue());
assertEquals("test order annotation 2", headerParam2.getName());
final QueryParameter priority1 = (QueryParameter) params.get(2);
assertNull(priority1.getDefaultValue());
assertEquals("test priority 1", priority1.getName());
final QueryParameter priority2 = (QueryParameter) params.get(3);
assertEquals(4, priority2.getDefaultValue());
assertEquals("test priority 2", priority2.getName());
final ModelImpl bodyParam1 = (ModelImpl) ((BodyParameter) params.get(4)).getSchema();
assertEquals("bodyParam", bodyParam1.getDefaultValue());
}
use of io.swagger.models.parameters.QueryParameter in project incubator-servicecomb-java-chassis by apache.
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);
}
use of io.swagger.models.parameters.QueryParameter in project incubator-servicecomb-java-chassis by apache.
the class TestRestOperationMeta method testFormDataFlagFalse.
@Test
public void testFormDataFlagFalse() {
when(meta.getMethod()).thenReturn(ReflectUtils.findMethod(SomeRestController.class, "form"));
when(meta.getSwaggerOperation()).thenReturn(operation);
List<Parameter> params = Arrays.asList(new QueryParameter());
when(operation.getParameters()).thenReturn(params);
operationMeta.init(meta);
assertThat(operationMeta.isFormData(), is(false));
}
use of io.swagger.models.parameters.QueryParameter in project sql-boot by sql-boot.
the class ApiController method getSwaggerDescription.
private Swagger getSwaggerDescription(HttpServletRequest request, String connectionName) {
FsResourceTypes fsResourceTypes = new FsResourceTypes(dbConnectionList.getConnectionByName(connectionName));
final List<ResourceType> resourceTypes = fsResourceTypes.resourceTypes();
Swagger swagger = new Swagger();
swagger.consumes("application/json");
swagger.host(request.getServerName() + ":" + request.getServerPort());
swagger.setInfo(new Info().version("v1").title("API specification"));
swagger.setSchemes(asList(Scheme.HTTP, Scheme.HTTPS));
swagger.path("/connections", new Path().get(new Operation().tag("connections").response(200, new Response().description("Ok").schema(new ArrayProperty(new RefProperty("connection")))).produces("application/json")));
swagger.model("connection", new ModelImpl().property("name", new StringProperty().description("name")).property("url", new StringProperty().description("url")).property("user", new StringProperty().description("user")).property("driverClassName", new StringProperty().description("driverClassName")).property("configurationFolder", new StringProperty().description("configurationFolder")));
// paths
for (ResourceType resourceType : resourceTypes) {
PathParameter parameter = new PathParameter().required(true).type("string").name("connection_name");
parameter.setDefaultValue(connectionName);
swagger.path("/api/{connection_name}/headers/" + resourceType.name(), new Path().get(new Operation().description(resourceType.name()).tag("db_objects").parameter(parameter).parameter(new QueryParameter().name("select").type("string")).parameter(new QueryParameter().name("distinct").type("boolean")).parameter(new QueryParameter().name("where").type("string")).parameter(new QueryParameter().name("page").type("string").description("get page by mask [page_count:page_size]")).parameter(new QueryParameter().name("limit").type("integer")).parameter(new QueryParameter().name("orderby").type("string")).parameter(new QueryParameter().name("cache").type("boolean")).response(200, new Response().description("Ok").schema(new ArrayProperty(new RefProperty(resourceType.name())))).produces("application/json")));
final List<String> path = resourceType.path();
final List<String> newPath = new ArrayList<>();
for (String s : path) {
newPath.add(s + "_name");
List<Parameter> parameterList = new ArrayList<>();
PathParameter parameterConnection = new PathParameter().required(true).type("string").name("connection_name");
parameterConnection.setDefaultValue(connectionName);
parameterList.add(parameterConnection);
for (String s1 : newPath) {
final PathParameter pathParameter = new PathParameter().required(true).type("string").name(s1);
pathParameter.setDefaultValue("*");
parameterList.add(pathParameter);
}
Operation operation = new Operation();
operation.setParameters(parameterList);
operation.parameter(new QueryParameter().name("select").type("string"));
operation.parameter(new QueryParameter().name("distinct").type("boolean"));
operation.parameter(new QueryParameter().name("where").type("string"));
operation.parameter(new QueryParameter().name("page").type("string").description("get page by mask [page_count:page_size]"));
operation.parameter(new QueryParameter().name("limit").type("integer"));
operation.parameter(new QueryParameter().name("orderby").type("string"));
operation.parameter(new QueryParameter().name("cache").type("boolean"));
swagger.path("/api/{connection_name}/headers/" + resourceType.name() + "/" + newPath.stream().map(v -> "{" + v + "}").collect(joining(".")), new Path().get(operation.description(resourceType.name()).tag("db_objects").response(200, new Response().description("Ok").schema(new ArrayProperty(new RefProperty(resourceType.name())))).produces("application/json")));
}
}
// definitions
for (ResourceType resourceType : resourceTypes) {
ModelImpl model = new ModelImpl();
Map<String, String> stringStringMap = resourceType.metaData();
if (stringStringMap != null) {
Set<Entry<String, String>> entries = stringStringMap.entrySet();
for (Entry<String, String> stringStringEntry : entries) {
model.property(stringStringEntry.getKey(), new StringProperty().description(stringStringEntry.getValue()));
}
}
swagger.model(resourceType.name(), model);
}
return swagger;
}
Aggregations