Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lambda-lambda-lambda/swagger-converter

Repository files navigation

L3 Swagger converter

Convert a Swagger/OpenAPI schema to a new L3 application. ⚠️ Work In Progress ⚠️

How it works

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());
 }
}

Dependencies

Developers

CLI options

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

Author

Marc S. Brooks

About

Convert a Swagger/OpenAPI schema to a new L3 application.

Resources

License

Stars

Watchers

Forks

Contributors

AltStyle によって変換されたページ (->オリジナル) /