use of io.apicurio.datamodels.openapi.v2.models.Oas20Document 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.Oas20Document 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.Oas20Document in project apicurio-data-models by Apicurio.
the class DeleteResponseDefinitionCommand_20 method doDeleteResponseDefinition.
/**
* @see io.apicurio.datamodels.cmd.commands.DeleteResponseDefinitionCommand#doDeleteResponseDefinition(io.apicurio.datamodels.core.models.Document)
*/
@Override
protected Object doDeleteResponseDefinition(Document document) {
Oas20Document doc20 = (Oas20Document) document;
Oas20ResponseDefinitions responses = doc20.responses;
if (this.isNullOrUndefined(responses) || ModelUtils.isNullOrUndefined(responses.getResponse(this._definitionName))) {
return null;
}
Oas20ResponseDefinition schemaDef = responses.removeResponse(this._definitionName);
return Library.writeNode(schemaDef);
}
use of io.apicurio.datamodels.openapi.v2.models.Oas20Document in project apicurio-data-models by Apicurio.
the class DeleteSchemaDefinitionCommand_20 method doRestoreSchemaDefinition.
/**
* @see io.apicurio.datamodels.cmd.commands.DeleteSchemaDefinitionCommand#doRestoreSchemaDefinition(io.apicurio.datamodels.core.models.Document, java.lang.Object)
*/
@Override
protected void doRestoreSchemaDefinition(Document document, Object oldDefinition) {
Oas20Document doc20 = (Oas20Document) document;
Oas20Definitions definitions = doc20.definitions;
if (this.isNullOrUndefined(definitions)) {
return;
}
Oas20SchemaDefinition definition = doc20.definitions.createSchemaDefinition(this._definitionName);
Library.readNode(oldDefinition, definition);
definitions.addDefinition(this._definitionName, definition);
}
use of io.apicurio.datamodels.openapi.v2.models.Oas20Document in project apicurio-data-models by Apicurio.
the class NewSchemaDefinitionCommand_20 method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[NewDefinitionCommand] Executing.");
Oas20Document doc20 = (Oas20Document) document;
if (this.isNullOrUndefined(doc20.definitions)) {
doc20.definitions = doc20.createDefinitions();
this._nullDefinitions = true;
}
if (this.isNullOrUndefined(doc20.definitions.getDefinition(this._newDefinitionName))) {
Oas20SchemaDefinition definition;
if (!this.isNullOrUndefined(this._newDefinitionExample)) {
definition = (Oas20SchemaDefinition) OasSchemaFactory.createSchemaDefinitionFromExample(doc20, this._newDefinitionName, this._newDefinitionExample);
definition.example = this._newDefinitionExample;
} else {
definition = doc20.definitions.createSchemaDefinition(this._newDefinitionName);
definition.type = "object";
}
if (ModelUtils.isDefined(this._newDefinitionDescription)) {
definition.description = this._newDefinitionDescription;
}
doc20.definitions.addDefinition(this._newDefinitionName, definition);
this._defExisted = false;
} else {
this._defExisted = true;
}
}
Aggregations