0.0.20 • Published 5 years ago

node-swagger-models v0.0.20

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

node-swagger-models

Generate javascript models from a self-documenting Swagger API.

Install

$ npm install -g node-swagger-models

Usage

node-swagger-models nsmconfig.json

nsmconfig.json

{
  "fileOutput": "./tmp",
  "filePrefix": "",  
  "api": "http://localhost:1802/api-docs/v1/swagger.json",
  "format": "backbone|vanilla|classout|typescript|typescript_interface"
}

node-swagger-models

package.json

...
node-swagger-models : {
  "fileOutput": "./tmp",
  "filePrefix": "",  
  "api": "http://localhost:1802/api-docs/v1/swagger.json",
  "format": "backbone"
}
...

node-swagger-models nsmconfig.js

nsmconfig.js

// Using a js config allows for custom formatters
module.exports = {
  "fileOutput": "./tmp",
  "filePrefix": "",  
  "api": "http://localhost:1802/api-docs/v1/swagger.json",
  "format": function(type, urlRoot, modelName, model, scriptModel, scriptValidation) {
    return ['module.exports = {', scriptModel.join('\n'), '};']
  }
}

Available formatters

  • backbone models (backbone)
  • plain json (vanilla)
  • typescript models (typescript)
  • js class (classout)
  • typescript interfaces (typescript_interface)

Notes

There is support for a vender extension on the swagger schemadefintion.
x-key to denote the primary key of the model.
For the backbone models this will translate to the idAttribute.

For an example of a venderextension with swashbuckle (dotnet) see the extra folder.
(If you know better ways to create a venderextension, please let me know)

Other models can be generated by creating a template in lib/formatters/.

Typescript will generate .ts files, all others will be .js

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.14

6 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago