{"repo":"jellydn/next-swagger-doc","free":true,"listed":false,"github":"https://github.com/jellydn/next-swagger-doc","clone":"git clone https://github.com/jellydn/next-swagger-doc.git","description":"This package reads your JSDoc-annotated source code on NextJS API route and generates an OpenAPI (Swagger) specification.","language":"TypeScript","stars":519,"topics":["nextjs","swagger","next-swagger","next-swagger-doc","hacktoberfest"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"Welcome to next-swagger-doc 👋 Generate Swagger JSON API from NextJS Api Routes If you enjoy working with next-swagger-doc, you will love next-validations: NextJS API Validations, support Zod, Yup, Fastest-Validator, Joi, and more 🏠 Homepage ✨ Demo Prerequisites - Nextjs = 9 - Node = 18 Motivation This package reads your JSDoc-annotated source code on NextJS API route and generates an OpenAPI (Swagger) specification. nextjs + swagger-jsdoc = next-swagger-doc Install Usage #1: next-swagger-doc with Next.js 13 To incorporate next-swagger-doc with your Next.js 13 project, follow these steps. This setup will generate Swagger documentation for your API based on your code and provide a built-in Swagger UI for viewing the documentation. 1. Create Swagger Spec Next, create a new file lib/swagger.ts . This file uses the next-swagger-doc library to create a Swagger specification based on the API routes in your Next.js project. 2. Create Swagger UI Component Generate a new file named app/api-doc/react-swagger.tsx . In this file, create and export a React component that utilizes the swagger-ui-react library to render the Swagger UI according to the provided specification. For demonstration purposes, here is an example using swagger-ui-react Feel free to employ any alternative swagger UI library, such as stoplightio/elements. I have added an example using this library in the example folder. 3. Create API Documentation Page Create a new file app/api-doc/page.tsx . This page imports the Sw","default_branch":null,"files":null,"tree":[],"storefront":"/r/jellydn","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/jellydn/next-swagger-doc/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}