Search in sources :

Example 1 with ServerVariableImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariableImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiParser method readServerVariable.

/**
 * Reads a list of {@link ServerVariable} OpenAPI nodes.
 * @param node
 */
private ServerVariable readServerVariable(JsonNode node) {
    if (node == null) {
        return null;
    }
    ServerVariableImpl model = new ServerVariableImpl();
    JsonNode enumNode = node.get(OpenApiConstants.PROP_ENUM);
    if (enumNode != null && enumNode.isArray()) {
        List<String> enums = new ArrayList<>(enumNode.size());
        for (JsonNode n : enumNode) {
            enums.add(n.asText());
        }
        model.setEnumeration(enums);
    }
    model.setDefaultValue(JsonUtil.stringProperty(node, OpenApiConstants.PROP_DEFAULT));
    model.setDescription(JsonUtil.stringProperty(node, OpenApiConstants.PROP_DESCRIPTION));
    readExtensions(node, model);
    return model;
}
Also used : ServerVariableImpl(org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariableImpl) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 2 with ServerVariableImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariableImpl 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)

Aggregations

ServerVariableImpl (org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariableImpl)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayList (java.util.ArrayList)1 ServerVariable (org.eclipse.microprofile.openapi.models.servers.ServerVariable)1