Search in sources :

Example 1 with Oas30Operation

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;
}
Also used : Oas30RequestBody(io.apicurio.datamodels.openapi.v3.models.Oas30RequestBody) Oas30Operation(io.apicurio.datamodels.openapi.v3.models.Oas30Operation)

Example 2 with Oas30Operation

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;
}
Also used : Oas30Operation(io.apicurio.datamodels.openapi.v3.models.Oas30Operation)

Example 3 with Oas30Operation

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);
}
Also used : Oas30Server(io.apicurio.datamodels.openapi.v3.models.Oas30Server) Oas30Callback(io.apicurio.datamodels.openapi.v3.models.Oas30Callback) Oas30Operation(io.apicurio.datamodels.openapi.v3.models.Oas30Operation)

Example 4 with Oas30Operation

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);
}
Also used : Oas30Responses(io.apicurio.datamodels.openapi.v3.models.Oas30Responses) Oas30Operation(io.apicurio.datamodels.openapi.v3.models.Oas30Operation)

Example 5 with Oas30Operation

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);
}
Also used : Oas30Server(io.apicurio.datamodels.openapi.v3.models.Oas30Server) Oas30ServerVariable(io.apicurio.datamodels.openapi.v3.models.Oas30ServerVariable) Oas20Operation(io.apicurio.datamodels.openapi.v2.models.Oas20Operation) Oas30PathItem(io.apicurio.datamodels.openapi.v3.models.Oas30PathItem) Oas30Operation(io.apicurio.datamodels.openapi.v3.models.Oas30Operation)

Aggregations

Oas30Operation (io.apicurio.datamodels.openapi.v3.models.Oas30Operation)27 Oas30Document (io.apicurio.datamodels.openapi.v3.models.Oas30Document)19 Oas30PathItem (io.apicurio.datamodels.openapi.v3.models.Oas30PathItem)18 Test (org.junit.Test)16 Oas30Parameter (io.apicurio.datamodels.openapi.v3.models.Oas30Parameter)14 OpenApiModelInfo (io.syndesis.server.api.generator.openapi.OpenApiModelInfo)10 Oas30MediaType (io.apicurio.datamodels.openapi.v3.models.Oas30MediaType)9 Oas30Response (io.apicurio.datamodels.openapi.v3.models.Oas30Response)6 Oas30Schema (io.apicurio.datamodels.openapi.v3.models.Oas30Schema)5 Violation (io.syndesis.common.model.Violation)5 Oas30ParameterDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30ParameterDefinition)4 Oas30RequestBody (io.apicurio.datamodels.openapi.v3.models.Oas30RequestBody)4 Oas30Server (io.apicurio.datamodels.openapi.v3.models.Oas30Server)4 OasPathItem (io.apicurio.datamodels.openapi.models.OasPathItem)3 OasResponse (io.apicurio.datamodels.openapi.models.OasResponse)2 Oas30Components (io.apicurio.datamodels.openapi.v3.models.Oas30Components)2 Oas30SchemaDefinition (io.apicurio.datamodels.openapi.v3.models.Oas30SchemaDefinition)2 DataShapeGenerator (io.syndesis.server.api.generator.openapi.DataShapeGenerator)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2