Search in sources :

Example 1 with FormDataParam

use of com.sun.jersey.multipart.FormDataParam in project swagger-core by swagger-api.

the class SwaggerJerseyJaxrs method extractParameters.

@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);
}
Also used : FormParameter(io.swagger.models.parameters.FormParameter) Parameter(io.swagger.models.parameters.Parameter) FormDataParam(com.sun.jersey.multipart.FormDataParam) FormParameter(io.swagger.models.parameters.FormParameter) Property(io.swagger.models.properties.Property) Annotation(java.lang.annotation.Annotation)

Aggregations

FormDataParam (com.sun.jersey.multipart.FormDataParam)1 FormParameter (io.swagger.models.parameters.FormParameter)1 Parameter (io.swagger.models.parameters.Parameter)1 Property (io.swagger.models.properties.Property)1 Annotation (java.lang.annotation.Annotation)1