Never-ending Pumpkin Mulch

    @ev-fns/openapi
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.2 • Public • Published

    @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;

    Keywords

    none

    Install

    npm i @ev-fns/openapi

    DownloadsWeekly Downloads

    2

    Version

    0.3.2

    License

    MIT

    Unpacked Size

    7.95 kB

    Total Files

    8

    Last publish

    Collaborators

    • eliseuvideira