0.84.3 • Published 5 months ago

@dzangolab/fastify-swagger v0.84.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@dzangolab/fastify-swagger

A Fastify plugin that provides an easy integration of swagger in fastify API.

Installation

Install with npm:

npm install @dzangolab/fastify-swagger

Install with pnpm:

pnpm add --filter "@scope/project @dzangolab/fastify-swagger

Configuration

To configure the swagger, add the following settings to your config/swagger.ts file:

import type { SwaggerOptions } from "@dzangolab/fastify-swagger";

const swaggerConfig: SwaggerOptions = {
  enabled: true,
  fastifySwaggerOptions: {
    openapi: {
      info: {
        title: "Test API",
        version: "1.0.0",
      },
      servers: [
      {
        url: 'http://localhost:3000',
        description: 'Development server'
      }
    ],
    },
  },
};

export default swaggerConfig;

Usage

Register the plugin with your Fastify instance:

import Fastify from "fastify";
import swaggerPlugin from "@dzangolab/fastify-swagger"

import swaggerConfig from "./config/swagger"

const start = async () => {
  // Create fastify instance
  const fastify = Fastify();

  await fastify.register(swaggerPlugin, swaggerOptions);

  await fastify.listen({
    port: 3000,
    host: "0.0.0.0",
  });
};

start();
0.84.3

5 months ago

0.84.2

5 months ago

0.84.1

5 months ago

0.84.0

5 months ago