Search in sources :

Example 16 with Parameter

use of org.eclipse.microprofile.openapi.models.parameters.Parameter in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method readParameter.

/**
 * Reads a Parameter annotation into a model.
 * @param annotation
 */
private Parameter readParameter(AnnotationInstance annotation) {
    if (annotation == null) {
        return null;
    }
    LOG.debug("Processing a single @Link annotation.");
    // Params can be hidden. Skip if that's the case.
    Boolean isHidden = JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_HIDDEN);
    if (isHidden != null && isHidden == Boolean.TRUE) {
        return null;
    }
    Parameter parameter = new ParameterImpl();
    parameter.setName(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_NAME));
    parameter.setIn(JandexUtil.enumValue(annotation, OpenApiConstants.PROP_IN, org.eclipse.microprofile.openapi.models.parameters.Parameter.In.class));
    parameter.setDescription(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_DESCRIPTION));
    parameter.setRequired(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_REQUIRED));
    parameter.setDeprecated(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_DEPRECATED));
    parameter.setAllowEmptyValue(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_ALLOW_EMPTY_VALUE));
    parameter.setStyle(JandexUtil.enumValue(annotation, OpenApiConstants.PROP_STYLE, org.eclipse.microprofile.openapi.models.parameters.Parameter.Style.class));
    parameter.setExplode(readExplode(JandexUtil.enumValue(annotation, OpenApiConstants.PROP_EXPLODE, org.eclipse.microprofile.openapi.annotations.enums.Explode.class)));
    parameter.setAllowReserved(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_ALLOW_RESERVED));
    parameter.setSchema(readSchema(annotation.value(OpenApiConstants.PROP_SCHEMA)));
    parameter.setContent(readContent(annotation.value(OpenApiConstants.PROP_CONTENT), ContentDirection.Parameter));
    parameter.setExamples(readExamples(annotation.value(OpenApiConstants.PROP_EXAMPLES)));
    parameter.setExample(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_EXAMPLE));
    parameter.setRef(JandexUtil.refValue(annotation, RefType.Parameter));
    return parameter;
}
Also used : ParameterImpl(org.wildfly.swarm.microprofile.openapi.api.models.parameters.ParameterImpl) In(org.eclipse.microprofile.openapi.models.parameters.Parameter.In) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter)

Example 17 with Parameter

use of org.eclipse.microprofile.openapi.models.parameters.Parameter in project wildfly-swarm by wildfly-swarm.

the class OpenApiParser method readParameterList.

/**
 * Reads a {@link Parameter} OpenAPI node.
 * @param node
 */
private List<Parameter> readParameterList(JsonNode node) {
    if (node == null || !node.isArray()) {
        return null;
    }
    List<Parameter> params = new ArrayList<>();
    ArrayNode arrayNode = (ArrayNode) node;
    for (JsonNode paramNode : arrayNode) {
        params.add(readParameter(paramNode));
    }
    return params;
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 18 with Parameter

use of org.eclipse.microprofile.openapi.models.parameters.Parameter in project wildfly-swarm by wildfly-swarm.

the class OpenApiSerializer method writeParameterList.

/**
 * Writes a list of {@link Parameter} to the JSON tree.
 * @param parent
 * @param models
 */
private void writeParameterList(ObjectNode parent, List<Parameter> models) {
    if (models == null) {
        return;
    }
    ArrayNode node = parent.putArray(OpenApiConstants.PROP_PARAMETERS);
    for (Parameter model : models) {
        ObjectNode paramNode = node.addObject();
        writeParameterToNode(paramNode, model);
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 19 with Parameter

use of org.eclipse.microprofile.openapi.models.parameters.Parameter in project wildfly-swarm by wildfly-swarm.

the class FilterUtil method filterParameters.

/**
 * Filters the given models.
 * @param filter
 * @param models
 */
private static void filterParameters(OASFilter filter, Map<String, Parameter> models) {
    if (models == null) {
        return;
    }
    Collection<String> keys = new ArrayList<>(models.keySet());
    for (String key : keys) {
        Parameter model = models.get(key);
        filterParameter(filter, model);
        if (filter.filterParameter(model) == null) {
            models.remove(key);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter)

Aggregations

Parameter (org.eclipse.microprofile.openapi.models.parameters.Parameter)19 SchemaImpl (fish.payara.microprofile.openapi.impl.model.media.SchemaImpl)7 ParameterImpl (fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl)5 RequestBodyImpl (fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl)5 Operation (org.eclipse.microprofile.openapi.models.Operation)5 MediaType (org.eclipse.microprofile.openapi.models.media.MediaType)5 Schema (org.eclipse.microprofile.openapi.models.media.Schema)5 APIResponse (org.eclipse.microprofile.openapi.models.responses.APIResponse)5 ArrayList (java.util.ArrayList)4 Callback (org.eclipse.microprofile.openapi.models.callbacks.Callback)4 RequestBody (org.eclipse.microprofile.openapi.models.parameters.RequestBody)4 CallbackImpl (fish.payara.microprofile.openapi.impl.model.callbacks.CallbackImpl)3 APIResponseImpl (fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl)3 SecuritySchemeImpl (fish.payara.microprofile.openapi.impl.model.security.SecuritySchemeImpl)3 LinkedHashMap (java.util.LinkedHashMap)3 PathItem (org.eclipse.microprofile.openapi.models.PathItem)3 In (org.eclipse.microprofile.openapi.models.parameters.Parameter.In)3 APIResponses (org.eclipse.microprofile.openapi.models.responses.APIResponses)3 SecurityRequirement (org.eclipse.microprofile.openapi.models.security.SecurityRequirement)3 SecurityScheme (org.eclipse.microprofile.openapi.models.security.SecurityScheme)3