1.2.4 • Published 1 year ago

openapi2plantuml v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

OpenApi 2 Plantuml

Known Vulnerabilities

Parse your REST API documentation written using OpenApi or Swagger to generate PlantUML diagrams.

See this library in action

Installation

npm install openapi2plantuml

Usage

const OpenApi2PlantUml = require('openapi2plantuml');

const documentation = `
openapi: 3.0.0
info:
  title: My amazing API
  version: 1.0.0
[...]
`

const generator = new OpenApi2PlantUml(documentation)
await generator.execute()
const diagrams = generator.getDiagrams()

An example of getDiagrams() output is the following:

{
  "/this/is/a/path": {
      "POST": {
        "request": {
          "diagram": "The plantUml diagram in text format",
          "imageUri": "The URI of the image that renders the diagram"
        },
        "response": {
          "diagram": "The plantUml diagram in text format",
          "imageUri": "The URI of the image that renders the diagram"
        }
      }
    }
}

Options

The constructor accepts as second argument a options object.

const generator = new OpenApi2PlantUml(documentation, {
  serverUrl: 'https://www.plantuml.com/plantuml',
  format: 'svg',
  diagramHeader: '',
  colors: true,
})
NameTypeDefaultDescription
serverUrlstring'https://www.plantuml.com/plantuml'The URL of the PlantUML server.
formatstring'png'The format of the image generated (png or svg).
diagramHeaderstring''The header of the diagram that will be put at the begin of each diagram. This option is usally used to apply a default theme to all diagrams.
colorsbooleantrueEnable colors to class properties and types.
1.2.0

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.0

2 years ago

1.0.0

2 years ago