Convert a Swagger/OpenAPI schema to a new L3 application.
This command-line script parses the supported schema definitions (e.g API General Info, Paths and Operations) and scaffolds a new L3 application with predefined route/resource handlers.
For example, the JSON schema definition below, when parsed..
"/example/{resourceId}": { "put": { "description": "Example using `Route.create` handler alias.", "parameters": [ { "in": "path", "name": "resourceId", "schema": { "type": "string" } } ], "responses": { "201": { "description": "Returns JSON response.", "headers": { "Content-Type": { "schema": { "type": "string", "example": "application/json" } } } } } } }
would create a file in path <AppName>/routes/Example.js with the following:
module.exports = { resource: ['create'], /** * @openapi * * /example/{resourceId}: * get: * description: Example using `Route.index` handler alias. * responses: * 201: * description: Returns JSON response. * content: * application/json: * schema: * type: object * properties: * name: * type: string * headers: * Content-Type: * schema: * type: string * example: application/json */ index (req, res) { res.status(200).send(req.param()); } }
Compile JavaScript sources from TypeScript to a distribution:
$ npm run compile
Compile and listen for changes (development mode):
$ npm run watch
Run ESLint on project sources:
$ npm run lint
Run Mocha integration tests:
$ npm run test