本文整理汇总了Java中io.swagger.models.parameters.BodyParameter.setRequired方法的典型用法代码示例。如果您正苦于以下问题:Java BodyParameter.setRequired方法的具体用法?Java BodyParameter.setRequired怎么用?Java BodyParameter.setRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.models.parameters.BodyParameter
的用法示例。
在下文中一共展示了BodyParameter.setRequired方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paramBody
import io.swagger.models.parameters.BodyParameter; //导入方法依赖的package包/类
/**
* Build BodyParameter for the Route parameter of type body.
*/
private BodyParameter paramBody(List<RequestRouter.Parameter> routeParams, Route route) {
BodyParameter bodyParam = new BodyParameter();
bodyParam.setRequired(false);
Model model = new ModelImpl();
if (routeParams != null) {
Map<String, Property> properties = new HashMap<>(routeParams.size());
routeParams.stream().forEach((p) -> {
StringProperty stringProperty = new StringProperty();
stringProperty.setName(p.name);
stringProperty
.setDescription(isBlank(p.description) ? route.description : p.description);
stringProperty.setDefault(p.value);
stringProperty.setRequired(p.required);
stringProperty.setType(StringProperty.TYPE);
properties.put(p.name, stringProperty);
});
model.setProperties(properties);
}
bodyParam.setSchema(model);
return bodyParam;
}
示例2: testFillBodyStringParameter
import io.swagger.models.parameters.BodyParameter; //导入方法依赖的package包/类
@Test
public void testFillBodyStringParameter() {
for (int i = 0; i < 100; i++) {
SwagRequest request = new SwagRequest();
RefModel ref = new RefModel();
ref.set$ref("#/definitions/Pet");
BodyParameter param = new BodyParameter();
param.setIn("body");
param.setName("testParam");
param.setSchema(ref);
param.setRequired(true);
ParameterGenerator.fillParameter(swagger.getSwagger(), request, param, TestType.VALID);
assertNotNull(request.getBodyParameters());
}
}
示例3: process
import io.swagger.models.parameters.BodyParameter; //导入方法依赖的package包/类
@Override
public void process(Object annotation, OperationGenerator operationGenerator, int paramIdx) {
BodyParameter bodyParameter = ParamUtils.createBodyParameter(operationGenerator, paramIdx);
bodyParameter.setVendorExtension("x-raw-json", true);
bodyParameter.setRequired(true);
operationGenerator.addProviderParameter(bodyParameter);
}
示例4: buildBodyParameter
import io.swagger.models.parameters.BodyParameter; //导入方法依赖的package包/类
private BodyParameter buildBodyParameter(VariableElement variableElement) {
BodyParameter bodyParameter = new BodyParameter();
bodyParameter.setName(variableElement.getSimpleName().toString());
bodyParameter.setRequired(true);
bodyParameter.setSchema(new ModelImpl().type(ModelImpl.OBJECT));
return bodyParameter;
}
示例5: extractParameters
import io.swagger.models.parameters.BodyParameter; //导入方法依赖的package包/类
@Override
public List<Parameter> extractParameters(List<Annotation> annotations, Type type, Set<Type> typesToSkip,
Iterator<SwaggerExtension> chain) {
// check PropertyBox type and body parameter case
if (isBodyParameter(annotations)) {
final PropertyBoxTypeInfo pbType = PropertyBoxTypeInfo.check(type).orElse(null);
if (pbType != null) {
// check property set
final PropertySetRef aps = hasApiPropertySet(annotations);
if (aps != null) {
PropertySet<?> propertySet = PropertySetRefIntrospector.get().getPropertySet(aps);
if (propertySet != null) {
// Skip PropertyBox type
Set<Type> skip = new HashSet<>();
if (typesToSkip != null) {
skip.addAll(typesToSkip);
}
skip.add(PropertyBox.class);
skip.add(PropertyBox[].class);
// load other parameters, if any
List<Parameter> parameters = new LinkedList<>();
if (chain.hasNext()) {
List<Parameter> ps = chain.next().extractParameters(annotations, type, skip, chain);
if (ps != null) {
parameters.addAll(ps);
}
}
ApiPropertySetModel psm = hasApiPropertySetModel(annotations);
final Model model = buildPropertyBoxModel(propertySet, false,
(pbType.isContainerType() && !pbType.isMap()),
(psm != null) ? AnnotationUtils.getStringValue(psm.value()) : null,
(psm != null) ? AnnotationUtils.getStringValue(psm.description()) : null,
(psm != null) ? AnnotationUtils.getStringValue(psm.reference()) : null,
SwaggerContext.getSwagger());
BodyParameter bp = new BodyParameter();
bp.setRequired(isParameterRequired(annotations));
bp.schema(model);
Parameter parameter = ParameterProcessor.applyAnnotations(new Swagger(), bp, type, annotations);
if (parameter != null) {
if (parameter instanceof BodyParameter) {
((BodyParameter) parameter).schema(model);
}
parameters.add(parameter);
}
return parameters;
}
}
}
}
return super.extractParameters(annotations, type, typesToSkip, chain);
}
示例6: buildEndpointServices
import io.swagger.models.parameters.BodyParameter; //导入方法依赖的package包/类
private void buildEndpointServices(Swagger swagger) {
BodyParameter bodyParameter = new BodyParameter().name("Body").description("Endpoint entity");
bodyParameter.setRequired(true);
// GET
Operation get = new Operation();
get.addParameter(new QueryParameter().name("method").required(true).description("Endpoint method").type("string"));
get.addParameter(new QueryParameter().name("path").required(true).description("Endpoint path").type("string"));
get.addResponse("200", resp().description("Requested endpoint"));
get.addResponse("400", resp().description("Malformed parameters"));
get.addResponse("404", resp().description("Bundle is empty"));
get.addResponse("404", resp().description("Endpoint does not exist"));
get.tag("1 : Endpoint Management");
//DELETE
Operation delete = new Operation();
delete.addParameter(new QueryParameter().name("method").required(true).description("Endpoint method").type("string"));
delete.addParameter(new QueryParameter().name("path").required(true).description("Endpoint path").type("string"));
delete.addResponse("200", resp().description("Attempting to delete endpoint"));
delete.addResponse("400", resp().description("Malformed parameters"));
delete.tag("5 : Danger Zone");
//POST
Operation post = new Operation();
post.addParameter(bodyParameter);
post.addResponse("200", resp().description("Update a existing endpoint"));
post.addResponse("400", resp().description("Malformed endpoint entity"));
post.addResponse("404", resp().description("Endpoint does not exist"));
post.tag("1 : Endpoint Management");
//PUT
Operation put = new Operation();
put.addParameter(bodyParameter);
put.addResponse("200", resp().description("Add new endpoint or update it"));
put.addResponse("400", resp().description("Malformed endpoint entity"));
put.tag("1 : Endpoint Management");
swagger.path("/endpoint", new Path()
.set("delete", delete)
.set("get", get)
.set("post", post)
.set("put", put));
}