Search in sources :

Example 1 with OasDocument

use of io.apicurio.datamodels.openapi.models.OasDocument 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);
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) OasPathItem(io.apicurio.datamodels.openapi.models.OasPathItem)

Example 2 with OasDocument

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

the class DeletePathCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[DeletePathCommand] Executing for path: %s", this._path);
    OasDocument odoc = (OasDocument) document;
    this._oldPath = null;
    OasPaths paths = odoc.paths;
    if (this.isNullOrUndefined(paths)) {
        return;
    }
    this._oldPath = Library.writeNode(paths.removePathItem(this._path));
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) OasPaths(io.apicurio.datamodels.openapi.models.OasPaths)

Example 3 with OasDocument

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

the class AddResponseDefinitionCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[AddResponseDefinitionCommand] Executing.");
    OasDocument doc = (OasDocument) document;
    // Do nothing if the definition already exists.
    if (this.defExists(doc)) {
        LoggerCompat.info("[AddResponseDefinitionCommand] Definition with name %s already exists.", this._newDefinitionName);
        this._defExisted = true;
        return;
    }
    this.prepareDocumentForDef(doc);
    OasResponse definition = this.createResponseDefinition(doc);
    this.addDefinition(doc, definition);
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) OasResponse(io.apicurio.datamodels.openapi.models.OasResponse)

Example 4 with OasDocument

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

the class AddSchemaDefinitionCommand method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[AddSchemaDefinitionCommand] Executing.");
    OasDocument doc = (OasDocument) document;
    // Do nothing if the definition already exists.
    if (this.defExists(doc)) {
        LoggerCompat.info("[AddSchemaDefinitionCommand] Definition with name %s already exists.", this._newDefinitionName);
        this._defExisted = true;
        return;
    }
    this.prepareDocumentForDef(doc);
    OasSchema definition = this.createSchemaDefinition(doc);
    this.addDefinition(doc, definition);
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) OasSchema(io.apicurio.datamodels.openapi.models.OasSchema)

Example 5 with OasDocument

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

the class OasTraverser method traverseDocument.

/**
 * @see io.apicurio.datamodels.core.visitors.Traverser#traverseDocument(io.apicurio.datamodels.core.models.Document)
 */
@Override
protected void traverseDocument(Document node) {
    OasDocument doc = (OasDocument) node;
    super.traverseDocument(node);
    this.traverseIfNotNull(doc.paths);
    this.traverseCollection(doc.security);
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument)

Aggregations

OasDocument (io.apicurio.datamodels.openapi.models.OasDocument)70 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 DefaultClassResolver (org.apache.camel.impl.engine.DefaultClassResolver)30 Test (org.junit.jupiter.api.Test)30 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)28 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)28 OasPathItem (io.apicurio.datamodels.openapi.models.OasPathItem)17 Map (java.util.Map)9 OasOperation (io.apicurio.datamodels.openapi.models.OasOperation)8 List (java.util.List)8 APIValidationContext (io.syndesis.server.api.generator.APIValidationContext)7 Optional (java.util.Optional)7 Collectors (java.util.stream.Collectors)7 OasPaths (io.apicurio.datamodels.openapi.models.OasPaths)6 OasModelHelper (io.syndesis.server.api.generator.openapi.util.OasModelHelper)6 Info (io.apicurio.datamodels.core.models.common.Info)5 Violation (io.syndesis.common.model.Violation)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Locale (java.util.Locale)5