SWAGGER-DEFINER
Document your api with ease
. . . .
. . . .
SWAGGER-DEFINER is a simple node.js library for defining Swagger 2.0 Spec.
- Simple API
- Built-in validation
- Use TypeScript Annotations or pure Javascript
Installation
$ npm install swagger-definer
Usage examples
// swagger.jsconst swg = "petstore.swagger.io" "/v2"swgswgsecurity"jwt" type: "apiKey" name: "Authorization" in: "header" description: "JWT Auth" swg
// UserModel.js // Using plain JSswg name: string // Or using TypeScript annotationsconst definition property = swg @ @ name: string = "Igor"
// UserRoutes.js // Using plain JSswg security"jwt" { console} // Or using TypeScript annotationsconst path parameter response security = swg // Annotations not working without class @ @ @ @ @ { console }
For more examples see: https://github.com/Sujimoshi/swagger-definer/tree/master/examples
About types
Definitionprototype
Types parsing table:
Common Name | type | format | Comments |
---|---|---|---|
integer | integer |
int32 |
signed 32 bits |
long | integer |
int64 |
signed 64 bits |
float | number |
float |
|
double | number |
double |
|
string | string |
||
byte | string |
byte |
base64 encoded characters |
binary | string |
binary |
any sequence of octets |
boolean | boolean |
||
date | string |
date |
As defined by full-date - RFC3339 |
dateTime | string |
date-time |
As defined by date-time - RFC3339 |
password | string |
password |
Used to hint UIs the input needs to be obscured. |