use of io.apicurio.datamodels.openapi.v2.models.Oas20Scopes in project apicurio-data-models by Apicurio.
the class Oas20DataModelReader method readSecurityScheme.
/**
* @see io.apicurio.datamodels.core.io.DataModelReader#readSecurityScheme(java.lang.Object, io.apicurio.datamodels.core.models.common.SecurityScheme)
*/
public void readSecurityScheme(Object json, SecurityScheme node) {
Oas20SecurityScheme scheme = (Oas20SecurityScheme) node;
String flow = JsonCompat.consumePropertyString(json, Constants.PROP_FLOW);
String authorizationUrl = JsonCompat.consumePropertyString(json, Constants.PROP_AUTHORIZATION_URL);
String tokenUrl = JsonCompat.consumePropertyString(json, Constants.PROP_TOKEN_URL);
Object scopes = JsonCompat.consumeProperty(json, Constants.PROP_SCOPES);
scheme.flow = flow;
scheme.authorizationUrl = authorizationUrl;
scheme.tokenUrl = tokenUrl;
if (scopes != null) {
Oas20Scopes scopesModel = scheme.createScopes();
this.readScopes(scopes, scopesModel);
scheme.scopes = scopesModel;
}
super.readSecurityScheme(json, scheme);
}
use of io.apicurio.datamodels.openapi.v2.models.Oas20Scopes in project apicurio-data-models by Apicurio.
the class OasUnexpectedSecurityRequirementScopesRule method visitSecurityRequirement.
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitSecurityRequirement(io.apicurio.datamodels.core.models.common.SecurityRequirement)
*/
@Override
public void visitSecurityRequirement(SecurityRequirement node) {
List<String> snames = node.getSecurityRequirementNames();
snames.forEach(sname -> {
Oas20SecurityDefinitions sdefs = ((Oas20Document) node.ownerDocument()).securityDefinitions;
if (hasValue(sdefs)) {
Oas20SecurityScheme scheme = sdefs.getSecurityScheme(sname);
if (hasValue(scheme)) {
if (equals(scheme.type, "oauth2")) {
Oas20Scopes definedScopes = scheme.scopes;
List<String> requiredScopes = node.getScopes(sname);
this.reportIfInvalid(isValidScopes(requiredScopes, definedScopes), node, null, map("sname", sname));
}
}
}
});
}
Aggregations