handleSwaggerAuth() {
    const { Category, AuthScheme } = this.namespace.elements;
    const schemes = [];

    if (this.swagger.securityDefinitions) {
      _.keys(this.swagger.securityDefinitions).forEach((name) => {
        this.withPath('securityDefinitions', name, () => {
          const item = this.swagger.securityDefinitions[name];
          const element = new AuthScheme();

          switch (item.type) {
            case 'basic':
              element.element = 'Basic Authentication Scheme';
              break;

            case 'apiKey':
              element.element = 'Token Authentication Scheme';
              this.apiKeyName(element, item);
              break;

            case 'oauth2':
              element.element = 'OAuth2 Scheme';
              this.oauthGrantType(element, item.flow);

              if (item.scopes) {
                this.withPath('scopes', () => {
                  this.oauthScopes(element, item.scopes);
                });
              }

              this.oauthTransitions(element, item);
              break;

            default:
              break;
          }

          element.id = name;

          if (this.generateSourceMap) {
            this.createSourceMap(element.meta.get('id'), this.path);
          }

          if (item['x-summary']) {
            element.title = item['x-summary'];

            if (this.generateSourceMap) {
              this.createSourceMap(element.meta.get('title'), this.path.concat(['x-summary']));
            }
          }

          if (item.description) {
            element.description = item.description;

            if (this.generateSourceMap) {
              this.createSourceMap(element.meta.get('description'), this.path.concat(['description']));
            }
          }

          schemes.push(element);

          this.handleSwaggerVendorExtensions(element, item);
        });
      });
    }

    if (schemes.length) {
      const category = new Category();

      category.meta.set('classes', ['authSchemes']);
      category.content = schemes;

      this.api.content.push(category);
    }

    if (!this.swagger.security) {
      return;
    }

    this.handleSwaggerSecurity(this.swagger.security, this.globalSchemes);
  }
// Convert a Swagger auth object into Refract elements.
Convert a Swagger auth object into Refract elements.
Convert a Swagger auth object into Refract elements .
handleSwaggerAuth() {
    const { Category, AuthScheme } = this.namespace.elements;
    const schemes = [];
    if (this.swagger.securityDefinitions) {
      _.keys(this.swagger.securityDefinitions).forEach((name) => {
        this.withPath('securityDefinitions', name, () => {
          const item = this.swagger.securityDefinitions[name];
          const element = new AuthScheme();
          switch (item.type) {
            case 'basic':
              element.element = 'Basic Authentication Scheme';
              break;
            case 'apiKey':
              element.element = 'Token Authentication Scheme';
              this.apiKeyName(element, item);
              break;
            case 'oauth2':
              element.element = 'OAuth2 Scheme';
              this.oauthGrantType(element, item.flow);
              if (item.scopes) {
                this.withPath('scopes', () => {
                  this.oauthScopes(element, item.scopes);
                });
              }
              this.oauthTransitions(element, item);
              break;
            default:
              break;
          }
          element.id = name;
          if (this.generateSourceMap) {
            this.createSourceMap(element.meta.get('id'), this.path);
          }
          if (item['x-summary']) {
            element.title = item['x-summary'];
            if (this.generateSourceMap) {
              this.createSourceMap(element.meta.get('title'), this.path.concat(['x-summary']));
            }
          }
          if (item.description) {
            element.description = item.description;
            if (this.generateSourceMap) {
              this.createSourceMap(element.meta.get('description'), this.path.concat(['description']));
            }
          }
          schemes.push(element);
          this.handleSwaggerVendorExtensions(element, item);
        });
      });
    }
    if (schemes.length) {
      const category = new Category();
      category.meta.set('classes', ['authSchemes']);
      category.content = schemes;
      this.api.content.push(category);
    }
    if (!this.swagger.security) {
      return;
    }
    this.handleSwaggerSecurity(this.swagger.security, this.globalSchemes);
  }
handleSwaggerAuth ( ) { const { Category , AuthScheme } = this . namespace . elements ; const schemes = [ ] ; if ( this . swagger . securityDefinitions ) { _ . keys ( this . swagger . securityDefinitions ) . forEach ( ( name ) => { this . withPath ( 'securityDefinitions' , name , ( ) => { const item = this . swagger . securityDefinitions [ name ] ; const element = new AuthScheme ( ) ; switch ( item . type ) { case 'basic' : element . element = 'Basic Authentication Scheme' ; break ; case 'apiKey' : element . element = 'Token Authentication Scheme' ; this . apiKeyName ( element , item ) ; break ; case 'oauth2' : element . element = 'OAuth2 Scheme' ; this . oauthGrantType ( element , item . flow ) ; if ( item . scopes ) { this . withPath ( 'scopes' , ( ) => { this . oauthScopes ( element , item . scopes ) ; } ) ; } this . oauthTransitions ( element , item ) ; break ; default : break ; } element . id = name ; if ( this . generateSourceMap ) { this . createSourceMap ( element . meta . get ( 'id' ) , this . path ) ; } if ( item [ 'x-summary' ] ) { element . title = item [ 'x-summary' ] ; if ( this . generateSourceMap ) { this . createSourceMap ( element . meta . get ( 'title' ) , this . path . concat ( [ 'x-summary' ] ) ) ; } } if ( item . description ) { element . description = item . description ; if ( this . generateSourceMap ) { this . createSourceMap ( element . meta . get ( 'description' ) , this . path . concat ( [ 'description' ] ) ) ; } } schemes . push ( element ) ; this . handleSwaggerVendorExtensions ( element , item ) ; } ) ; } ) ; } if ( schemes . length ) { const category = new Category ( ) ; category . meta . set ( 'classes' , [ 'authSchemes' ] ) ; category . content = schemes ; this . api . content . push ( category ) ; } if ( ! this . swagger . security ) { return ; } this . handleSwaggerSecurity ( this . swagger . security , this . globalSchemes ) ; }
Convert a Swagger auth object into Refract elements.
Convert a Swagger auth object into Refract elements .