0.3.2 • Published 4 years ago

@ev-fns/openapi v0.3.2

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

@ev-fns/openapi

swagger-ui openapi parser middleware

Install

yarn add @ev-fns/openapi

Example

const express = require("express");
const openapi = require("@ev-fns/openapi");

const app = express();

app.use(openapi());

app.listen(3000, () => {
  console.log("listening on http://localhost:3000");
});

Usage

1. Define openapi schemas on a schemas.yml file at the root level

components:
  schemas:
    Error:
      type: object
      properties:
        message:
          type: string
          example: Internal server error
      required:
        - message

2. Comment the routes with the openapi-comment-parser syntax

https://github.com/bee-travels/openapi-comment-parser

const express = require("express");
const { getEmployees } = require("./employees");

const router = express.Router();

/**
 * GET /employees
 * @tag Employees
 * @response 200
 * @responseContent {Employee} 200.application/json
 * @response default
 * @responseContent {Error} default.application/json
 */
router.get("/employees", getEmployees);

module.exports = router;
0.3.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.0

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago