Skip to content

Commit 3d91cc1

Browse files
authored
Merge branch 'master' into data-root-option
2 parents 696bc50 + 7b7efff commit 3d91cc1

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ Like [Postman Documenter](https://www.getpostman.com/api-documentation-generator
77

88
## Table of Contents
99

10+
- [Table of Contents](#table-of-contents)
1011
- [Requirements](#requirements)
1112
- [Getting Started](#getting-started)
1213
- [Using `npx`](#using-npx)
1314
- [By installing the package globally](#by-installing-the-package-globally)
1415
- [Options](#options)
15-
- [Using a GitHub Release](#using-a-github-release)
16+
- [Using a GitHub release](#using-a-github-release)
1617
- [Updating the API](#updating-the-api)
1718
- [Custom Root Paths](#custom-root-paths)
1819
- [Running the Page Locally](#running-the-page-locally)
@@ -49,6 +50,7 @@ insomnia-documenter --config /path/to/insomnia/config.json
4950
Options:
5051
-c, --config <location> Location of the exported Insomnia JSON config.
5152
-l, --logo <location> Project logo location (48x48px PNG).
53+
-f, --favicon <location> Project favicon location (ICO).
5254
-o, --output <location> Where to save the file (defaults to current working directory).
5355
-h, --help output usage information
5456
```
@@ -61,7 +63,7 @@ Alternatively, you can start using Insomnia Documenter by downloading a release
6163

6264
Updating the API is super simple! Since Insomnia Documenter is a plug-and-play web app, you can just replace your `insomnia.json` with your new exported JSON file. Just make sure it's called `insomnia.json`.
6365

64-
The same actually applies to the logo as well (`logo.png`).
66+
The same actually applies to the logo (`logo.png`) e favicon (`favicon.ico`) as well .
6567

6668
## Custom Root Paths
6769

bin/generate.js

100755100644
+10-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ const mkdirp = require('mkdirp');
99
program
1010
.option('-c, --config <location>', 'Location of the exported Insomnia JSON config.')
1111
.option('-l, --logo <location>', 'Project logo location (48x48px PNG).')
12+
.option('-f, --favicon <location>', 'Project favicon location (ICO).')
1213
.option('-o, --output <location>', 'Where to save the file (defaults to current working directory).')
1314
.option('-d, --data-root <docs-root>', 'Docs root for the API documentation.', '')
1415
.parse(process.argv);
1516

16-
const { config, logo, output, dataRoot } = program;
17+
18+
const { config, logo, favicon, output, dataRoot } = program;
1719

1820
if (!config) {
1921
console.log('You must provide an exported Insomnia config (Preferences -> Data -> Export Data -> Current Workspace).');
@@ -23,6 +25,7 @@ if (!config) {
2325
const PACKAGE_DIST_PATH = path.resolve(__dirname, '..', 'public');
2426
const outputPath = output ? path.join(process.cwd(), output) : process.cwd();
2527
const logoPath = logo && path.join(process.cwd(), logo);
28+
const faviconPath = favicon && path.join(process.cwd(), favicon);
2629
const configPath = path.join(process.cwd(), config);
2730

2831
console.log('Getting files ready...');
@@ -50,15 +53,16 @@ mkdirp(outputPath, err => {
5053

5154
try {
5255
const data = fs.readFileSync(path.join(outputPath, 'index.html'), 'utf8')
53-
var result = data.replace('DATAROOT', dataRoot);
56+
var result = data.replace('<div id="app">', `<div id="app" data-root="${dataRoot}">`);
57+
fs.writeFileSync(path.join(outputPath, 'index.html'), result)
5458
} catch (err) {
5559
console.error(err)
5660
}
5761

58-
try {
59-
fs.writeFileSync(path.join(outputPath, 'index.html'), result)
60-
} catch (err) {
61-
console.error(err)
62+
if (faviconPath) {
63+
console.log('Adding custom favicon...');
64+
fs.copyFileSync(faviconPath, path.join(outputPath, 'favicon.ico'));
65+
6266
}
6367

6468
console.log('\n * * * Done! * * *\nYour documentation has been created and it\'s ready to be deployed!');

src/lib/generateCode/targets/php.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ curl_setopt_array($curl, array(
3838
}
3939

4040
if (req.authHeader) {
41-
headers.push(`${req.authHeader.name}: ${req.authHeader.value}`);
41+
headers.push(`'${req.authHeader.name}: ${req.authHeader.value}'`);
4242
}
4343

4444
if (headers.length) {
45-
opts.push(`CURLOPTS_HTTPHEADER => array(
45+
opts.push(`CURLOPT_HTTPHEADER => array(
4646
${headers.join(',\n ')}
4747
)`);
4848
}

src/lib/generateCode/targets/python.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function parseBody(body) {
2020
}
2121

2222
if (mime === 'application/json' && body.text) {
23-
return `payload = ${JSON.stringify(JSON.parse(body.text), null, 2)}`;
23+
return `payload = ${JSON.stringify(JSON.parse(body.text), null, 2)}\n\nfiles = null`;
2424
}
2525

2626
return body.text
27-
? `payload = '${body.text}'`
28-
: null;
27+
? `payload = '${body.text}'\n\nfiles = null`
28+
: 'files = null';
2929
}
3030

3131
export default function python(url, req) {

0 commit comments

Comments
 (0)