use of io.swagger.models.parameters.BodyParameter in project java-chassis by ServiceComb.
the class OperationGenerator method processBodyBasedParameter.
protected void processBodyBasedParameter() {
List<BodyParameter> bodyParameters = collectBodyBasedParameters();
if (bodyParameters.isEmpty()) {
return;
}
if (bodyParameters.size() == 1) {
Parameter bodyParameter = bodyParameters.get(0);
replaceBodyBasedParameter(bodyParameter);
return;
}
// 将多个pending合并成一个body
mergeBodyBasedParameters(bodyParameters);
}
use of io.swagger.models.parameters.BodyParameter in project java-chassis by ServiceComb.
the class OperationGenerator method mergeBodyBasedParameters.
protected void mergeBodyBasedParameters(List<BodyParameter> bodyParameters) {
for (Parameter parameter : bodyParameters) {
swaggerParameters.remove(parameter);
}
// 将这些body包装为一个class,整体做为一个body参数
String bodyParamName = ParamUtils.generateBodyParameterName(providerMethod);
Class<?> cls = ClassUtils.getOrCreateBodyClass(this, bodyParameters);
BodyParameter bodyParameter = ParamUtils.createBodyParameter(swagger, bodyParamName, cls);
swaggerParameters.add(bodyParameter);
}
use of io.swagger.models.parameters.BodyParameter in project carbon-apimgt by wso2.
the class APIDefinitionFromSwagger20 method getDefaultBodyParameter.
private BodyParameter getDefaultBodyParameter() {
BodyParameter bodyParameter = new BodyParameter();
bodyParameter.setName("Payload");
bodyParameter.setDescription("Request Body");
bodyParameter.setRequired(false);
Model model = new ModelImpl();
Map<String, Property> properties = new HashMap<>();
Property property = new StringProperty();
properties.put("payload", property);
model.setProperties(properties);
bodyParameter.setSchema(model);
return bodyParameter;
}
use of io.swagger.models.parameters.BodyParameter 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.BodyParameter in project incubator-servicecomb-java-chassis by apache.
the class RequestBodyAnnotationProcessor method process.
@Override
public void process(Object annotation, OperationGenerator operationGenerator, int paramIdx) {
BodyParameter bodyParameter = ParamUtils.createBodyParameter(operationGenerator, paramIdx);
operationGenerator.addProviderParameter(bodyParameter);
}
Aggregations