Search in sources :

Example 6 with Tag

use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.

the class Oas20to30TransformationVisitor method visitTag.

/**
 * @see io.apicurio.datamodels.core.visitors.IVisitor#visitTag(io.apicurio.datamodels.core.models.common.Tag)
 */
@Override
public void visitTag(Tag node) {
    Oas30Document parent30 = this.doc30;
    Tag tag30 = parent30.addTag(node.name, node.description);
    this.mapNode(node, tag30);
}
Also used : Oas30Document(io.apicurio.datamodels.openapi.v3.models.Oas30Document) Tag(io.apicurio.datamodels.core.models.common.Tag)

Example 7 with Tag

use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.

the class RenameTagDefinitionCommand method _doTagRename.

/**
 * Does the work of renaming a tag from one name to another.
 * @param document
 * @param from
 * @param to
 * @private
 */
private void _doTagRename(Document document, String from, String to) {
    // If the "to" tag already exists, bail out before doing anything
    Tag existingTag = this._findTag(document, to);
    if (ModelUtils.isDefined(existingTag)) {
        return;
    }
    // Find the tag by name and rename it.
    Tag tagToRename = this._findTag(document, from);
    if (ModelUtils.isDefined(tagToRename)) {
        // Now rename the tag
        tagToRename.name = to;
        // Rename every **usage** of the tag in the document (all operations)
        IVisitor tagRenamer = new TagRenameVisitor(from, to);
        VisitorUtil.visitTree(document, tagRenamer, TraverserDirection.down);
    }
}
Also used : IVisitor(io.apicurio.datamodels.core.visitors.IVisitor) Tag(io.apicurio.datamodels.core.models.common.Tag)

Example 8 with Tag

use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.

the class DeleteTagCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[DeleteTagCommand] Executing.");
    if (this.isNullOrUndefined(document.tags)) {
        return;
    }
    List<Tag> tags = document.tags;
    Tag tag = null;
    for (Tag t : tags) {
        if (NodeCompat.equals(t.name, this._tagName)) {
            tag = t;
        }
    }
    this._oldIndex = tags.indexOf(tag);
    tags.remove(this._oldIndex);
    this._oldTag = Library.writeNode(tag);
}
Also used : Tag(io.apicurio.datamodels.core.models.common.Tag)

Example 9 with Tag

use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.

the class NewTagCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[NewTagCommand] Executing.");
    this._created = false;
    if (this.isNullOrUndefined(document.tags)) {
        document.tags = new ArrayList<>();
    }
    Tag tag = this.findTag(document, this._tagName);
    if (this.isNullOrUndefined(tag)) {
        document.addTag(this._tagName, this._tagDescription);
        this._created = true;
    }
}
Also used : Tag(io.apicurio.datamodels.core.models.common.Tag)

Example 10 with Tag

use of io.apicurio.datamodels.core.models.common.Tag in project apicurio-data-models by Apicurio.

the class Oas30Document method createTag.

/**
 * @see io.apicurio.datamodels.core.models.Document#createTag()
 */
@Override
public Tag createTag() {
    Tag tag = new Oas30Tag();
    tag._ownerDocument = this;
    tag._parent = this;
    return tag;
}
Also used : Tag(io.apicurio.datamodels.core.models.common.Tag)

Aggregations

Tag (io.apicurio.datamodels.core.models.common.Tag)12 IVisitor (io.apicurio.datamodels.core.visitors.IVisitor)1 OasDocument (io.apicurio.datamodels.openapi.models.OasDocument)1 Oas30Document (io.apicurio.datamodels.openapi.v3.models.Oas30Document)1 ArrayList (java.util.ArrayList)1