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);
}
}
}
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);
}
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;
}
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);
}
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;
}
Aggregations