OpenAPI generator for NextJS

3.1k Views Asked by At

I have a NextJS project which uses the /api path for implementation of our API. We use an openapi.yaml file to define the interface. The following command generates the API client and works great:

openapi-generator-cli generate -i data/api/openapi.yaml -o src/api/openapi -g typescript-fetch

I am now trying to generate the stubs for implementing the server side of the API (which should be called under the /api). I tried the following which shows an error:

openapi-generator-cli generate -i data/api/openapi.yaml -o src/api/openapi -g next

This is because it cannot find a 'next' generator:

Can't load config class with name 'next' Available: ... here comes a list of generators

I noticed that there is a typescript-node generator but my project uses Next.JS and not plain node. Is there a way to re-use the node generator or another way?

1

There are 1 best solutions below

0
Mads Hougesen On

As of 21th of September 2023 there is no server generator for Next.js.

It is not possible to reuse that standard Node generator without heavy alterations.

You can find a list of server generators in the documentation.