Search in sources :

Example 1 with OasPathItem

use of io.apicurio.datamodels.openapi.models.OasPathItem in project apicurio-data-models by Apicurio.

the class DeleteAllOperationsCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[DeleteAllOperationsCommand] Executing.");
    this._oldOperations = new ArrayList<>();
    OasPathItem parent = (OasPathItem) this._parentPath.resolve(document);
    if (this.isNullOrUndefined(parent)) {
        return;
    }
    // Save the old operations (if any)
    for (String method : ALL_METHODS) {
        OasOperation oldOp = (OasOperation) NodeCompat.getProperty(parent, method);
        if (!this.isNullOrUndefined(oldOp)) {
            Object oldOpData = JsonCompat.objectNode();
            JsonCompat.setPropertyString(oldOpData, "_method", method);
            JsonCompat.setProperty(oldOpData, "_operation", Library.writeNode(oldOp));
            this._oldOperations.add(oldOpData);
            NodeCompat.setProperty(parent, method, null);
        }
    }
}
Also used : OasOperation(io.apicurio.datamodels.openapi.models.OasOperation) OasPathItem(io.apicurio.datamodels.openapi.models.OasPathItem)

Example 2 with OasPathItem

use of io.apicurio.datamodels.openapi.models.OasPathItem in project apicurio-data-models by Apicurio.

the class NewOperationCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[NewOperationCommand] Reverting.");
    if (!this._created) {
        return;
    }
    OasDocument odoc = (OasDocument) document;
    if (this.isNullOrUndefined(odoc.paths)) {
        return;
    }
    OasPathItem path = odoc.paths.getPathItem(this._path);
    if (this.isNullOrUndefined(path)) {
        return;
    }
    NodeCompat.setProperty(path, this._method, null);
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) OasPathItem(io.apicurio.datamodels.openapi.models.OasPathItem)

Example 3 with OasPathItem

use of io.apicurio.datamodels.openapi.models.OasPathItem in project apicurio-data-models by Apicurio.

the class NewParamCommand method findOverridableParam.

/**
 * Tries to find the parameter being overridden (if any).  Returns null if it can't
 * find something.
 */
public OasParameter findOverridableParam(OasOperation operation) {
    OasParameter rval = null;
    OasPathItem pathItem = (OasPathItem) operation.parent();
    if (ModelUtils.isDefined(pathItem)) {
        rval = pathItem.getParameter(this._paramType, this._paramName);
    }
    return rval;
}
Also used : OasParameter(io.apicurio.datamodels.openapi.models.OasParameter) OasPathItem(io.apicurio.datamodels.openapi.models.OasPathItem)

Example 4 with OasPathItem

use of io.apicurio.datamodels.openapi.models.OasPathItem in project apicurio-data-models by Apicurio.

the class OasDataModelReader method readPaths.

/**
 * Read the paths.
 * @param json
 * @param node
 */
public void readPaths(Object json, OasPaths node) {
    List<String> pathNames = JsonCompat.keys(json);
    for (String pathName : pathNames) {
        if (pathName.indexOf("x-") == 0) {
            continue;
        }
        Object pathItem = JsonCompat.consumeProperty(json, pathName);
        OasPathItem pathItemModel = node.createPathItem(pathName);
        this.readPathItem(pathItem, pathItemModel);
        node.addPathItem(pathName, pathItemModel);
    }
    this.readExtensions(json, node);
    this.readExtraProperties(json, node);
}
Also used : OasPathItem(io.apicurio.datamodels.openapi.models.OasPathItem)

Example 5 with OasPathItem

use of io.apicurio.datamodels.openapi.models.OasPathItem in project apicurio-data-models by Apicurio.

the class ReplacePathItemCommand method readNode.

/**
 * @see io.apicurio.datamodels.cmd.commands.ReplaceNodeCommand#readNode(io.apicurio.datamodels.core.models.Document, java.lang.Object)
 */
@Override
protected OasPathItem readNode(Document doc, Object node) {
    OasDocument odoc = (OasDocument) doc;
    OasPathItem pathItem = odoc.paths.createPathItem(this._pathName);
    Library.readNode(node, pathItem);
    return pathItem;
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) OasPathItem(io.apicurio.datamodels.openapi.models.OasPathItem)

Aggregations

OasPathItem (io.apicurio.datamodels.openapi.models.OasPathItem)31 OasDocument (io.apicurio.datamodels.openapi.models.OasDocument)13 OasOperation (io.apicurio.datamodels.openapi.models.OasOperation)12 Map (java.util.Map)10 OasParameter (io.apicurio.datamodels.openapi.models.OasParameter)7 OasPaths (io.apicurio.datamodels.openapi.models.OasPaths)4 Violation (io.syndesis.common.model.Violation)4 List (java.util.List)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 OasResponse (io.apicurio.datamodels.openapi.models.OasResponse)3 OasSchema (io.apicurio.datamodels.openapi.models.OasSchema)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Citrus (com.consol.citrus.Citrus)2 CitrusSettings (com.consol.citrus.CitrusSettings)2 TestCaseRunner (com.consol.citrus.TestCaseRunner)2 CitrusAnnotations (com.consol.citrus.annotations.CitrusAnnotations)2 CitrusFramework (com.consol.citrus.annotations.CitrusFramework)2 CitrusResource (com.consol.citrus.annotations.CitrusResource)2