Git Product home page Git Product logo

openapi-transformer's Introduction

OpenAPI transformer

Coverage Status

Node.js CI

Known Vulnerabilities

This tool creates one or more of the following from a Swagger 2 or OpenApi 3 specification -

Requirements

  • Swagger 2 or OpenAPI 3+ Specification
  • NodeJS

Usage

Always run the script from the directory in which the yaml file are.

Usage: index [options] <inputfile>

Options:
  -V, --version                       Output the version number
  -p, --plantuml <plantuml file>      The plantuml file
  -m, --markdown <markdown file>      The output file for markdown
  -j, --jsonschema <jsonschema file>  Transform to json schema
  -v, --verbose                       Show verbose debug output
  -h, --help                          Output usage information

Example

Generates to plantuml

openapi-transformer vehicle.yaml --plantuml vehicle.plantuml

Generates to plantuml with verbose debug info :)

openapi-transformer vehicle.yaml --verbose --plantuml vehicle.plantuml

Generates to plantuml file and markdown file

openapi-transformer vehicle.yaml --plantuml ./example.plantuml --markdown ./example.md

Example output plantuml

No details

Example no details

Details

Example with details

Online utils

openapi-transformer's People

Contributors

aebaugh avatar armand-janssen avatar armandjanssen1978 avatar dependabot[bot] avatar shelbys avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

openapi-transformer's Issues

Wrong type is used when attribute is using a $ref in plantuml and md

OpenApi:

        myFancyName:
          $ref: '#/components/schemas/myType'

Plantuml:
Actual:

myFancyName: myFancyName

Expected:

myFancyName: myType

MD:
Actual:

| myFancyName| &nbsp; | myFancyName| &nbsp; | &nbsp; | &nbsp; |

Expected:

| myFancyName| &nbsp; | myType| &nbsp; | &nbsp; | &nbsp; |

Installation

I am having trouble installing. I have tried
npm install armand-janssen/openapi-transformer
and it seems to return with no errors, but openapi-transformer is not on my PATH.

Am I missing a step or is the problem with my npm install?

Limit the $ref depth

Limit the $ref depth โ€“ Crawling all of our $refs leads to a huge graph (and unusable diagrams), where maybe for the UML we only want a certain depth. So, allowing a limit on the depth of references.

Does not follow html $ref

It will not follow a $ref that points to an html resource. Error is (company info removed)
UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open './https://artifactory.cloud.mycompany.com/artifactory/maven/common-.yaml'
at Object.openSync (fs.js:498:3)
at Object.readFileSync (fs.js:394:35)
at loadYamlFile (C:\Users\212708371\AppData\Roaming\npm\node_modules\openapi-transformer\src\index.js:59:21)
at C:\Users\212708371\AppData\Roaming\npm\node_modules\openapi-transformer\src\index.js:78:47
at Array.forEach ()
at Object.loadYamlFile (C:\Users\212708371\AppData\Roaming\npm\node_modules\openapi-transformer\src\index.js:77:23)
at C:\Users\212708371\AppData\Roaming\npm\node_modules\openapi-transformer\src\cli.js:30:53
at Object. (C:\Users\212708371\AppData\Roaming\npm\node_modules\openapi-transformer\src\cli.js:56:5)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
(Use node --trace-warnings ... to show where the warning was created)
(node:36168) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:36168) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Allow for circular $refs

#Allow for circular $refs โ€“ When resolving $refs it can lead to cycles, so only load files once

When using parenthesis in a regex pattern, then the field is rendered as a method in plantuml diagram

When PlantUML sees parenthesis, it assumes it is a method instead of a field.
You can prepend this file with {field} to override this.

OpenAPI Schema

components:
  schemas:
    someClass:
      type: Object
      properties:
        someField:
          type: string
          maxLength: 100
        problemField:
          type: string
          pattern: '^(NL|nl)([0-9]){5}$'
        someOtherField:
          type: string
          maxLength: 100

Generated PlantUML

@startuml
class someClass {
  someField : string [maxLength : 100]
  problemField : string [pattern : ^(NL|nl)([0-9]){5}$ ]
  someOtherField : string [maxLength : 100]
}

@enduml

Solution PlantUML

@startuml
class someClass {
  someField : string [maxLength : 100]
  {field} problemField : string [pattern : ^(NL|nl)([0-9]){5}$ ]
  someOtherField : string [maxLength : 100]
}
@enduml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.