Search in sources :

Example 1 with Tag

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

the class DeleteTagCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[DeleteTagCommand] Reverting.");
    if (this.isNullOrUndefined(document.tags)) {
        document.tags = new ArrayList<>();
    }
    Tag tag = document.createTag();
    Library.readNode(this._oldTag, tag);
    if (document.tags.size() >= this._oldIndex) {
        document.tags.add(_oldIndex, tag);
    } else {
        document.tags.add(tag);
    }
}
Also used : Tag(io.apicurio.datamodels.core.models.common.Tag)

Example 2 with Tag

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

the class Oas20Document method createTag.

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

Example 3 with Tag

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

the class NewTagCommand method undo.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void undo(Document document) {
    LoggerCompat.info("[NewTagCommand] Reverting.");
    if (!this._created) {
        return;
    }
    Tag tag = this.findTag(document, this._tagName);
    if (this.isNullOrUndefined(tag)) {
        return;
    }
    document.tags.remove(document.tags.indexOf(tag));
}
Also used : Tag(io.apicurio.datamodels.core.models.common.Tag)

Example 4 with Tag

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

the class DataModelReader method readDocument.

/**
 * Reads the root document.
 * @param json
 * @param node
 */
public void readDocument(Object json, Document node) {
    Object info = JsonCompat.consumeProperty(json, Constants.PROP_INFO);
    List<Object> tags = JsonCompat.consumePropertyArray(json, Constants.PROP_TAGS);
    Object externalDocs = JsonCompat.consumeProperty(json, Constants.PROP_EXTERNAL_DOCS);
    if (info != null) {
        node.info = node.createInfo();
        this.readInfo(info, node.info);
    }
    if (tags != null) {
        List<Tag> tagModels = new ArrayList<>();
        for (Object tag : tags) {
            Tag tagModel = node.createTag();
            this.readTag(tag, tagModel);
            tagModels.add(tagModel);
        }
        node.tags = tagModels;
    }
    if (externalDocs != null) {
        node.externalDocs = node.createExternalDocumentation();
        this.readExternalDocumentation(externalDocs, node.externalDocs);
    }
    this.readExtensions(json, node);
    this.readExtraProperties(json, node);
}
Also used : ArrayList(java.util.ArrayList) Tag(io.apicurio.datamodels.core.models.common.Tag)

Example 5 with Tag

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

the class Document method addTag.

/**
 * Adds a tag.
 * @param name
 * @param description
 */
public Tag addTag(String name, String description) {
    Tag tag = this.createTag();
    tag.name = name;
    tag.description = description;
    if (this.tags == null) {
        this.tags = new ArrayList<>();
    }
    this.tags.add(tag);
    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