@forinda/kickjs-swagger 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @forinda/kickjs-swagger
|
|
2
|
+
|
|
3
|
+
Auto-generated OpenAPI spec from decorators, Swagger UI, and ReDoc for KickJS.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @forinda/kickjs-swagger @forinda/kickjs-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- `SwaggerAdapter` — serves Swagger UI at `/docs`, ReDoc at `/redoc`, JSON at `/openapi.json`
|
|
14
|
+
- Decorators: `@ApiTags`, `@ApiOperation`, `@ApiResponse`, `@ApiBearerAuth`, `@ApiExclude`
|
|
15
|
+
- Auto-converts Zod validation schemas to OpenAPI JSON Schema
|
|
16
|
+
- Pluggable `SchemaParser` — use Joi, Yup, Valibot instead of Zod
|
|
17
|
+
- Schemas registered in `components.schemas` for the Models section
|
|
18
|
+
|
|
19
|
+
## Quick Example
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { SwaggerAdapter } from '@forinda/kickjs-swagger'
|
|
23
|
+
|
|
24
|
+
bootstrap({
|
|
25
|
+
modules,
|
|
26
|
+
adapters: [
|
|
27
|
+
new SwaggerAdapter({
|
|
28
|
+
info: { title: 'My API', version: '1.0.0' },
|
|
29
|
+
bearerAuth: true,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Custom Schema Parser (Joi)
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { type SchemaParser } from '@forinda/kickjs-swagger'
|
|
39
|
+
|
|
40
|
+
const joiParser: SchemaParser = {
|
|
41
|
+
name: 'joi',
|
|
42
|
+
supports: (schema) => Joi.isSchema(schema),
|
|
43
|
+
toJsonSchema: (schema) => joiToJson(schema),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
new SwaggerAdapter({ schemaParser: joiParser })
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Documentation
|
|
50
|
+
|
|
51
|
+
[Full documentation](https://github.com/forinda/kick-js)
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs-swagger",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "OpenAPI spec generation from decorators, Swagger UI and ReDoc serving for KickJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"reflect-metadata": "^0.2.2",
|
|
19
|
-
"@forinda/kickjs-core": "0.3.
|
|
19
|
+
"@forinda/kickjs-core": "0.3.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"express": "^5.1.0",
|