Search in sources :

Example 1 with ServerVariable

use of org.eclipse.microprofile.openapi.models.servers.ServerVariable in project wildfly-swarm by wildfly-swarm.

the class OpenApiParser method readServerVariables.

/**
 * Reads the {@link ServerVariables} OpenAPI node.
 * @param node
 */
private ServerVariables readServerVariables(JsonNode node) {
    if (node == null) {
        return null;
    }
    ServerVariablesImpl model = new ServerVariablesImpl();
    for (Iterator<String> iterator = node.fieldNames(); iterator.hasNext(); ) {
        String fieldName = iterator.next();
        if (!fieldName.toLowerCase().startsWith(OpenApiConstants.EXTENSION_PROPERTY_PREFIX)) {
            JsonNode varNode = node.get(fieldName);
            ServerVariable varModel = readServerVariable(varNode);
            model.put(fieldName, varModel);
        }
    }
    readExtensions(node, model);
    return model;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ServerVariablesImpl(org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariablesImpl) ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable)

Example 2 with ServerVariable

use of org.eclipse.microprofile.openapi.models.servers.ServerVariable in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method readServerVariable.

/**
 * Reads a single ServerVariable annotation.
 * @param serverVariableAnno
 */
private ServerVariable readServerVariable(AnnotationInstance serverVariableAnno) {
    if (serverVariableAnno == null) {
        return null;
    }
    LOG.debug("Processing a single @ServerVariable annotation.");
    ServerVariable variable = new ServerVariableImpl();
    variable.setDescription(JandexUtil.stringValue(serverVariableAnno, OpenApiConstants.PROP_DESCRIPTION));
    variable.setEnumeration(JandexUtil.stringListValue(serverVariableAnno, OpenApiConstants.PROP_ENUMERATION));
    variable.setDefaultValue(JandexUtil.stringValue(serverVariableAnno, OpenApiConstants.PROP_DEFAULT_VALUE));
    return variable;
}
Also used : ServerVariableImpl(org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariableImpl) ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable)

Example 3 with ServerVariable

use of org.eclipse.microprofile.openapi.models.servers.ServerVariable in project wildfly-swarm by wildfly-swarm.

the class FilterUtil method filterServerVariables.

/**
 * Filters the given model.
 * @param filter
 * @param model
 */
private static void filterServerVariables(OASFilter filter, ServerVariables model) {
    if (model == null) {
        return;
    }
    Collection<String> keys = new ArrayList<>(model.keySet());
    for (String key : keys) {
        ServerVariable childModel = model.get(key);
        filterServerVariable(filter, childModel);
    }
    filterExtensions(filter, model.getExtensions());
}
Also used : ArrayList(java.util.ArrayList) ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable)

Example 4 with ServerVariable

use of org.eclipse.microprofile.openapi.models.servers.ServerVariable in project Payara by payara.

the class ServerImpl method merge.

public static void merge(String serverVariableName, ServerVariable from, Map<String, ServerVariable> to, boolean override) {
    if (from == null) {
        return;
    }
    org.eclipse.microprofile.openapi.models.servers.ServerVariable variable = new ServerVariableImpl();
    variable.setDefaultValue(mergeProperty(variable.getDefaultValue(), from.getDefaultValue(), override));
    variable.setDescription(mergeProperty(variable.getDescription(), from.getDescription(), override));
    if (from.getEnumeration() != null && !from.getEnumeration().isEmpty()) {
        if (variable.getEnumeration() == null) {
            variable.setEnumeration(createList());
        }
        for (String value : from.getEnumeration()) {
            variable.addEnumeration(value);
        }
    }
    if ((to.containsKey(serverVariableName) && override) || !to.containsKey(serverVariableName)) {
        to.put(serverVariableName, variable);
    }
}
Also used : ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable)

Example 5 with ServerVariable

use of org.eclipse.microprofile.openapi.models.servers.ServerVariable in project Payara by payara.

the class ServerVariableImpl method createInstance.

@SuppressWarnings("unchecked")
public static ServerVariable createInstance(AnnotationModel annotation, ApiContext context) {
    ServerVariable from = new ServerVariableImpl();
    from.setDescription(annotation.getValue("description", String.class));
    from.setDefaultValue(annotation.getValue("defaultValue", String.class));
    List<String> enumeration = annotation.getValue("enumeration", List.class);
    if (enumeration != null) {
        from.setEnumeration(enumeration);
    }
    return from;
}
Also used : ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable)

Aggregations

ServerVariable (org.eclipse.microprofile.openapi.models.servers.ServerVariable)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 CallbackImpl (fish.payara.microprofile.openapi.impl.model.callbacks.CallbackImpl)1 ExampleImpl (fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl)1 HeaderImpl (fish.payara.microprofile.openapi.impl.model.headers.HeaderImpl)1 ContactImpl (fish.payara.microprofile.openapi.impl.model.info.ContactImpl)1 InfoImpl (fish.payara.microprofile.openapi.impl.model.info.InfoImpl)1 LicenseImpl (fish.payara.microprofile.openapi.impl.model.info.LicenseImpl)1 LinkImpl (fish.payara.microprofile.openapi.impl.model.links.LinkImpl)1 ContentImpl (fish.payara.microprofile.openapi.impl.model.media.ContentImpl)1 DiscriminatorImpl (fish.payara.microprofile.openapi.impl.model.media.DiscriminatorImpl)1 EncodingImpl (fish.payara.microprofile.openapi.impl.model.media.EncodingImpl)1 MediaTypeImpl (fish.payara.microprofile.openapi.impl.model.media.MediaTypeImpl)1 SchemaImpl (fish.payara.microprofile.openapi.impl.model.media.SchemaImpl)1 XMLImpl (fish.payara.microprofile.openapi.impl.model.media.XMLImpl)1 ParameterImpl (fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl)1 RequestBodyImpl (fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl)1 APIResponseImpl (fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl)1 APIResponsesImpl (fish.payara.microprofile.openapi.impl.model.responses.APIResponsesImpl)1 OAuthFlowImpl (fish.payara.microprofile.openapi.impl.model.security.OAuthFlowImpl)1