Skip to content

Commit

Permalink
multi-auth:fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
barduinor committed Sep 9, 2023
1 parent bcd80b5 commit cf9fd8b
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 231 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"standard": "^16.0.1",
"uuid": "^8.0.0"
},
"devDependencies": {
"jest": "^26.6.3",
"standard": "^16.0.1"
},
"scripts": {
"clean": "rm -rf ./.sources ./compiled",
"pull": "node -e 'require(\"./src/scripts/pull.js\").pullAll()'",
Expand Down
55 changes: 27 additions & 28 deletions src/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Collection {
this.openapi = openapi
this.locale = locale
this.LOCALE = locale.toUpperCase()
this.small = small //RB: if true returns a subset of the collection with only a few folders
this.small = small // RB: if true returns a subset of the collection with only a few folders
}

/**
Expand Down Expand Up @@ -143,7 +143,7 @@ class Collection {
* populates it with every endpoint
*/
getItems () {
if ( this.small ) {
if (this.small) {
this.createFoldersSmall()
} else {
this.createFolders()
Expand Down Expand Up @@ -179,7 +179,7 @@ class Collection {
this.openapi.tags.sort(byName).sort(byPriority).forEach(tag => {
// only append subfolders in openapi
const folder = {
id: uuid.v5(tag.name,NAMESPACE), //RB: use uuid v5 to generate a deterministic uuid
id: uuid.v5(tag.name, NAMESPACE), // RB: use uuid v5 to generate a deterministic uuid
name: tag.name,
item: []
}
Expand All @@ -190,13 +190,13 @@ class Collection {

// create a subset of the folders
createFoldersSmall () {
const foldersSubSet = ['Authorization' ,'Users', 'Files', 'Folders']
const foldersSubSet = ['Authorization', 'Users', 'Files', 'Folders']

this.folders = []

for (const folderName of foldersSubSet) {
const folder = {
id: uuid.v5(folderName,NAMESPACE), //RB: use uuid v5 to generate a deterministic uuid
id: uuid.v5(folderName, NAMESPACE), // RB: use uuid v5 to generate a deterministic uuid
name: folderName,
item: []
}
Expand All @@ -218,7 +218,7 @@ class Collection {

const item = {
// id: uuid.v4(),
id: uuid.v5(endpoint.operationId,NAMESPACE), //RB: use uuid v5 to generate a deterministic uuid
id: uuid.v5(endpoint.operationId, NAMESPACE), // RB: use uuid v5 to generate a deterministic uuid
// id: verb+'_'+path+'_'+endpoint.operationId,
name: endpoint.summary,
description: this.description(endpoint),
Expand All @@ -233,7 +233,7 @@ class Collection {
parent.push(item)
console.log(`${item.name} [${item.id}] added to collection`)
} catch (e) {

}
}

Expand All @@ -259,9 +259,9 @@ class Collection {

request (verb, path, endpoint) {
return {
id: uuid.v5(verb+'_'+path+'_'+endpoint,NAMESPACE), //RB: use uuid v5 to generate a deterministic uuid
id: uuid.v5(verb + '_' + path + '_' + endpoint, NAMESPACE), // RB: use uuid v5 to generate a deterministic uuid
url: this.url(path, endpoint),
auth: this.auth_for_endpoint(endpoint),
auth: this.authForEndPoint(endpoint),
method: verb.toUpperCase(),
description: this.description(endpoint),
header: this.header(endpoint),
Expand Down Expand Up @@ -358,9 +358,9 @@ class Collection {
return headers
}

auth_for_endpoint (endpoint) {
authForEndPoint (endpoint) {
// RB: if multi then inherit security from parent collection
if ( this.LOCALE === 'MULTI' ) { return null }
if (this.LOCALE === 'MULTI') { return null }
if (endpoint.security && endpoint.security.length === 0) {
return {
type: 'noauth'
Expand All @@ -372,25 +372,24 @@ class Collection {

defaultAuth () {
// RB: if multi the collection has bearer token
if ( this.LOCALE === 'MULTI' ) { return this.auth_bearer_token() }
else { return this.auth_oAuth() }
}

auth_bearer_token(){
return{
type: "bearer",
bearer: [
{
key: 'token',
value:'{{access_token}}',
type: 'any'
}
if (this.LOCALE === 'MULTI') { return this.authBearerToken() } else { return this.authOAuth() }
}

authBearerToken () {
return {
type: 'bearer',
bearer: [
{
key: 'token',
value: '{{access_token}}',
type: 'any'
}

]
]
}
}
}

auth_oAuth () {
authOAuth () {
return {
type: 'oauth2',
oauth2: [
Expand Down Expand Up @@ -478,7 +477,7 @@ class Collection {
.filter(([code]) => code !== 'default')
.map(([code, response]) => ({
// id: uuid.v4(),
id: uuid.v5(endpoint.operationId+'_'+code,NAMESPACE), //RB: use uuid v5 to generate a deterministic uuid
id: uuid.v5(endpoint.operationId + '_' + code, NAMESPACE), // RB: use uuid v5 to generate a deterministic uuid
name: this.responseName(code, response),
header: this.responseHeaders(response),
body: this.responseBody(response),
Expand Down
2 changes: 1 addition & 1 deletion src/OpenAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class OpenAPI {
this.filename = filename
this.openapi = null
this.locale = locale
this.small = small //RB: small sub set of endpoints
this.small = small // RB: small sub set of endpoints
this.tags = {}
}

Expand Down
Loading

0 comments on commit cf9fd8b

Please sign in to comment.