Search in sources :

Example 1 with Oas20Document

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

the class DeleteSecuritySchemeCommand_20 method doDeleteScheme.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteSecuritySchemeCommand#doDeleteScheme(io.apicurio.datamodels.core.models.Document)
 */
@Override
protected Object doDeleteScheme(Document document) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20SecurityDefinitions definitions = doc20.securityDefinitions;
    if (this.isNullOrUndefined(definitions)) {
        return null;
    }
    return Library.writeNode(definitions.removeSecurityScheme(this._schemeName));
}
Also used : Oas20SecurityDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document)

Example 2 with Oas20Document

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

the class DeleteSecuritySchemeCommand_20 method doRestoreScheme.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteSecuritySchemeCommand#doRestoreScheme(io.apicurio.datamodels.core.models.Document, java.lang.Object)
 */
@Override
protected void doRestoreScheme(Document document, Object oldScheme) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20SecurityDefinitions definitions = doc20.securityDefinitions;
    if (this.isNullOrUndefined(definitions) || this.isNullOrUndefined(oldScheme)) {
        return;
    }
    Oas20SecurityScheme scheme = definitions.createSecurityScheme(this._schemeName);
    Library.readNode(oldScheme, scheme);
    definitions.addSecurityScheme(this._schemeName, scheme);
}
Also used : Oas20SecurityDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20SecurityScheme(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)

Example 3 with Oas20Document

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

the class DeleteResponseDefinitionCommand_20 method doDeleteResponseDefinition.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteResponseDefinitionCommand#doDeleteResponseDefinition(io.apicurio.datamodels.core.models.Document)
 */
@Override
protected Object doDeleteResponseDefinition(Document document) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20ResponseDefinitions responses = doc20.responses;
    if (this.isNullOrUndefined(responses) || ModelUtils.isNullOrUndefined(responses.getResponse(this._definitionName))) {
        return null;
    }
    Oas20ResponseDefinition schemaDef = responses.removeResponse(this._definitionName);
    return Library.writeNode(schemaDef);
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20ResponseDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinitions) Oas20ResponseDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)

Example 4 with Oas20Document

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

the class DeleteSchemaDefinitionCommand_20 method doRestoreSchemaDefinition.

/**
 * @see io.apicurio.datamodels.cmd.commands.DeleteSchemaDefinitionCommand#doRestoreSchemaDefinition(io.apicurio.datamodels.core.models.Document, java.lang.Object)
 */
@Override
protected void doRestoreSchemaDefinition(Document document, Object oldDefinition) {
    Oas20Document doc20 = (Oas20Document) document;
    Oas20Definitions definitions = doc20.definitions;
    if (this.isNullOrUndefined(definitions)) {
        return;
    }
    Oas20SchemaDefinition definition = doc20.definitions.createSchemaDefinition(this._definitionName);
    Library.readNode(oldDefinition, definition);
    definitions.addDefinition(this._definitionName, definition);
}
Also used : Oas20Definitions(io.apicurio.datamodels.openapi.v2.models.Oas20Definitions) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20SchemaDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)

Example 5 with Oas20Document

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

the class NewSchemaDefinitionCommand_20 method execute.

/**
 * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
 */
@Override
public void execute(Document document) {
    LoggerCompat.info("[NewDefinitionCommand] Executing.");
    Oas20Document doc20 = (Oas20Document) document;
    if (this.isNullOrUndefined(doc20.definitions)) {
        doc20.definitions = doc20.createDefinitions();
        this._nullDefinitions = true;
    }
    if (this.isNullOrUndefined(doc20.definitions.getDefinition(this._newDefinitionName))) {
        Oas20SchemaDefinition definition;
        if (!this.isNullOrUndefined(this._newDefinitionExample)) {
            definition = (Oas20SchemaDefinition) OasSchemaFactory.createSchemaDefinitionFromExample(doc20, this._newDefinitionName, this._newDefinitionExample);
            definition.example = this._newDefinitionExample;
        } else {
            definition = doc20.definitions.createSchemaDefinition(this._newDefinitionName);
            definition.type = "object";
        }
        if (ModelUtils.isDefined(this._newDefinitionDescription)) {
            definition.description = this._newDefinitionDescription;
        }
        doc20.definitions.addDefinition(this._newDefinitionName, definition);
        this._defExisted = false;
    } else {
        this._defExisted = true;
    }
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20SchemaDefinition(io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)

Aggregations

Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)91 Test (org.junit.Test)46 OpenApiModelInfo (io.syndesis.server.api.generator.openapi.OpenApiModelInfo)24 Oas20SchemaDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)20 Oas20PathItem (io.apicurio.datamodels.openapi.v2.models.Oas20PathItem)18 Oas20Operation (io.apicurio.datamodels.openapi.v2.models.Oas20Operation)17 Oas20Parameter (io.apicurio.datamodels.openapi.v2.models.Oas20Parameter)15 Oas20Schema (io.apicurio.datamodels.openapi.v2.models.Oas20Schema)15 Oas20SecurityScheme (io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)12 Oas20Response (io.apicurio.datamodels.openapi.v2.models.Oas20Response)9 Oas20ResponseDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinition)9 ConnectorSettings (io.syndesis.common.model.connection.ConnectorSettings)8 Violation (io.syndesis.common.model.Violation)7 ConfigurationProperty (io.syndesis.common.model.connection.ConfigurationProperty)6 Oas30Document (io.apicurio.datamodels.openapi.v3.models.Oas30Document)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 Oas20ParameterDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20ParameterDefinition)4 ArrayList (java.util.ArrayList)4 Aai20Document (io.apicurio.datamodels.asyncapi.v2.models.Aai20Document)3 IDefinition (io.apicurio.datamodels.core.models.common.IDefinition)3