@cinnabun/openapi 0.0.1 → 0.0.6

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.
Files changed (2) hide show
  1. package/README.md +85 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # @cinnabun/openapi
2
+
3
+ Auto-generate OpenAPI 3.1 specs and Swagger UI for Cinnabun applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @cinnabun/openapi
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { CinnabunApp, CinnabunFactory } from "@cinnabun/core";
15
+ import { OpenApiModule } from "@cinnabun/openapi";
16
+
17
+ @CinnabunApp({
18
+ port: 3000,
19
+ scanPaths: [],
20
+ imports: [
21
+ OpenApiModule.forRoot({
22
+ title: "My API",
23
+ version: "1.0.0",
24
+ docsPath: "/api-docs",
25
+ jsonPath: "/api-docs/json",
26
+ }),
27
+ ],
28
+ })
29
+ class App {}
30
+
31
+ CinnabunFactory.run(App);
32
+ ```
33
+
34
+ Access Swagger UI at `http://localhost:3000/api-docs` and the JSON spec at `http://localhost:3000/api-docs/json`.
35
+
36
+ ## Decorators
37
+
38
+ Annotate controllers and DTOs for richer documentation:
39
+
40
+ ```typescript
41
+ import { RestController, GetMapping, PostMapping, Body } from "@cinnabun/core";
42
+ import { ApiTags, ApiOperation, ApiResponse, ApiProperty } from "@cinnabun/openapi";
43
+
44
+ @ApiTags("Users")
45
+ @RestController("/api/users")
46
+ class UserController {
47
+ @GetMapping("/")
48
+ @ApiOperation({ summary: "List all users" })
49
+ @ApiResponse({ status: 200, description: "User list" })
50
+ findAll() {
51
+ return [];
52
+ }
53
+
54
+ @PostMapping("/")
55
+ @ApiOperation({ summary: "Create user" })
56
+ @ApiResponse({ status: 201, description: "Created" })
57
+ create(@Body() body: CreateUserDto) {
58
+ return body;
59
+ }
60
+ }
61
+
62
+ class CreateUserDto {
63
+ @ApiProperty()
64
+ name!: string;
65
+
66
+ @ApiProperty()
67
+ email!: string;
68
+ }
69
+ ```
70
+
71
+ ## Configuration
72
+
73
+ ```typescript
74
+ interface OpenApiModuleOptions {
75
+ title?: string;
76
+ version?: string;
77
+ description?: string;
78
+ docsPath?: string; // default: "/api-docs"
79
+ jsonPath?: string; // default: "/api-docs/json"
80
+ }
81
+ ```
82
+
83
+ ## License
84
+
85
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinnabun/openapi",
3
- "version": "0.0.1",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",