use of io.apicurio.datamodels.openapi.v3.models.Oas30Operation in project apicurio-data-models by Apicurio.
the class DeleteRequestBodyCommand method readNode.
/**
* @see io.apicurio.datamodels.cmd.commands.DeleteNodeCommand#readNode(io.apicurio.datamodels.core.models.Document,
* java.lang.Object)
*/
@Override
protected Oas30RequestBody readNode(Document doc, Object node) {
Oas30Operation operation = (Oas30Operation) this._parentPath.resolve(doc);
Oas30RequestBody requestBody = operation.createRequestBody();
Library.readNode(node, requestBody);
return requestBody;
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Operation in project apicurio-data-models by Apicurio.
the class NewRequestBodyCommand_30 method doRemoveRequestBody.
/**
* @see io.apicurio.datamodels.cmd.commands.NewRequestBodyCommand#doRemoveRequestBody(io.apicurio.datamodels.openapi.models.OasOperation)
*/
@Override
protected void doRemoveRequestBody(OasOperation operation) {
Oas30Operation op30 = (Oas30Operation) operation;
op30.requestBody = null;
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Operation in project apicurio-data-models by Apicurio.
the class Oas30DataModelReader method readOperation.
/**
* @see io.apicurio.datamodels.openapi.io.OasDataModelReader#readOperation(java.lang.Object, io.apicurio.datamodels.core.models.common.Operation)
*/
@Override
public void readOperation(Object json, Operation node) {
Oas30Operation operation = (Oas30Operation) node;
Object requestBody = JsonCompat.consumeProperty(json, Constants.PROP_REQUEST_BODY);
Object callbacks = JsonCompat.consumeProperty(json, Constants.PROP_CALLBACKS);
List<Object> servers = JsonCompat.consumePropertyArray(json, Constants.PROP_SERVERS);
if (requestBody != null) {
operation.requestBody = operation.createRequestBody();
this.readRequestBody(requestBody, operation.requestBody);
}
if (callbacks != null) {
JsonCompat.keys(callbacks).forEach(name -> {
Object callback = JsonCompat.consumeProperty(callbacks, name);
Oas30Callback callbackModel = operation.createCallback(name);
this.readCallback(callback, callbackModel);
operation.addCallback(name, callbackModel);
});
}
if (servers != null) {
servers.forEach(server -> {
Oas30Server serverModel = (Oas30Server) operation.createServer();
this.readServer(server, serverModel);
operation.addServer(serverModel);
});
}
super.readOperation(json, node);
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Operation in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method visitResponses.
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitResponses(io.apicurio.datamodels.openapi.models.OasResponses)
*/
@Override
public void visitResponses(OasResponses node) {
Oas30Operation parent30 = (Oas30Operation) this.lookup(node.parent());
Oas30Responses responses30 = (Oas30Responses) parent30.createResponses();
parent30.responses = responses30;
this.mapNode(node, responses30);
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Operation in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method visitOperation.
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitOperation(io.apicurio.datamodels.core.models.common.Operation)
*/
@Override
public void visitOperation(Operation node) {
Oas20Operation op = (Oas20Operation) node;
Oas30PathItem pathItem30 = (Oas30PathItem) this.lookup(node.parent());
Oas30Operation operation30 = (Oas30Operation) pathItem30.createOperation(node.getType());
pathItem30.setOperation(operation30);
operation30.tags = op.tags;
operation30.summary = op.summary;
operation30.description = op.description;
operation30.operationId = op.operationId;
operation30.deprecated = op.deprecated;
if (!NodeCompat.isNullOrUndefined(op.schemes) && op.schemes.size() > 0 && !NodeCompat.isNullOrUndefined(this.doc30.servers) && this.doc30.servers.size() > 0) {
Oas30Server server30 = (Oas30Server) operation30.createServer();
operation30.servers = new ArrayList<>();
operation30.servers.add(server30);
server30.url = this.doc30.servers.get(0).url;
if (op.schemes.size() == 1) {
server30.url = server30.url.replace("{scheme}", op.schemes.get(0));
server30.removeServerVariable("scheme");
} else {
server30.url = "{scheme}" + server30.url.substring(server30.url.indexOf("://"));
Oas30ServerVariable var30 = (Oas30ServerVariable) server30.createServerVariable("scheme");
server30.addServerVariable("scheme", var30);
var30.description = "The supported protocol schemes.";
var30.default_ = op.schemes.get(0);
var30.enum_ = NodeCompat.copyList(op.schemes);
}
}
// Note: consumes/produces will be handled elsewhere (when Request Body and Response models are created)
this.mapNode(op, operation30);
}
Aggregations