Search in sources :

Example 1 with FormDataParam

use of org.glassfish.jersey.media.multipart.FormDataParam in project swagger-core by swagger-api.

the class SwaggerJersey2Jaxrs method extractParameters.

@Override
public List<Parameter> extractParameters(final List<Annotation> annotations, final Type type, final Set<Type> typesToSkip, final Iterator<SwaggerExtension> chain) {
    List<Parameter> parameters = new ArrayList<Parameter>();
    if (shouldIgnoreType(type, typesToSkip)) {
        return parameters;
    }
    for (final Annotation annotation : annotations) {
        // just handle the jersey specific annotation
        if (annotation instanceof FormDataParam) {
            FormDataParam fd = (FormDataParam) annotation;
            if (java.io.InputStream.class.isAssignableFrom(constructType(type).getRawClass())) {
                final Parameter param = new FormParameter().type("file").name(fd.value());
                parameters.add(param);
            } else {
                final FormParameter fp = new FormParameter().name(fd.value());
                final Property schema = ModelConverters.getInstance().readAsProperty(type);
                if (schema != null) {
                    fp.setProperty(schema);
                }
                parameters.add(fp);
            }
        }
    }
    // Only call down to the other items in the chain if no parameters were produced
    if (parameters.isEmpty()) {
        parameters = super.extractParameters(annotations, type, typesToSkip, chain);
    }
    return parameters;
}
Also used : ArrayList(java.util.ArrayList) FormParameter(io.swagger.models.parameters.FormParameter) Parameter(io.swagger.models.parameters.Parameter) FormDataParam(org.glassfish.jersey.media.multipart.FormDataParam) FormParameter(io.swagger.models.parameters.FormParameter) Property(io.swagger.models.properties.Property) Annotation(java.lang.annotation.Annotation)

Aggregations

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 ArrayList (java.util.ArrayList)1 FormDataParam (org.glassfish.jersey.media.multipart.FormDataParam)1