@omer-x/next-swagger-jsdoc
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Next Swagger JSDoc

Description

A Next.js plugin to generate Swagger documentation using JSDoc annotations.

Installation

npm install @omer-x/next-swagger-jsdoc

Usage

API Documentation Generation

import { generateApiDocs } from "@omer-x/next-swagger-jsdoc";

const apiSpec = generateApiDocs("./src/models/*.ts");

React Component for Swagger UI

import React from "react";
import { ReactSwagger } from "@omer-x/next-swagger-jsdoc";

const Page = () => {
  const spec = generateApiDocs("./src/models/*.ts");
  return <ReactSwagger spec={spec} />;
};

export default Page;

Swagger Route Example (Next.js)

// ./src/app/swagger/route.ts

import { generateApiDocs } from "next-swagger-jsdoc";

export function GET() {
  const spec = generateApiDocs("./src/models/*.ts");
  return Response.json(spec);
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i @omer-x/next-swagger-jsdoc

Weekly Downloads

30

Version

0.1.2

License

MIT

Unpacked Size

4.79 kB

Total Files

7

Last publish

Collaborators

  • omer-x