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


Java FormParameter类代码示例

本文整理汇总了Java中io.swagger.models.parameters.FormParameter的典型用法代码示例。如果您正苦于以下问题:Java FormParameter类的具体用法?Java FormParameter怎么用?Java FormParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FormParameter类属于io.swagger.models.parameters包,在下文中一共展示了FormParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initConverters

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
private static void initConverters() {
  // inner converters
  for (Class<? extends Property> propertyCls : PROPERTY_MAP.keySet()) {
    addInnerConverter(propertyCls);
  }

  converterMap.put(RefProperty.class, new RefPropertyConverter());
  converterMap.put(ArrayProperty.class, new ArrayPropertyConverter());
  converterMap.put(MapProperty.class, new MapPropertyConverter());
  converterMap.put(StringProperty.class, new StringPropertyConverter());
  converterMap.put(ObjectProperty.class, new ObjectPropertyConverter());

  converterMap.put(ModelImpl.class, new ModelImplConverter());
  converterMap.put(RefModel.class, new RefModelConverter());
  converterMap.put(ArrayModel.class, new ArrayModelConverter());

  converterMap.put(BodyParameter.class, new BodyParameterConverter());

  AbstractSerializableParameterConverter converter = new AbstractSerializableParameterConverter();
  converterMap.put(QueryParameter.class, converter);
  converterMap.put(PathParameter.class, converter);
  converterMap.put(HeaderParameter.class, converter);
  converterMap.put(FormParameter.class, converter);
  converterMap.put(CookieParameter.class, converter);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:ConverterMgr.java

示例2: createParameterInstance

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
private static Parameter createParameterInstance(ApiImplicitParam paramAnnotation) {
  switch (paramAnnotation.paramType()) {
    case "path":
      return new PathParameter();
    case "query":
      return new QueryParameter();
    case "body":
      return new BodyParameter();
    case "header":
      return new HeaderParameter();
    case "form":
      return new FormParameter();
    case "cookie":
      return new CookieParameter();
    default:
      throw new Error("not support paramType " + paramAnnotation.paramType());
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:AnnotationUtils.java

示例3: testFillFormdataStringParameter

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
@Test
public void testFillFormdataStringParameter() {
	for (int i = 0; i < 100; i++) {
		SwagRequest request = new SwagRequest();

		FormParameter param = new FormParameter();
		param.setIn("formData");
		param.setType("string");
		param.setFormat("date");
		param.setName("testParam");
		param.setRequired(true);

		ParameterGenerator.fillParameter(swagger.getSwagger(), request, param, TestType.VALID);

		assertNotNull(request.getFormDataParameters());
		assertEquals(1, request.getFormDataParameters().size());
		assertTrue(request.getFormDataParameters().containsKey("testParam"));
		assertTrue(request.getFormDataParameters().get("testParam") instanceof String);
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:21,代码来源:TestParameterGenerator.java

示例4: process

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
@Override
public void process(OperationGenerator operationGenerator, int paramIdx) {
  FormParameter parameter = new FormParameter();
  parameter.setType(new FileProperty().getType());
  parameter.setName(ParamUtils.getParameterName(operationGenerator.getProviderMethod(), paramIdx));
  operationGenerator.addProviderParameter(parameter);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:MultipartFileTypeProcessor.java

示例5: testFormDataFlagTrue

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
@Test
public void testFormDataFlagTrue() {
  when(meta.getMethod()).thenReturn(ReflectUtils.findMethod(SomeRestController.class, "form"));
  when(meta.getSwaggerOperation()).thenReturn(operation);
  List<Parameter> params = Arrays.asList(new FormParameter());
  when(operation.getParameters()).thenReturn(params);

  operationMeta.init(meta);

  assertThat(operationMeta.isFormData(), is(true));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:12,代码来源:TestRestOperationMeta.java

示例6: testCreate

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
@Test
public void testCreate() {
  ParamValueProcessorCreator creator =
      ParamValueProcessorCreatorManager.INSTANCE.findValue(FormProcessorCreator.PARAMTYPE);
  FormParameter p = new FormParameter();
  p.setName("p1");

  ParamValueProcessor processor = creator.create(p, String.class);

  Assert.assertEquals(FormProcessor.class, processor.getClass());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:12,代码来源:TestFormProcessorCreator.java

示例7: readParam

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
private Parameter readParam(Swagger swagger, Type type,Class<?> cls, ApiParam param) {
	PrimitiveType fromType = PrimitiveType.fromType(type);
	final Parameter para = null == fromType ? new FormParameter() : new QueryParameter();
	Parameter parameter = ParameterProcessor.applyAnnotations(swagger, para,
			type == null ? String.class : type, null == param ? new ArrayList<Annotation>()
					: Collections.<Annotation> singletonList(param));
	if (parameter instanceof AbstractSerializableParameter) {
		final AbstractSerializableParameter<?> p = (AbstractSerializableParameter<?>) parameter;
		if (p.getType() == null) p.setType(null == fromType ? "string" : fromType.getCommonName());
		p.setRequired(p.getRequired() == true ? true : cls.isPrimitive());
	}
	return parameter;
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:14,代码来源:DubboReaderExtension.java

示例8: readImplicitParam

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
private Parameter readImplicitParam(Swagger swagger, ApiImplicitParam param) {
	PrimitiveType fromType = PrimitiveType.fromName(param.paramType());
	final Parameter p = null == fromType ? new FormParameter() : new QueryParameter();
	final Type type = ReflectionUtils.typeFromString(param.dataType());
	return ParameterProcessor.applyAnnotations(swagger, p, type == null ? String.class : type,
			Collections.<Annotation> singletonList(param));
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:8,代码来源:DubboReaderExtension.java

示例9: returnProperFormDataParam

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
@Test
public void returnProperFormDataParam() throws NoSuchMethodException {
    final Method method = getClass().getDeclaredMethod("testFormDataParamRoute", InputStream.class, Part.class);
    final List<Pair<Type, Annotation[]>> parameters = getParameters(method.getGenericParameterTypes(), method.getParameterAnnotations());

    for (final Pair<Type, Annotation[]> parameter : parameters) {
        final Type parameterType = parameter.first();
        final List<Parameter> swaggerParams = new MinijaxSwaggerExtension().extractParameters(Arrays.asList(parameter.second()),
                parameterType, new HashSet<Type>(), SwaggerExtensions.chain());
        assertEquals("file", ((FormParameter) swaggerParams.get(0)).getType());
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:13,代码来源:MinijaxSwaggerTest.java

示例10: extract

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
@Override
public Object extract(String name, Parameter parameter, RoutingContext context) {
    FormParameter formParam = (FormParameter) parameter;
    if ("file".equals(formParam.getType())) {
        for (FileUpload file : context.fileUploads()) {
            if (file.name().equals(name)) {
                return file.uploadedFileName();
            }
        }
        if(formParam.getRequired())
            throw new IllegalArgumentException("Missing required parameter: " + name);
        return null;
    } else 
        return this.extract(name, parameter, context.request().formAttributes());
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:16,代码来源:FormParameterExtractor.java

示例11: createParam

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
private Parameter createParam(String paramType) {
    if ("path".equals(paramType))
        return new PathParameter();
    else if ("query".equals(paramType))
        return new QueryParameter();
    else if ("form".equals(paramType))
        return new FormParameter();
    else if ("formData".equals(paramType))
        return new FormParameter();
    else if ("header".equals(paramType))
        return new HeaderParameter();
    else if ("body".equals(paramType))
        return new BodyParameter();
    return null;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:16,代码来源:ResourceReaderExtension.java

示例12: extractParameters

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
public List<Parameter> extractParameters(Annotation[] annotations, Type type)
{
    String defaultValue = null;

    List<Parameter> parameters = new ArrayList<>();
    Parameter parameter = null;

    for (Annotation annotation : annotations) {
        if (annotation instanceof ApiParam) {
            FormParameter qp = new FormParameter()
                    .name(((ApiParam) annotation).value());
            qp.setDefaultValue(defaultValue);
            Property schema = modelConverters.readAsProperty(type);
            if (schema != null) {
                qp.setProperty(schema);
                if (schema instanceof ArrayProperty) {
                    qp.setItems(((ArrayProperty) schema).getItems());
                }
            }
            parameter = qp;
        }
    }
    if (parameter != null) {
        parameters.add(parameter);
    }

    return parameters;
}
 
开发者ID:buremba,项目名称:netty-rest,代码行数:29,代码来源:SwaggerReader.java

示例13: toExampleJsonParameters

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
private String toExampleJsonParameters(Operation operation)
{
    if (operation.getParameters().size() == 1 && operation.getParameters().get(0).getIn().equals("body")) {
        Model model = ((BodyParameter) operation.getParameters().get(0)).getSchema();

        Map<String, Property> properties;
        if (model.getReference() != null) {
            String prefix = "#/definitions/";
            if (model.getReference().startsWith(prefix)) {
                Model model1 = swagger.getDefinitions().get(model.getReference().substring(prefix.length()));
                if (model1 instanceof ArrayModel) {
                    return prettyJson("[" + getValue(((ArrayModel) model1).getItems()) + "]");
                }
                properties = model1.getProperties();
            }
            else {
                throw new IllegalStateException();
            }
        }
        else {
            properties = model.getProperties();
        }
        return prettyJson(toExampleJsonParameters(properties));
    }

    String jsonString = "{" + operation.getParameters().stream()
            .filter(e -> e instanceof FormParameter).map(e -> "\"" + e.getName() + "\" : " + getValue((AbstractSerializableParameter) e))
            .collect(Collectors.joining(", ")) + "}";

    return prettyJson(jsonString);
}
 
开发者ID:buremba,项目名称:swagger-slate,代码行数:32,代码来源:SlateDocumentGenerator.java

示例14: shouldCreateSwaggerFile

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
@Test
public void shouldCreateSwaggerFile() throws Exception {
  Swagger swagger = new SwaggerBuilder()
      .build(null, Arrays.asList(route(fileParam("myfile", Upload.class))));
  FormParameter parameter = (FormParameter) swagger
      .getPath("/file")
      .getOperationMap()
      .get(HttpMethod.POST)
      .getParameters()
      .get(0);
  assertEquals("formData", parameter.getIn());
  assertEquals("myfile", parameter.getName());
  assertEquals("file", parameter.getType());
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:15,代码来源:Issue958.java

示例15: shouldCreateSwaggerFiles

import io.swagger.models.parameters.FormParameter; //导入依赖的package包/类
@Test
public void shouldCreateSwaggerFiles() throws Exception {
  Swagger swagger = new SwaggerBuilder()
      .build(null, Arrays.asList(route(fileParam("files", Types.listOf(Upload.class)))));
  FormParameter parameter = (FormParameter) swagger
      .getPath("/file")
      .getOperationMap()
      .get(HttpMethod.POST)
      .getParameters()
      .get(0);
  assertEquals("formData", parameter.getIn());
  assertEquals("files", parameter.getName());
  assertEquals("array", parameter.getType());
  assertEquals("file", parameter.getItems().getType());
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:16,代码来源:Issue958.java


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