-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support .redocly.yaml for options for redoc-cli (#1981)
Co-authored-by: Anastasiia Derymarko < anastasiia@redocly.com> Co-authored-by: Adam Altman <adam@redoc.ly> Co-authored-by: Ivana Isadora Devcic <33730345+skadinna@users.noreply.github.com>
- Loading branch information
1 parent
7988e81
commit 1f417d6
Showing
8 changed files
with
96 additions
and
5 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
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,2 @@ | ||
features.openapi: | ||
disableSearch: 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,30 @@ | ||
import { spawnSync } from 'child_process'; | ||
import { readFileSync } from 'fs'; | ||
|
||
describe('build', () => { | ||
it('should use .redocly.yaml', () => { | ||
const r = spawnSync( | ||
'node', | ||
['../../../index.js', 'build', ' ../../../../demo/openapi.yaml', '--output=redocTest.html'], | ||
{ | ||
cwd: __dirname, | ||
shell: true, | ||
}, | ||
); | ||
|
||
const out = r.stdout.toString('utf-8'); | ||
const err = r.stderr.toString('utf-8'); | ||
const result = `${out}\n${err}`; | ||
|
||
try { | ||
const redocStaticFile = readFileSync(`${__dirname}/redocTest.html`, 'utf8'); | ||
expect(redocStaticFile).toContain('"options":{"disableSearch":true}'); | ||
expect(redocStaticFile).not.toContain('role="search"'); | ||
} catch (err) { | ||
expect(err.toString()).toContain('{"options":{"disableSearch":"true"}'); | ||
} | ||
|
||
expect(result).toContain('Found .redocly.yaml and using features.openapi options'); | ||
expect(result).toContain('bundled successfully'); | ||
}); | ||
}); |
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,34 @@ | ||
import { spawnSync } from 'child_process'; | ||
import { readFileSync } from 'fs'; | ||
|
||
describe('build with inline options', () => { | ||
it('should use inline options and ignore .redocly.yaml', () => { | ||
const r = spawnSync( | ||
'node', | ||
[ | ||
'../../../index.js', | ||
'build', | ||
' ../../../../demo/openapi.yaml', | ||
'--options.disableSearch="false" ', | ||
], | ||
{ | ||
cwd: __dirname, | ||
shell: true, | ||
}, | ||
); | ||
|
||
const out = r.stdout.toString('utf-8'); | ||
const err = r.stderr.toString('utf-8'); | ||
const result = `${out}\n${err}`; | ||
expect(result).not.toContain('Found .redocly.yaml and using features.openapi options'); | ||
expect(result).toContain('bundled successfully'); | ||
|
||
try { | ||
const redocStaticFile = readFileSync(`${__dirname}/redoc-static.html`, 'utf8'); | ||
expect(redocStaticFile).toContain('"options":{"disableSearch":"false"}'); | ||
expect(redocStaticFile).toContain('role="search"'); | ||
} catch (err) { | ||
expect(err.toString()).toContain('"options":{"disableSearch":"false"}'); | ||
} | ||
}); | ||
}); |
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