How to use openapi-security-handler - 2 common examples

To help you get started, we’ve selected a few openapi-security-handler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kogosoftwarellc / open-api / packages / openapi-framework / index.ts View on Github external
public initialize(visitor: OpenAPIFrameworkVisitor) {
    const securitySchemes = (this.apiDoc as OpenAPIV3.Document).openapi
      ? (this.apiDoc.components || {}).securitySchemes
      : this.apiDoc.securityDefinitions;

    const apiSecurityMiddleware =
      this.securityHandlers && this.apiDoc.security && securitySchemes
        ? new OpenAPISecurityHandler({
            securityDefinitions: securitySchemes,
            securityHandlers: this.securityHandlers,
            operationSecurity: this.apiDoc.security,
            loggingKey: `${this.name}-security`
          })
        : null;

    let paths = [];
    let routes = [];
    const routesCheckMap = {};

    if (this.paths) {
      paths = [].concat(this.paths);
      this.logger.debug(`${this.loggingPrefix}paths=`, paths);
      paths.forEach(pathItem => {
        if (byString(pathItem)) {
github kogosoftwarellc / open-api / packages / openapi-framework / index.ts View on Github external
let securityDefinition;

            if (this.securityHandlers && securitySchemes) {
              if (operationDoc.security) {
                securityDefinition = operationDoc.security;
              } else if (this.pathSecurity.length) {
                securityDefinition = getSecurityDefinitionByPath(
                  openapiPath,
                  this.pathSecurity
                );
              }
            }

            if (securityDefinition) {
              pathDoc[methodName].security = securityDefinition;
              securityFeature = new OpenAPISecurityHandler({
                securityDefinitions: securitySchemes,
                securityHandlers: this.securityHandlers,
                operationSecurity: securityDefinition,
                loggingKey: `${this.name}-security`
              });
            } else if (apiSecurityMiddleware) {
              securityFeature = apiSecurityMiddleware;
            }

            if (securityFeature) {
              operationContext.features.securityHandler = securityFeature;
            }
          }
        }

        if (visitor.visitOperation) {

openapi-security-handler

A library to process OpenAPI security definitions in parallel.

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis

Popular openapi-security-handler functions