Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.
/ dna-to-openapi Public archive

given holochain dna, generate a swagger / openapi spec file

Notifications You must be signed in to change notification settings

holochain/dna-to-openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dna-to-openapi

given holochain dna, generate a swagger / openapi spec file / static swagger-ui html documentation

usage

commandline

$ npm install -g @holochain/dna-to-openapi

$ dna-to-openapi -h

Usage dna-to-openapi [options]

Options:
  -p, --path     specify a path (otherwise ".")
  -s, --spec     generates an open-api spec file ("-" for stdout)
  -d, --doc      generates a static swagger-ui html doc ("-" for stdout)
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

Examples:
  dna-to-openapi                            lints the given holo app / dna
  dna-to-openapi --path <path>              to specify a path (otherwise ".")
  dna-to-openapi --spec <spec-file.json>    generates an open-api spec
  dna-to-openapi --doc <api-doc.html>       generates static swagger-ui html doc
  dna-to-openapi --spec <spec-file.json>    does both
  --doc <api-doc.html>

as a library

const dna = require('@holochain/dna-to-openapi')

// 1 - lint
const lintResults = dna.lint(dnaJsonObject, schemasObject)

// if there are errors (lintResults.errors), abort here.
// generating a spec file with lint errors may not work
if (lintResults.errors.length > 0) {
  process.exit(1)
}

// 2 - generate openapi spec
const specJson = dna.convert(dnaJsonObject, schemasObject)

// 3 - generate swagger-ui html
const swaggerHtml = dna.genDocs(specJson)

About

given holochain dna, generate a swagger / openapi spec file

Resources

Stars

Watchers

Forks

Packages

No packages published