use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions in project apicurio-data-models by Apicurio.
the class DeleteSecuritySchemeCommand_20 method doDeleteScheme.
/**
* @see io.apicurio.datamodels.cmd.commands.DeleteSecuritySchemeCommand#doDeleteScheme(io.apicurio.datamodels.core.models.Document)
*/
@Override
protected Object doDeleteScheme(Document document) {
Oas20Document doc20 = (Oas20Document) document;
Oas20SecurityDefinitions definitions = doc20.securityDefinitions;
if (this.isNullOrUndefined(definitions)) {
return null;
}
return Library.writeNode(definitions.removeSecurityScheme(this._schemeName));
}
use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions in project apicurio-data-models by Apicurio.
the class DeleteSecuritySchemeCommand_20 method doRestoreScheme.
/**
* @see io.apicurio.datamodels.cmd.commands.DeleteSecuritySchemeCommand#doRestoreScheme(io.apicurio.datamodels.core.models.Document, java.lang.Object)
*/
@Override
protected void doRestoreScheme(Document document, Object oldScheme) {
Oas20Document doc20 = (Oas20Document) document;
Oas20SecurityDefinitions definitions = doc20.securityDefinitions;
if (this.isNullOrUndefined(definitions) || this.isNullOrUndefined(oldScheme)) {
return;
}
Oas20SecurityScheme scheme = definitions.createSecurityScheme(this._schemeName);
Library.readNode(oldScheme, scheme);
definitions.addSecurityScheme(this._schemeName, scheme);
}
use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions in project apicurio-data-models by Apicurio.
the class Oas20DataModelReader method readSecurityDefinitions.
/**
* Reads the security definitions.
* @param json
* @param node
*/
public void readSecurityDefinitions(Object json, Oas20SecurityDefinitions node) {
List<String> names = JsonCompat.keys(json);
for (String name : names) {
Object schemeJson = JsonCompat.consumeProperty(json, name);
Oas20SecurityScheme schemeModel = node.createSecurityScheme(name);
this.readSecurityScheme(schemeJson, schemeModel);
node.addSecurityScheme(name, schemeModel);
}
}
use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions 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