omermecitoglu / next-openapi-json-generator Goto Github PK
View Code? Open in Web Editor NEWa Next.js plugin to generate OpenAPI documentation from route handlers
License: MIT License
a Next.js plugin to generate OpenAPI documentation from route handlers
License: MIT License
@omermecitoglu I was looking to add security schemas.
The current documentation suggests this:
const spec = await generateOpenApiSpec({
schema
});
I see no way to edit the info or components:
return {
openapi: "3.1.0",
info: {
title: metadata.serviceName,
version: metadata.version,
},
paths: bundlePaths(validRoutes, schemas),
components: {
schemas: bundleSchemas(schemas),
},
tags: [],
} as OpenApiDocument;
Would it be possible to provide a way to extend the info, component security schemas?
Here's a repo you might find helpful for inspiration: https://github.com/jellydn/next-swagger-doc
createSwaggerSpec({
apiFolder: 'app/api', // define api folder under app folder
definition: {
openapi: '3.0.0',
info: {
title: 'Next Swagger API Example',
version: '1.0'
},
components: {
securitySchemes: {
BearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT'
}
}
},
security: []
}
});
On Windows, the path of the operation is invalid.
Perhaps it can be solved like this:
function getRoutePathName(filePath: string, rootPath: string) {
return filePath
.replace(rootPath, "")
.replace("[", "{")
.replace("]", "}")
.replaceAll("\\", "/") // add this line
.replace("/route.ts", "");
}
When using pnpm to run "@omer-x/next-openapi-json-generator": "^0.2.5"
there's a warning that occurs every single time generateOpenApiSpec
is called.
โ ./node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js
Critical dependency: the request of a dependency is an expression
Import trace for requested module:
./node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js
./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@omer-x/next-openapi-json-generator/dist/index.js
./app/openapi/route.ts
Hi. Found this, looks cool.
But for starters (and existing project with a lot of routes) it would be great to generate a spec simply based on standard Next.js route.ts
handlers and JSDoc. It would be really cool.
I checked Route Handler as well, looks pretty useful. But migration would take a lot of time and I need a quicker solution for now over my plain Next.js app codepase to at least list all API endpoints (and use some data from JSDoc if possible).
Does it make sense?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.