Search in sources :

Example 1 with OasSchema

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

the class DeleteAllChildSchemasCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[DeleteAllChildSchemasCommand] Reverting.");
    if (this.isNullOrUndefined(this._oldSchemas) || this._oldSchemas.size() == 0) {
        return;
    }
    OasSchema schema = (OasSchema) this._schemaPath.resolve(document);
    if (this.isNullOrUndefined(schema)) {
        return;
    }
    this.copySchemaJsTo(_oldSchemas, schema, _childSchemaType);
}
Also used : OasSchema(io.apicurio.datamodels.openapi.models.OasSchema)

Example 2 with OasSchema

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

the class ChangeSchemaInheritanceCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[ChangeSchemaInheritanceCommand] Reverting: " + this._oldInheritanceType);
    OasSchema schema = (OasSchema) this._schemaPath.resolve(document);
    if (this.isNullOrUndefined(schema)) {
        return;
    }
    switchInheritance(schema, this._newInheritanceType, this._oldInheritanceType, true);
    // model might have had are lost.
    if (NodeCompat.equals(TYPE_NONE, this._newInheritanceType) && !this._oldSchemas.isEmpty()) {
        copySchemaJsTo(this._oldSchemas, schema, this._oldInheritanceType);
    }
}
Also used : OasSchema(io.apicurio.datamodels.openapi.models.OasSchema)

Example 3 with OasSchema

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

the class ChangeSchemaTypeCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[ChangeSchemaTypeCommand] Reverting.");
    if (this._oldType == null) {
        return;
    }
    OasSchema schema = (OasSchema) this._schemaPath.resolve(document);
    if (this.isNullOrUndefined(schema)) {
        return;
    }
    SimplifiedTypeUtil.setSimplifiedType((OasSchema) schema, this._oldType);
}
Also used : OasSchema(io.apicurio.datamodels.openapi.models.OasSchema)

Example 4 with OasSchema

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

the class DeleteChildSchemaCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[DeleteChildSchemaCommand] Reverting.");
    if (this.isNullOrUndefined(this._oldSchema)) {
        return;
    }
    OasSchema parent = (OasSchema) this._parentPath.resolve(document);
    if (this.isNullOrUndefined(parent)) {
        return;
    }
    // Create the schema and unmarshal it from the saved JSON data
    OasSchema schema = this.createSchema(parent, this._oldSchemaType);
    Library.readNode(this._oldSchema, schema);
    // Add the schema back to the parent
    SchemaAdderVisitor schemaAdder = new SchemaAdderVisitor();
    Library.visitNode(schema, schemaAdder);
}
Also used : OasSchema(io.apicurio.datamodels.openapi.models.OasSchema)

Example 5 with OasSchema

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

the class DeleteChildSchemaCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[DeleteChildSchemaCommand] Executing.");
    this._oldSchema = null;
    OasSchema childSchema = (OasSchema) this._schemaPath.resolve(document);
    if (this.isNullOrUndefined(childSchema)) {
        return;
    }
    // Remove the schema from its parent
    SchemaRemoverVisitor schemaRemover = new SchemaRemoverVisitor();
    Library.visitNode(childSchema, schemaRemover);
    this._oldSchema = Library.writeNode(childSchema);
    this._oldSchemaType = schemaRemover.type;
}
Also used : OasSchema(io.apicurio.datamodels.openapi.models.OasSchema)

Aggregations

OasSchema (io.apicurio.datamodels.openapi.models.OasSchema)46 Map (java.util.Map)10 OasResponse (io.apicurio.datamodels.openapi.models.OasResponse)4 Oas30Schema (io.apicurio.datamodels.openapi.v3.models.Oas30Schema)4 ArrayList (java.util.ArrayList)4 OasParameter (io.apicurio.datamodels.openapi.models.OasParameter)3 List (java.util.List)3 Element (org.dom4j.Element)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 TestContext (com.consol.citrus.context.TestContext)2 Node (io.apicurio.datamodels.core.models.Node)2 OasOperation (io.apicurio.datamodels.openapi.models.OasOperation)2 OasPathItem (io.apicurio.datamodels.openapi.models.OasPathItem)2 OasXML (io.apicurio.datamodels.openapi.models.OasXML)2 Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)2