Search in sources :

Example 1 with PathParameter

use of io.swagger.v3.oas.models.parameters.PathParameter in project cxf by apache.

the class JaxRs2Extension method extractParameters.

@Override
public ResolvedParameter extractParameters(final List<Annotation> annotations, final Type type, final Set<Type> typesToSkip, final Components components, final Consumes classConsumes, final Consumes methodConsumes, final boolean includeRequestBody, final JsonView jsonViewAnnotation, final Iterator<OpenAPIExtension> chain) {
    if (shouldIgnoreType(type, typesToSkip)) {
        return new ResolvedParameter();
    }
    List<Parameter> parameters = annotations.stream().filter(annotation -> annotation instanceof MatrixParam).map(annotation -> {
        MatrixParam param = (MatrixParam) annotation;
        Parameter mp = new PathParameter().name(param.value());
        mp.setStyle(Parameter.StyleEnum.MATRIX);
        ResolvedSchema resolvedSchema = ModelConverters.getInstance().readAllAsResolvedSchema(type);
        if (resolvedSchema != null) {
            mp.setSchema(resolvedSchema.schema);
        }
        applyBeanValidatorAnnotations(mp, annotations);
        return mp;
    }).collect(Collectors.toList());
    // Only call down to the other items in the chain if no parameters were produced
    if (parameters.isEmpty()) {
        return super.extractParameters(annotations, type, typesToSkip, components, classConsumes, methodConsumes, includeRequestBody, jsonViewAnnotation, chain);
    }
    ResolvedParameter resolved = new ResolvedParameter();
    resolved.parameters = parameters;
    return resolved;
}
Also used : Size(javax.validation.constraints.Size) AbstractOpenAPIExtension(io.swagger.v3.jaxrs2.ext.AbstractOpenAPIExtension) JsonView(com.fasterxml.jackson.annotation.JsonView) ResolvedSchema(io.swagger.v3.core.converter.ResolvedSchema) Parameter(io.swagger.v3.oas.models.parameters.Parameter) DecimalMin(javax.validation.constraints.DecimalMin) HashMap(java.util.HashMap) ResolvedParameter(io.swagger.v3.jaxrs2.ResolvedParameter) BigDecimal(java.math.BigDecimal) Consumes(javax.ws.rs.Consumes) Map(java.util.Map) Max(javax.validation.constraints.Max) Schema(io.swagger.v3.oas.models.media.Schema) Iterator(java.util.Iterator) Set(java.util.Set) Min(javax.validation.constraints.Min) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) OpenAPIExtension(io.swagger.v3.jaxrs2.ext.OpenAPIExtension) ModelConverters(io.swagger.v3.core.converter.ModelConverters) List(java.util.List) Type(java.lang.reflect.Type) DecimalMax(javax.validation.constraints.DecimalMax) Annotation(java.lang.annotation.Annotation) Pattern(javax.validation.constraints.Pattern) MatrixParam(javax.ws.rs.MatrixParam) Components(io.swagger.v3.oas.models.Components) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) MatrixParam(javax.ws.rs.MatrixParam) ResolvedParameter(io.swagger.v3.jaxrs2.ResolvedParameter) Parameter(io.swagger.v3.oas.models.parameters.Parameter) ResolvedParameter(io.swagger.v3.jaxrs2.ResolvedParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) ResolvedSchema(io.swagger.v3.core.converter.ResolvedSchema) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter)

Aggregations

JsonView (com.fasterxml.jackson.annotation.JsonView)1 ModelConverters (io.swagger.v3.core.converter.ModelConverters)1 ResolvedSchema (io.swagger.v3.core.converter.ResolvedSchema)1 ResolvedParameter (io.swagger.v3.jaxrs2.ResolvedParameter)1 AbstractOpenAPIExtension (io.swagger.v3.jaxrs2.ext.AbstractOpenAPIExtension)1 OpenAPIExtension (io.swagger.v3.jaxrs2.ext.OpenAPIExtension)1 Components (io.swagger.v3.oas.models.Components)1 Schema (io.swagger.v3.oas.models.media.Schema)1 Parameter (io.swagger.v3.oas.models.parameters.Parameter)1 PathParameter (io.swagger.v3.oas.models.parameters.PathParameter)1 Annotation (java.lang.annotation.Annotation)1 Type (java.lang.reflect.Type)1 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 DecimalMax (javax.validation.constraints.DecimalMax)1