oauthScopes(element, items) {
    const {
      Member: MemberElement,
      Array: ArrayElement,
      String: StringElement,
    } = this.namespace.elements;

    const scopes = new ArrayElement();
    let descriptions = null;
    let scopesList = items;

    if (_.isObject(items) && !_.isArray(items)) {
      descriptions = Object.values(items);
      scopesList = Object.keys(items);
    }

    // If value is not an empty array, then they are scopes
    _.forEach(scopesList, (scopeName, index) => {
      const scope = new StringElement(scopeName);

      if (descriptions) {
        scope.description = descriptions[index];

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

      if (this.generateSourceMap) {
        const value = descriptions ? scopeName : index;
        this.createSourceMap(scope, this.path.concat([value]));
      }

      scopes.content.push(scope);
    });

    if (scopes.length) {
      element.content.push(new MemberElement('scopes', scopes));
    }
  }
// Convert OAuth2 scopes into Refract elements
Convert OAuth2 scopes into Refract elements
Convert OAuth2 scopes into Refract elements
oauthScopes(element, items) {
    const {
      Member: MemberElement,
      Array: ArrayElement,
      String: StringElement,
    } = this.namespace.elements;
    const scopes = new ArrayElement();
    let descriptions = null;
    let scopesList = items;
    if (_.isObject(items) && !_.isArray(items)) {
      descriptions = Object.values(items);
      scopesList = Object.keys(items);
    }
    _.forEach(scopesList, (scopeName, index) => {
      const scope = new StringElement(scopeName);
      if (descriptions) {
        scope.description = descriptions[index];
        if (this.generateSourceMap) {
          this.createSourceMap(scope.meta.get('description'), this.path.concat([scopeName]));
        }
      }
      if (this.generateSourceMap) {
        const value = descriptions ? scopeName : index;
        this.createSourceMap(scope, this.path.concat([value]));
      }
      scopes.content.push(scope);
    });
    if (scopes.length) {
      element.content.push(new MemberElement('scopes', scopes));
    }
  }
oauthScopes ( element , items ) { const { Member : MemberElement , Array : ArrayElement , String : StringElement , } = this . namespace . elements ; const scopes = new ArrayElement ( ) ; let descriptions = null ; let scopesList = items ; if ( _ . isObject ( items ) && ! _ . isArray ( items ) ) { descriptions = Object . values ( items ) ; scopesList = Object . keys ( items ) ; } _ . forEach ( scopesList , ( scopeName , index ) => { const scope = new StringElement ( scopeName ) ; if ( descriptions ) { scope . description = descriptions [ index ] ; if ( this . generateSourceMap ) { this . createSourceMap ( scope . meta . get ( 'description' ) , this . path . concat ( [ scopeName ] ) ) ; } } if ( this . generateSourceMap ) { const value = descriptions ? scopeName : index ; this . createSourceMap ( scope , this . path . concat ( [ value ] ) ) ; } scopes . content . push ( scope ) ; } ) ; if ( scopes . length ) { element . content . push ( new MemberElement ( 'scopes' , scopes ) ) ; } }
Convert OAuth2 scopes into Refract elements
Convert OAuth2 scopes into Refract elements
// If value is not an empty array, then they are scopes