Skip to content

MaxW1337/swagger-spec-to-pdf

 
 

Repository files navigation

swagger-spec-to-pdf

codebeat badge dependabot badge david-dm badge

Originally forked from agreatfool swagger-spec-to-pdf

Install

npm install -g MaxW1337/swagger-spec-to-pdf

Usage

usage: swagger2pdf [-h] [-v] [-s SRC] [-j] [-y] [-o OUTPUT]

Optional arguments:
  -h, --help            Show this help message and exit.
  -v, --version         Show program's version number and exit.
  -s SRC, --src SRC     Swagger spec JSON file.
  -j, --json            Spec file in JSON format (default).
  -y, --yaml            Spec file in YAML format.
  -o OUTPUT, --output OUTPUT
                        Output path of the pdf file.

Exec

For JSON files:

swagger2pdf -j -s ./swagger-spec-sample.json -o ./dump/

For YAML files:

swagger2pdf -y -s ./swagger-spec-sample.yaml -o ./dump/

In either case, the execution will take several seconds to complete.

Sample

See: ./dump/swagger-spec-sample.pdf

Change log

1.1.0

Support swagger spec files in YAML format, see: PR#13.

Appendix

Working Theory

In the case of a JSON input file:

  1. Read source swagger json spec
  2. Convert it into yaml format
  3. Dump yaml into the spec dir of swagger editor
  4. Use electron to render swagger editor page (nicely formatted api page)
  5. Dump the page into pdf

In the case of a YAML input file, steps 1-2 are bypassed.

Swagger Editor

This Application uses the swagger-editor-dist version of Swagger Editor

If you want to use some other version:

  • clone the repo
  • change version of swagger-editor-dist in package.json
  • npm install

Done, just use it.

About

Convert swagger/openapi v3 specifications into pdf document

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%