Search in sources :

Example 1 with Oas20SecurityScheme

use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme 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 2 with Oas20SecurityScheme

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

the class ChangeSecuritySchemeCommand_20 method nullScheme.

/**
 * @see io.apicurio.datamodels.cmd.commands.ChangeSecuritySchemeCommand#nullScheme(io.apicurio.datamodels.core.models.common.SecurityScheme)
 */
@Override
protected void nullScheme(SecurityScheme scheme) {
    super.nullScheme(scheme);
    Oas20SecurityScheme scheme20 = (Oas20SecurityScheme) scheme;
    scheme20.tokenUrl = null;
    scheme20.authorizationUrl = null;
    scheme20.flow = null;
    scheme20.scopes = null;
}
Also used : Oas20SecurityScheme(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)

Example 3 with Oas20SecurityScheme

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

the class Oas20Traverser method visitSecurityScheme.

/**
 * @see io.apicurio.datamodels.core.visitors.IVisitor#visitSecurityScheme(io.apicurio.datamodels.core.models.common.SecurityScheme)
 */
@Override
public void visitSecurityScheme(SecurityScheme node) {
    Oas20SecurityScheme node20 = (Oas20SecurityScheme) node;
    node.accept(this.visitor);
    this.traverseIfNotNull(node20.scopes);
    this.traverseExtensions(node);
    this.traverseValidationProblems(node);
}
Also used : Oas20SecurityScheme(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)

Example 4 with Oas20SecurityScheme

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

the class Oas20DataModelWriter method writeSecurityScheme.

/**
 * @see io.apicurio.datamodels.core.io.DataModelWriter#writeSecurityScheme(java.lang.Object, io.apicurio.datamodels.core.models.common.SecurityScheme)
 */
@Override
protected void writeSecurityScheme(Object json, SecurityScheme node) {
    Oas20SecurityScheme node20 = (Oas20SecurityScheme) node;
    JsonCompat.setPropertyString(json, Constants.PROP_FLOW, node20.flow);
    JsonCompat.setPropertyString(json, Constants.PROP_AUTHORIZATION_URL, node20.authorizationUrl);
    JsonCompat.setPropertyString(json, Constants.PROP_TOKEN_URL, node20.tokenUrl);
    JsonCompat.setPropertyNull(json, Constants.PROP_SCOPES);
    super.writeSecurityScheme(json, node);
}
Also used : Oas20SecurityScheme(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)

Example 5 with Oas20SecurityScheme

use of io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme in project syndesis by syndesisio.

the class OpenApiConnectorGeneratorTest method shouldNotProvideAuthenticationPropertiesWithMultipleSecurityDefinitionsMatching.

@Test
public void shouldNotProvideAuthenticationPropertiesWithMultipleSecurityDefinitionsMatching() {
    final Oas20Document openApiDoc = new Oas20Document();
    openApiDoc.securityDefinitions = openApiDoc.createSecurityDefinitions();
    Oas20SecurityScheme scheme1 = openApiDoc.securityDefinitions.createSecurityScheme("one");
    scheme1.in = "query";
    scheme1.type = "apiKey";
    Oas20SecurityScheme scheme2 = openApiDoc.securityDefinitions.createSecurityScheme("two");
    scheme2.in = "header";
    scheme2.type = "apiKey";
    openApiDoc.securityDefinitions.addSecurityScheme("one", scheme1);
    openApiDoc.securityDefinitions.addSecurityScheme("two", scheme2);
    final String specification = Library.writeDocumentToJSONString(openApiDoc);
    final ConnectorSettings connectorSettings = new ConnectorSettings.Builder().putConfiguredProperty("specification", specification).build();
    final APISummary summary = generator.info(ApiConnectorTemplate.SWAGGER_TEMPLATE, connectorSettings);
    assertThat(summary.getProperties().keySet()).containsOnly("authenticationType", "basePath", "host", "specification");
}
Also used : APISummary(io.syndesis.common.model.api.APISummary) Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20SecurityScheme(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme) ConnectorSettings(io.syndesis.common.model.connection.ConnectorSettings) Test(org.junit.Test)

Aggregations

Oas20SecurityScheme (io.apicurio.datamodels.openapi.v2.models.Oas20SecurityScheme)23 Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)12 Test (org.junit.Test)9 ConnectorSettings (io.syndesis.common.model.connection.ConnectorSettings)4 OpenApiModelInfo (io.syndesis.server.api.generator.openapi.OpenApiModelInfo)4 Oas30SecurityScheme (io.apicurio.datamodels.openapi.v3.models.Oas30SecurityScheme)3 Aai20Document (io.apicurio.datamodels.asyncapi.v2.models.Aai20Document)2 Oas20Scopes (io.apicurio.datamodels.openapi.v2.models.Oas20Scopes)2 Oas20SecurityDefinitions (io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions)2 Oas30Document (io.apicurio.datamodels.openapi.v3.models.Oas30Document)2 APISummary (io.syndesis.common.model.api.APISummary)2 AaiSecurityScheme (io.apicurio.datamodels.asyncapi.models.AaiSecurityScheme)1 Aai20NodeFactory (io.apicurio.datamodels.asyncapi.v2.models.Aai20NodeFactory)1 Aai20SecurityScheme (io.apicurio.datamodels.asyncapi.v2.models.Aai20SecurityScheme)1 CombinedVisitorAdapter (io.apicurio.datamodels.combined.visitors.CombinedVisitorAdapter)1 SecurityRequirement (io.apicurio.datamodels.core.models.common.SecurityRequirement)1 SecurityScheme (io.apicurio.datamodels.core.models.common.SecurityScheme)1 Oas30Components (io.apicurio.datamodels.openapi.v3.models.Oas30Components)1 Violation (io.syndesis.common.model.Violation)1 ConfigurationProperty (io.syndesis.common.model.connection.ConfigurationProperty)1