private FormParameter extractFormParameter(Type type, String defaultValue, FormParam param) { FormParameter formParameter = new FormParameter().name(param.value()); if (!Strings.isNullOrEmpty(defaultValue)) { formParameter.setDefaultValue(defaultValue); } Property schema = ModelConverters.getInstance().readAsProperty(type); if (schema != null) { formParameter.setProperty(schema); } String parameterType = formParameter.getType(); if (parameterType == null || parameterType.equals("ref") || parameterType.equals("array")) { formParameter.setType("string"); } return formParameter; } }
@Override public void process(OperationGenerator operationGenerator, int paramIdx) { FormParameter parameter = new FormParameter(); parameter.setName(ParamUtils.getParameterName(operationGenerator.getProviderMethod(), paramIdx)); Property property = new ArrayProperty(new FileProperty()); parameter.setProperty(property); operationGenerator.addProviderParameter(parameter); } }
@Override public void process(OperationGenerator operationGenerator, int paramIdx) { FormParameter parameter = new FormParameter(); parameter.setName(ParamUtils.getParameterName(operationGenerator.getProviderMethod(), paramIdx)); Property property = new ArrayProperty(new FileProperty()); parameter.setProperty(property); operationGenerator.addProviderParameter(parameter); } }
private FormParameter extractRequestPart(Type type, RequestPart requestPart) { String paramName = StringUtils.defaultIfEmpty(requestPart.value(), requestPart.name()); FormParameter formParameter = new FormParameter().name(paramName) .required(requestPart.required()); JavaType ct = constructType(type); Property schema; if (MultipartFile.class.isAssignableFrom(ct.getRawClass())) { schema = new FileProperty(); } else if (ct.isContainerType() && MultipartFile.class.isAssignableFrom(ct.getContentType().getRawClass())) { schema = new ArrayProperty().items(new FileProperty()); } else { schema = ModelConverters.getInstance().readAsProperty(type); } if (schema != null) { formParameter.setProperty(schema); } return formParameter; }
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; }
@Override public List<Parameter> extractParameters(List<Annotation> annotations, Type type, Set<Type> typesToSkip, Iterator<SwaggerExtension> chain) { if (shouldIgnoreType(type, typesToSkip)) { // stop the processing chain return Collections.emptyList(); } for (Annotation annotation : annotations) { if (annotation instanceof FormDataParam) { final FormDataParam fd = (FormDataParam) annotation; final Class<?> cls = TypeFactory.defaultInstance().constructType(type).getRawClass(); final Parameter param; if (java.io.InputStream.class.isAssignableFrom(cls)) { param = new FormParameter().type("file").name(fd.value()); } else { FormParameter fp = new FormParameter().name(fd.value()); Property schema = ModelConverters.getInstance().readAsProperty(type); if (schema != null) { fp.setProperty(schema); } param = fp; } return Collections.singletonList(param); } } return super.extractParameters(annotations, type, typesToSkip, chain); }
Property schema = createProperty(type); if (schema != null) { fp.setProperty(schema);