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;
}
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;
}
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());
}
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);
}
}
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;
}
Aggregations