0.1.0 • Published 2 years ago

@exotjs/swagger v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

OpenAPI / Swagger plugin for Exot

This plugin auto-generates OpenAPI specification for the parent Exot instance.

It adds two new endpoints:

GET /swagger.json - returns OpenAPI specs in JSON.

GET /swagger - serves OpenAPI UI.

Usage

import { Exot, t } from '@exotjs/exot';
import { swagger } from '@exotjs/swagger';

new Exot()
  // mount plugin
  .use(swagger())

  // add routes
  .post('/', async ({ json }) => {
    return {
      received: await json(),
    };
  }, {
    body: t.Object({
      name: t.String(),
    }, {
      description: 'Payload with user\'s name',
    }),
    swagger: {
      description: '...',
      summary: 'Say hi'
    },
  })

  // bind port
  .listen(3000);

License

MIT

0.1.0

2 years ago

0.0.1

2 years ago