use of org.wildfly.swarm.microprofile.openapi.api.models.security.SecurityRequirementImpl in project wildfly-swarm by wildfly-swarm.
the class OpenApiParser method readSecurityRequirement.
/**
* Reads a {@link APIResponses} OpenAPI node.
* @param node
*/
private SecurityRequirement readSecurityRequirement(JsonNode node) {
if (node == null || !node.isObject()) {
return null;
}
SecurityRequirementImpl model = new SecurityRequirementImpl();
for (Iterator<String> fieldNames = node.fieldNames(); fieldNames.hasNext(); ) {
String fieldName = fieldNames.next();
JsonNode scopesNode = node.get(fieldName);
List<String> scopes = readStringArray(scopesNode);
if (scopes == null) {
model.addScheme(fieldName);
} else {
model.addScheme(fieldName, scopes);
}
}
return model;
}
use of org.wildfly.swarm.microprofile.openapi.api.models.security.SecurityRequirementImpl in project wildfly-swarm by wildfly-swarm.
the class OpenApiAnnotationScanner method readSecurityRequirement.
/**
* Reads a single SecurityRequirement annotation.
* @param annotation
*/
private SecurityRequirement readSecurityRequirement(AnnotationInstance annotation) {
String name = JandexUtil.stringValue(annotation, OpenApiConstants.PROP_NAME);
if (name != null) {
List<String> scopes = JandexUtil.stringListValue(annotation, OpenApiConstants.PROP_SCOPES);
SecurityRequirement requirement = new SecurityRequirementImpl();
if (scopes == null) {
requirement.addScheme(name);
} else {
requirement.addScheme(name, scopes);
}
return requirement;
}
return null;
}
Aggregations