use of io.apicurio.datamodels.openapi.v3.models.Oas30ResponseDefinition in project apicurio-data-models by Apicurio.
the class DeleteResponseDefinitionCommand_30 method doRestoreResponseDefinition.
/**
* @see io.apicurio.datamodels.cmd.commands.DeleteResponseDefinitionCommand#doRestoreResponseDefinition(io.apicurio.datamodels.core.models.Document, java.lang.Object)
*/
@Override
protected void doRestoreResponseDefinition(Document document, Object oldDefinition) {
Oas30Document doc30 = (Oas30Document) document;
if (ModelUtils.isDefined(doc30.components)) {
Oas30ResponseDefinition schemaDef = doc30.components.createResponseDefinition(this._definitionName);
Library.readNode(oldDefinition, schemaDef);
doc30.components.addResponseDefinition(this._definitionName, schemaDef);
}
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30ResponseDefinition in project apicurio-data-models by Apicurio.
the class NewResponseDefinitionCommand_30 method execute.
/**
* @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void execute(Document document) {
LoggerCompat.info("[NewResponseDefinitionCommand] Executing.");
Oas30Document doc30 = (Oas30Document) document;
if (this.isNullOrUndefined(doc30.components)) {
doc30.components = doc30.createComponents();
this._nullComponents = true;
}
this._nullComponents = false;
if (this.isNullOrUndefined(doc30.components.getResponseDefinition(this._newDefinitionName))) {
Oas30ResponseDefinition definition = doc30.components.createResponseDefinition(this._newDefinitionName);
if (ModelUtils.isDefined(this._newDefinitionDescription)) {
definition.description = this._newDefinitionDescription;
}
doc30.components.addResponseDefinition(this._newDefinitionName, definition);
this._defExisted = false;
} else {
this._defExisted = true;
}
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30ResponseDefinition in project apicurio-data-models by Apicurio.
the class AddResponseDefinitionCommand_30 method addDefinition.
/**
* @see io.apicurio.datamodels.cmd.commands.AddResponseDefinitionCommand#addDefinition(io.apicurio.datamodels.openapi.models.OasDocument, io.apicurio.datamodels.openapi.models.OasResponse)
*/
@Override
protected void addDefinition(OasDocument document, OasResponse definition) {
Oas30Document doc30 = (Oas30Document) document;
doc30.components.addResponseDefinition(this._newDefinitionName, (Oas30ResponseDefinition) definition);
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30ResponseDefinition in project apicurio-data-models by Apicurio.
the class Oas30DataModelReader method readComponents.
/**
* Reads a Components model.
* @param json
* @param node
*/
public void readComponents(Object json, Oas30Components node) {
Object schemas = JsonCompat.consumeProperty(json, Constants.PROP_SCHEMAS);
Object responses = JsonCompat.consumeProperty(json, Constants.PROP_RESPONSES);
Object parameters = JsonCompat.consumeProperty(json, Constants.PROP_PARAMETERS);
Object examples = JsonCompat.consumeProperty(json, Constants.PROP_EXAMPLES);
Object requestBodies = JsonCompat.consumeProperty(json, Constants.PROP_REQUEST_BODIES);
Object headers = JsonCompat.consumeProperty(json, Constants.PROP_HEADERS);
Object securitySchemes = JsonCompat.consumeProperty(json, Constants.PROP_SECURITY_SCHEMES);
Object links = JsonCompat.consumeProperty(json, Constants.PROP_LINKS);
Object callbacks = JsonCompat.consumeProperty(json, Constants.PROP_CALLBACKS);
if (schemas != null) {
JsonCompat.keys(schemas).forEach(name -> {
Object schema = JsonCompat.consumeProperty(schemas, name);
Oas30SchemaDefinition schemaModel = node.createSchemaDefinition(name);
this.readSchema(schema, schemaModel);
node.addSchemaDefinition(name, schemaModel);
});
}
if (responses != null) {
JsonCompat.keys(responses).forEach(name -> {
Object response = JsonCompat.consumeProperty(responses, name);
Oas30ResponseDefinition responseModel = node.createResponseDefinition(name);
this.readResponse(response, responseModel);
node.addResponseDefinition(name, responseModel);
});
}
if (parameters != null) {
JsonCompat.keys(parameters).forEach(name -> {
Object parameter = JsonCompat.consumeProperty(parameters, name);
Oas30ParameterDefinition parameterModel = node.createParameterDefinition(name);
this.readParameter(parameter, parameterModel);
node.addParameterDefinition(name, parameterModel);
});
}
if (examples != null) {
JsonCompat.keys(examples).forEach(name -> {
Object example = JsonCompat.consumeProperty(examples, name);
Oas30ExampleDefinition exampleModel = node.createExampleDefinition(name);
this.readExample(example, exampleModel);
node.addExampleDefinition(name, exampleModel);
});
}
if (requestBodies != null) {
JsonCompat.keys(requestBodies).forEach(name -> {
Object requestBody = JsonCompat.consumeProperty(requestBodies, name);
Oas30RequestBodyDefinition requestBodyModel = node.createRequestBodyDefinition(name);
this.readRequestBody(requestBody, requestBodyModel);
node.addRequestBodyDefinition(name, requestBodyModel);
});
}
if (headers != null) {
JsonCompat.keys(headers).forEach(name -> {
Object header = JsonCompat.consumeProperty(headers, name);
Oas30HeaderDefinition headerModel = node.createHeaderDefinition(name);
this.readHeader(header, headerModel);
node.addHeaderDefinition(name, headerModel);
});
}
if (securitySchemes != null) {
JsonCompat.keys(securitySchemes).forEach(name -> {
Object securityScheme = JsonCompat.consumeProperty(securitySchemes, name);
Oas30SecurityScheme securitySchemeModel = node.createSecurityScheme(name);
this.readSecurityScheme(securityScheme, securitySchemeModel);
node.addSecurityScheme(name, securitySchemeModel);
});
}
if (links != null) {
JsonCompat.keys(links).forEach(name -> {
Object link = JsonCompat.consumeProperty(links, name);
Oas30LinkDefinition linkModel = node.createLinkDefinition(name);
this.readLink(link, linkModel);
node.addLinkDefinition(name, linkModel);
});
}
if (callbacks != null) {
JsonCompat.keys(callbacks).forEach(name -> {
Object callback = JsonCompat.consumeProperty(callbacks, name);
Oas30CallbackDefinition callbackModel = node.createCallbackDefinition(name);
this.readCallback(callback, callbackModel);
node.addCallbackDefinition(name, callbackModel);
});
}
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30ResponseDefinition in project apicurio-data-models by Apicurio.
the class ReplaceResponseDefinitionCommand_30 method readNode.
/**
* @see io.apicurio.datamodels.cmd.commands.ReplaceNodeCommand#readNode(io.apicurio.datamodels.core.models.Document, java.lang.Object)
*/
@Override
protected Oas30ResponseDefinition readNode(Document doc, Object node) {
Oas30Document doc30 = (Oas30Document) doc;
Oas30ResponseDefinition definition = doc30.components.createResponseDefinition(this._defName);
Library.readNode(node, definition);
return definition;
}
Aggregations