forked from mrin9/RapiPdf
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial rewrite of RapiPdf as a cli tool
- Loading branch information
Stefan Schubert
authored and
Stefan Schubert
committed
Sep 24, 2021
1 parent
978516c
commit c0fe3a6
Showing
176 changed files
with
4,006 additions
and
60,301 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['prettier'], | ||
extends: ['prettier', 'plugin:prettier/recommended'], | ||
root: true, | ||
env: { | ||
node: true, | ||
}, | ||
rules: { | ||
'prettier/prettier': ['error', { 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,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"printWidth": 120 | ||
} |
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,24 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2019-2021 | ||
Mrinmoy Majumdar <[email protected]> | ||
Stefan Schubert <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file was deleted.
Oops, something went wrong.
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,38 +1,20 @@ | ||
<img alt="MrinDoc logo" src="https://github.com/mrin9/RapiPdf/blob/master/logo.png" width="60px" /> | ||
# OpenApi2Pdf | ||
|
||
|
||
<p align="center"> | ||
<img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square"/> | ||
<img src="https://img.shields.io/github/size/mrin9/rapipdf/dist/rapipdf-min.js.svg?colorB=blue&label=minified&style=flat-square"> | ||
<img src="https://img.shields.io/github/size/mrin9/rapipdf/dist/rapipdf-min.js.gz.svg?colorB=blue&label=zip&style=flat-square"> | ||
</p> | ||
|
||
# RapiPDF | ||
Custom element for Open-API to PDF generation | ||
Converts a openapi spec file to pdf. Based on [RapiPDF](https://github.com/mrin9/RapiPdf) | ||
|
||
## Features | ||
|
||
- Supports Swagger 2.0 and OpenAPI 3.0 | ||
- Generate PDF using Web-Component | ||
- Works with any framework or with no framework | ||
- Plenty of customizing options, including selection of brand colors | ||
- Supported on Chrome, FireFox and Safari. (Not yet tested on Edge) | ||
|
||
## Documentation | ||
[Check out the usage and examples](https://mrin9.github.io/RapiPdf/) | ||
## Usage | ||
|
||
## Build Process | ||
We recommend `yarn` over `npm` as we use yarn [resolutions](https://yarnpkg.com/lang/en/docs/selective-version-resolutions/) to keep the bundle size smaller. As of this writing this feature is not supported in npm natively | ||
```bash | ||
# Clone / Download the project then | ||
yarn install | ||
npm install -g openapi2pdf | ||
|
||
# build will generate rapidoc-min.js, this is the only file you will need. | ||
# use it in the script tag of your html <script type="text/javascript" src="rapidoc-min.js"></script></body> | ||
yarn build | ||
openapi2pdf --spec ~/home/openapi-spec.json --out ~/home/pdf-spec.pdf | ||
``` | ||
|
||
# for developement use yarn serve (this will start an webserver at port 8080, then navigate to localhost:8080) | ||
yarn serve | ||
## Licence | ||
|
||
# alternative to yarn serve: (this will start an webserver at port 8080 listening to all adapters) | ||
yarn serve-everyone | ||
``` | ||
OpenApi2Pdf is [MIT licensed](LICENSE). |
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,79 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
import createPdf from '../src/pdf-gen.mjs'; | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import yargs from 'yargs'; | ||
import { hideBin } from 'yargs/helpers'; | ||
|
||
const argv = yargs(hideBin(process.argv)) | ||
.option('spec', { | ||
alias: 's', | ||
type: 'string', | ||
description: 'openapi spec file to convert', | ||
requiresArg: true, | ||
demandOption: true, | ||
}) | ||
.option('out', { alias: 'o', type: 'string', description: 'output file', requiresArg: true, demandOption: true }) | ||
.option('primaryColor', { type: 'string', description: 'primary color to use in document', requiresArg: true }) | ||
.help().argv; | ||
|
||
export async function generatePdf() { | ||
try { | ||
const data = await createPdf(JSON.parse(readFileSync(argv.spec, { encoding: 'utf-8' })), { | ||
pdfSortTags: false, | ||
pdfPrimaryColor: argv.primaryColor ? argv.primaryColor : '', | ||
// pdfAlternateColor: '', | ||
pdfTitle: 'API Reference', | ||
pdfCoverText: '', | ||
pdfSecurityText: '', | ||
pdfApiText: '', | ||
pdfSchemaStyle: 'object', | ||
pdfFooterText: '', | ||
includeInfo: true, | ||
includeToc: true, | ||
includeSecurity: true, | ||
includeExample: false, | ||
includeApiDetails: true, | ||
includeApiList: false, | ||
localize: { | ||
index: 'INDEX', | ||
api: 'API', | ||
apiList: 'API List', | ||
apiReference: 'API Reference', | ||
apiVersion: 'API Version', | ||
contact: 'CONTACT', | ||
name: 'NAME', | ||
email: 'EMAIL', | ||
url: 'URL', | ||
termsOfService: 'Terms of service', | ||
securityAndAuthentication: 'Security and Authentication', | ||
securitySchemes: 'SECURITY SCHEMES', | ||
key: 'KEY', | ||
type: 'TYPE', | ||
example: 'EXAMPLE', | ||
description: 'DESCRIPTION', | ||
request: 'REQUEST', | ||
requestBody: 'REQUEST BODY', | ||
response: 'RESPONSE', | ||
responseModel: 'RESPONSE MODEL', | ||
statusCode: 'STATUS CODE', | ||
deprecated: 'DEPRECATED', | ||
allowed: 'ALLOWED', | ||
default: 'DEFAULT', | ||
readOnly: 'READ ONLY', | ||
writeOnly: 'WRITE ONLY', | ||
enumValues: 'ENUM', | ||
pattern: 'PATTERN', | ||
parameters: 'Parameters', | ||
noRequestParameters: 'No request parameters', | ||
method: 'METHOD', | ||
}, | ||
}); | ||
|
||
writeFileSync(argv.out, data); | ||
} catch (e) { | ||
console.error('Something went wrong! Please check your input parameters!'); | ||
} | ||
} | ||
generatePdf(); |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.