Replies: 12 comments 8 replies
-
I am looking for the exact same answer. is next.js not supposed to be used for building api servers? There are threads about generating API documentation but none of them have answers or responses :( |
Beta Was this translation helpful? Give feedback.
-
Okay, I did some homework, and I think I found out the answer. The background for my question is that, I am a ASP.NET API developer. In ASP.NET (standard, core, version 5), have built in systems to automatically generate API documentation. Further, generating swagger documentation is as simple as plugging a swagger nugget package and we are good to go. It's easy and convenient and so on. After spending hours and hours growing through different documentations of different frameworks (Next.JS, Node JS, Express JS), and so many stack overflow and so many reference books from my digital library subscription, I have realised that, a system (like in .NET) to automatically generate API documentation simply does not exist. Which explains why there is no content related to it. From what I understand, we have to build out our own API documentation using Swagger specification, and then, use Swagger documentation generator to generate the API documentation. There are some tools which will help in writing the swagger specification, but ultimately, it has to be done by hand, manually. For a moment there, I thought, Postman might help. Postman does not currently have a option to export in Swagger Spec. There are (paid) services that allow Postman stuff to be exported to Swagger Spec. Ultimately, it comes down to who and how the swagger spec file gets created. Once the documentation is ready in Swagger Spec, the actual documentation generation itself is automatic. Hopefully, this will help others who come looking (perhaps from .NET) for something similar. Of course, if I am wrong, that would be a relief, and please correct my views above. |
Beta Was this translation helpful? Give feedback.
-
Ability to generate OpenAPI Specs will be great |
Beta Was this translation helpful? Give feedback.
-
There isn't a built-in way to do this, however you can use open-source tools like Slate or ReDoc for generating the UI for you, although manual data entry is still required, and there's nothing wrong with it. |
Beta Was this translation helpful? Give feedback.
-
I made a little npm library that auto-generates Swagger docs from your NextJS project. No user input needed! Just run |
Beta Was this translation helpful? Give feedback.
-
I don't know if my response is still relevant at this point but, I found this library that has helped me out building the api docs using swagger You would need to install next-swagger-doc and swagger-ui-react to make it work |
Beta Was this translation helpful? Give feedback.
-
Hi, we are using https://github.com/blomqma/next-rest-framework for the purpose of having a Swagger for our API. The project is very early, but it would be very cool if this or a similar tool could gain traction and perhaps be integrated in NEXT I have the feeling that with the introduction of server side component in Next 13, more and more people will have a need to access their API documentation |
Beta Was this translation helpful? Give feedback.
-
Cannot get any of the solutions suggested here to work at all. How is this not a more highly demanded feature?? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Still looking for a solution that helps automate API doc generation. |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
I needed something like that, so I built one:
Try it with: npx nextjs-swagger-gen -a /path/to/your/app -o /path/to/write/swagger.json or simply from the root of your next project with : npx nextjs-swagger-gen -a ./app -o ./swagger.json It is custom for my needs for a nextjs, app router, ts, project, but the code is also there if you want to adapt it on your case. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does Next.js have a convenient way to generate documentation for
/api
routes? Or are there external tools which would make it easy to generate documentation?Beta Was this translation helpful? Give feedback.
All reactions