This repository has been archived by the owner on Dec 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(converter): ignore x-swagger-router-controller folders (#27)
fixes #26
- Loading branch information
Showing
21 changed files
with
4,124 additions
and
4,137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"quotes": [2, "single"] | ||
}, | ||
"env": { | ||
"browser": true, | ||
"browser": false, | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"printWidth": 100, | ||
"semi": false | ||
"semi": false, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const { getBaseUrl } = require('../src/converter') | ||
|
||
describe('OAS3', () => { | ||
test('should return https url', () => { | ||
const url = getBaseUrl({ | ||
servers: [ | ||
{ url: 'https://example.com' }, | ||
{ url: 'https://sub.example.com' }, | ||
{ url: 'http://example.com' }, | ||
], | ||
}) | ||
|
||
expect(url).toContain('https://') | ||
}) | ||
|
||
test('should return http url for backward compatibility', () => { | ||
const url = getBaseUrl({ | ||
servers: [{ url: 'http://example.com' }, { url: 'http://sub.example.com' }], | ||
}) | ||
|
||
expect(url).toContain('http://') | ||
}) | ||
|
||
test('should return url without trailing slash', () => { | ||
const url = getBaseUrl({ | ||
servers: [{ url: 'https://example.com/' }, { url: 'http://example.com' }], | ||
}) | ||
|
||
expect(url).toContain('https://') | ||
}) | ||
}) | ||
|
||
describe('OAS2', () => { | ||
test('should return https url', () => { | ||
const url = getBaseUrl({ | ||
schemes: [ | ||
'https', | ||
'http', | ||
], | ||
host: 'example.com' | ||
}) | ||
|
||
expect(url).toEqual('https://example.com') | ||
}) | ||
|
||
test('should return http url for backward compatibility', () => { | ||
const url = getBaseUrl({ | ||
schemes: [ | ||
'http', | ||
], | ||
host: 'example.com' | ||
}) | ||
|
||
expect(url).toContain('http://example.com') | ||
}) | ||
|
||
test('should return url with path', () => { | ||
const url = getBaseUrl({ | ||
schemes: [ | ||
'http', | ||
'https' | ||
], | ||
host: 'example.com', | ||
basePath: '/api/v1' | ||
}) | ||
|
||
expect(url).toContain('https://example.com/api/v1') | ||
}) | ||
}) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
__tests__/multipart_mixin.js → __tests__/multipart-mixin.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { parseSwaggerDoc } = require('../src/converter') | ||
|
||
test('should return empty entries', () => { | ||
const swagger = { | ||
paths: { | ||
'x-swagger-router-controller': 'health', | ||
}, | ||
} | ||
const entries = parseSwaggerDoc(swagger, 'https://example.com') | ||
expect(entries.length).toEqual(0) | ||
}) | ||
|
||
test('should skip x-swagger-router-controller from paths', () => { | ||
const swagger = { | ||
paths: { | ||
'x-swagger-router-controller': 'health', | ||
'/emojis': { | ||
get: { | ||
parameters: [ | ||
{ | ||
description: 'You can check the current version of media type in responses.', | ||
in: 'header', | ||
name: 'X-Media-Type', | ||
type: 'string', | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
} | ||
const entries = parseSwaggerDoc(swagger, 'https://example.com') | ||
expect(entries.length).toEqual(1) | ||
expect(entries).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ url: 'https://example.com/emojis' }) | ||
]) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ts__/application_x_www_form_urlencoded.js → __tests__/x-www-form-urlencoded.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.