Search in sources :

Example 11 with Tag

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

the class DeleteAllTagsCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[DeleteAllTagsCommand] Reverting.");
    if (this._oldTags.size() == 0) {
        return;
    }
    OasDocument odoc = (OasDocument) document;
    if (this.isNullOrUndefined(document.tags)) {
        odoc.tags = new ArrayList<>();
    }
    this._oldTags.forEach(oldTag -> {
        Tag tag = document.createTag();
        Library.readNode(oldTag, tag);
        document.tags.add(tag);
    });
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) Tag(io.apicurio.datamodels.core.models.common.Tag)

Example 12 with Tag

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

the class TagUniquenessValidationRule method visitTag.

/**
 * @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitTag(io.apicurio.datamodels.core.models.common.Tag)
 */
@Override
public void visitTag(Tag node) {
    List<Tag> tags = node.ownerDocument().tags;
    int tcount = 0;
    for (Tag tag : tags) {
        if (equals(tag.name, node.name)) {
            tcount++;
        }
    }
    this.reportIf(tcount > 1, node, node.name, map("tagName", node.name));
}
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