Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openapi-ui/nodejs-openapi-ui
A middleware collection for NodeJS using OpenAPI-UI
https://github.com/openapi-ui/nodejs-openapi-ui
express-openapi-ui hono-openapi-ui nestjs-openapi-ui openapi-ui swagger-ui
Last synced: about 2 months ago
JSON representation
A middleware collection for NodeJS using OpenAPI-UI
- Host: GitHub
- URL: https://github.com/openapi-ui/nodejs-openapi-ui
- Owner: openapi-ui
- License: mit
- Created: 2024-05-16T08:13:57.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-04T09:11:50.000Z (7 months ago)
- Last Synced: 2024-08-08T21:52:55.164Z (5 months ago)
- Topics: express-openapi-ui, hono-openapi-ui, nestjs-openapi-ui, openapi-ui, swagger-ui
- Language: TypeScript
- Homepage: http://www.openapi-ui.com
- Size: 325 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NodeJS-OpenAPI-UI
A middleware collection for using the [OpenAPI-UI](https://github.com/rookie-luochao/openapi-ui) with NodeJS
## List of Contents
- List of Contents
- [Usage](#Usage)
- [NestJS](#nestjs)
- [Express](#express)
- [Hono](#hono)
- [License](#license)## Usage
### NestJS
```ts
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import { openApiUIReference } from "@openapi-ui/nestjs-openapi-ui";const app = await NestFactory.create(AppModule);
const config = new DocumentBuilder()
.setTitle('Cats example')
.setDescription('The cats API description')
.setVersion('1.0')
.addTag('cats')
.build()const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("swagger", app, document, {
jsonDocumentUrl: "/openapi.json",
});app.use(
"/openapi",
openApiUIReference({
specPath: "/openapi.json",
}),
);
```Read more: [@openapi-ui/nestjs-openapi-ui](https://github.com/openapi-ui/nodejs-openapi-ui/tree/main/packages/nestjs-openapi-ui)
### Express
```ts
import { openApiUIReference } from '@openapi-ui/express-openapi-ui';
import swaggerJsdoc from "swagger-jsdoc";const openApiSpec = swaggerJsdoc({
definition: {
openapi: "3.0.0",
info: {
title: "Hello World",
version: "1.0",
},
},
apis: ["./src/*.ts"], // files containing annotations as above
});app.get('/openapi.json', (req, res) => {
res.json(openApiSpec);
});app.use(
'/openapi',
openApiUIReference({
specPath: '/openapi.json',
}),
);
```Read more: [@openapi-ui/express-openapi-ui](https://github.com/openapi-ui/nodejs-openapi-ui/tree/main/packages/express-openapi-ui)
### Hono
```ts
import { openApiUIReference } from '@openapi-ui/hono-openapi-ui';app.doc('/openapi.json', {
info: {
title: 'Example API',
description: 'Example API description',
version: '1.0.0',
},
openapi: '3.0.0',
});app.use(
'/openapi',
openApiUIReference({
specPath: '/openapi.json',
}),
);
```Read more: [@openapi-ui/hono-openapi-ui](https://github.com/openapi-ui/nodejs-openapi-ui/tree/main/packages/hono-openapi-ui)
## License
[MIT](https://github.com/openapi-ui/nodejs-openapi-ui/blob/main/LICENSE)