当前位置: 首页>>代码示例>>Java>>正文


Java BodyParameter.setRequired方法代码示例

本文整理汇总了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;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:27,代码来源:SwaggerAssembler.java

示例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());
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:20,代码来源:TestParameterGenerator.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:RawJsonRequestBodyProcessor.java

示例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;
}
 
开发者ID:Cosium,项目名称:openapi-annotation-processor,代码行数:8,代码来源:SpringParser.java

示例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);
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:59,代码来源:PropertyBoxSwaggerExtension.java

示例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));

    }
 
开发者ID:groovylabs,项目名称:lyre,代码行数:47,代码来源:SwaggerHelper.java


注:本文中的io.swagger.models.parameters.BodyParameter.setRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。