@navios/openapi 0.7.0
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/LICENSE +8 -0
- package/README.md +260 -0
- package/dist/src/__tests__/decorators.spec.d.mts +2 -0
- package/dist/src/__tests__/decorators.spec.d.mts.map +1 -0
- package/dist/src/__tests__/metadata.spec.d.mts +2 -0
- package/dist/src/__tests__/metadata.spec.d.mts.map +1 -0
- package/dist/src/__tests__/services.spec.d.mts +2 -0
- package/dist/src/__tests__/services.spec.d.mts.map +1 -0
- package/dist/src/decorators/api-deprecated.decorator.d.mts +33 -0
- package/dist/src/decorators/api-deprecated.decorator.d.mts.map +1 -0
- package/dist/src/decorators/api-exclude.decorator.d.mts +26 -0
- package/dist/src/decorators/api-exclude.decorator.d.mts.map +1 -0
- package/dist/src/decorators/api-operation.decorator.d.mts +58 -0
- package/dist/src/decorators/api-operation.decorator.d.mts.map +1 -0
- package/dist/src/decorators/api-security.decorator.d.mts +36 -0
- package/dist/src/decorators/api-security.decorator.d.mts.map +1 -0
- package/dist/src/decorators/api-stream.decorator.d.mts +50 -0
- package/dist/src/decorators/api-stream.decorator.d.mts.map +1 -0
- package/dist/src/decorators/api-summary.decorator.d.mts +24 -0
- package/dist/src/decorators/api-summary.decorator.d.mts.map +1 -0
- package/dist/src/decorators/api-tag.decorator.d.mts +42 -0
- package/dist/src/decorators/api-tag.decorator.d.mts.map +1 -0
- package/dist/src/decorators/index.d.mts +8 -0
- package/dist/src/decorators/index.d.mts.map +1 -0
- package/dist/src/index.d.mts +5 -0
- package/dist/src/index.d.mts.map +1 -0
- package/dist/src/metadata/index.d.mts +2 -0
- package/dist/src/metadata/index.d.mts.map +1 -0
- package/dist/src/metadata/openapi.metadata.d.mts +30 -0
- package/dist/src/metadata/openapi.metadata.d.mts.map +1 -0
- package/dist/src/services/endpoint-scanner.service.d.mts +42 -0
- package/dist/src/services/endpoint-scanner.service.d.mts.map +1 -0
- package/dist/src/services/index.d.mts +6 -0
- package/dist/src/services/index.d.mts.map +1 -0
- package/dist/src/services/metadata-extractor.service.d.mts +19 -0
- package/dist/src/services/metadata-extractor.service.d.mts.map +1 -0
- package/dist/src/services/openapi-generator.service.d.mts +91 -0
- package/dist/src/services/openapi-generator.service.d.mts.map +1 -0
- package/dist/src/services/path-builder.service.d.mts +73 -0
- package/dist/src/services/path-builder.service.d.mts.map +1 -0
- package/dist/src/services/schema-converter.service.d.mts +57 -0
- package/dist/src/services/schema-converter.service.d.mts.map +1 -0
- package/dist/src/tokens/index.d.mts +18 -0
- package/dist/src/tokens/index.d.mts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/tsconfig.spec.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsdown.config.d.mts +3 -0
- package/dist/tsdown.config.d.mts.map +1 -0
- package/dist/vitest.config.d.mts +3 -0
- package/dist/vitest.config.d.mts.map +1 -0
- package/lib/index.cjs +2120 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +594 -0
- package/lib/index.d.cts.map +1 -0
- package/lib/index.d.mts +594 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +2077 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +44 -0
- package/project.json +66 -0
- package/src/__tests__/decorators.spec.mts +185 -0
- package/src/__tests__/metadata.spec.mts +207 -0
- package/src/__tests__/services.spec.mts +216 -0
- package/src/decorators/api-deprecated.decorator.mts +45 -0
- package/src/decorators/api-exclude.decorator.mts +29 -0
- package/src/decorators/api-operation.decorator.mts +59 -0
- package/src/decorators/api-security.decorator.mts +44 -0
- package/src/decorators/api-stream.decorator.mts +55 -0
- package/src/decorators/api-summary.decorator.mts +33 -0
- package/src/decorators/api-tag.decorator.mts +51 -0
- package/src/decorators/index.mts +7 -0
- package/src/index.mts +42 -0
- package/src/metadata/index.mts +2 -0
- package/src/metadata/openapi.metadata.mts +30 -0
- package/src/services/endpoint-scanner.service.mts +118 -0
- package/src/services/index.mts +21 -0
- package/src/services/metadata-extractor.service.mts +91 -0
- package/src/services/openapi-generator.service.mts +219 -0
- package/src/services/path-builder.service.mts +344 -0
- package/src/services/schema-converter.service.mts +96 -0
- package/src/tokens/index.mts +24 -0
- package/tsconfig.json +24 -0
- package/tsconfig.lib.json +8 -0
- package/tsconfig.spec.json +12 -0
- package/tsdown.config.mts +35 -0
- package/vitest.config.mts +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright 2025 Oleksandr Hanzha
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# @navios/openapi
|
|
2
|
+
|
|
3
|
+
Core OpenAPI package for Navios - Automatic OpenAPI 3.1 documentation generation.
|
|
4
|
+
|
|
5
|
+
This package provides the core functionality for generating OpenAPI documentation from your Navios controllers and endpoints. It automatically discovers endpoints, extracts type information from Zod schemas, and generates comprehensive OpenAPI specifications.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
`@navios/openapi` is the foundation package that provides decorators and services for OpenAPI documentation. It works with provider packages to add runtime-specific UI integration:
|
|
10
|
+
|
|
11
|
+
- `@navios/openapi-fastify` - For Fastify applications with Scalar UI
|
|
12
|
+
- `@navios/openapi-bun` - For Bun applications with Scalar UI
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Automatic endpoint discovery from controllers
|
|
17
|
+
- Zod schema to OpenAPI schema conversion
|
|
18
|
+
- Comprehensive decorator system for API documentation
|
|
19
|
+
- Type-safe metadata extraction
|
|
20
|
+
- Support for all endpoint types (standard, multipart, stream)
|
|
21
|
+
- OpenAPI 3.1 specification generation
|
|
22
|
+
- Rich schema metadata support via Zod `.meta()`
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @navios/openapi zod
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or with yarn:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
yarn add @navios/openapi zod
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### Basic Setup
|
|
39
|
+
|
|
40
|
+
This package is typically used through provider packages (`@navios/openapi-fastify` or `@navios/openapi-bun`), but you can also use the core services directly:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { NaviosFactory } from '@navios/core'
|
|
44
|
+
import {
|
|
45
|
+
EndpointScannerService,
|
|
46
|
+
MetadataExtractorService,
|
|
47
|
+
OpenApiGeneratorService,
|
|
48
|
+
} from '@navios/openapi'
|
|
49
|
+
|
|
50
|
+
// Use the services to generate OpenAPI spec programmatically
|
|
51
|
+
const generator = await container.get(OpenApiGeneratorService)
|
|
52
|
+
|
|
53
|
+
const spec = await generator.generate({
|
|
54
|
+
info: {
|
|
55
|
+
title: 'My API',
|
|
56
|
+
version: '1.0.0',
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Decorators
|
|
62
|
+
|
|
63
|
+
The package provides decorators to enhance your API documentation:
|
|
64
|
+
|
|
65
|
+
#### @ApiTag
|
|
66
|
+
|
|
67
|
+
Groups endpoints under tags in the documentation:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { Controller, Endpoint } from '@navios/core'
|
|
71
|
+
import { ApiTag } from '@navios/openapi'
|
|
72
|
+
|
|
73
|
+
@Controller()
|
|
74
|
+
@ApiTag('Users', 'User management operations')
|
|
75
|
+
class UserController {
|
|
76
|
+
@Endpoint(getUser)
|
|
77
|
+
async getUser() {}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### @ApiOperation
|
|
82
|
+
|
|
83
|
+
Provides detailed operation metadata:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { ApiOperation } from '@navios/openapi'
|
|
87
|
+
|
|
88
|
+
@Endpoint(getUser)
|
|
89
|
+
@ApiOperation({
|
|
90
|
+
summary: 'Get user by ID',
|
|
91
|
+
description: 'Retrieves a user by their unique identifier.',
|
|
92
|
+
operationId: 'getUserById',
|
|
93
|
+
deprecated: false,
|
|
94
|
+
})
|
|
95
|
+
async getUser() {}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### @ApiSummary
|
|
99
|
+
|
|
100
|
+
Shorthand for adding just a summary:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { ApiSummary } from '@navios/openapi'
|
|
104
|
+
|
|
105
|
+
@Endpoint(getUser)
|
|
106
|
+
@ApiSummary('Get user by ID')
|
|
107
|
+
async getUser() {}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### @ApiDeprecated
|
|
111
|
+
|
|
112
|
+
Marks an endpoint as deprecated:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { ApiDeprecated } from '@navios/openapi'
|
|
116
|
+
|
|
117
|
+
@Endpoint(legacyGetUser)
|
|
118
|
+
@ApiDeprecated('Use /v2/users/:id instead')
|
|
119
|
+
async getLegacyUser() {}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### @ApiSecurity
|
|
123
|
+
|
|
124
|
+
Specifies security requirements:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { ApiSecurity } from '@navios/openapi'
|
|
128
|
+
|
|
129
|
+
@Endpoint(getUser)
|
|
130
|
+
@ApiSecurity({ bearerAuth: [] })
|
|
131
|
+
async getUser() {}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### @ApiExclude
|
|
135
|
+
|
|
136
|
+
Excludes an endpoint from documentation:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { ApiExclude } from '@navios/openapi'
|
|
140
|
+
|
|
141
|
+
@Endpoint(healthCheck)
|
|
142
|
+
@ApiExclude()
|
|
143
|
+
async healthCheck() {
|
|
144
|
+
return { status: 'ok' }
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### @ApiStream
|
|
149
|
+
|
|
150
|
+
Specifies content type for stream endpoints:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import { ApiStream } from '@navios/openapi'
|
|
154
|
+
import { Stream } from '@navios/core'
|
|
155
|
+
|
|
156
|
+
@Stream(downloadFile)
|
|
157
|
+
@ApiStream({
|
|
158
|
+
contentType: 'application/octet-stream',
|
|
159
|
+
description: 'Download file as binary stream',
|
|
160
|
+
})
|
|
161
|
+
async download() {}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Schema Metadata
|
|
165
|
+
|
|
166
|
+
Add OpenAPI metadata to your Zod schemas:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import { z } from 'zod'
|
|
170
|
+
|
|
171
|
+
const userSchema = z
|
|
172
|
+
.object({
|
|
173
|
+
id: z.string().meta({
|
|
174
|
+
openapi: {
|
|
175
|
+
description: 'Unique user identifier',
|
|
176
|
+
example: 'usr_123abc',
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
name: z.string().meta({
|
|
180
|
+
openapi: {
|
|
181
|
+
description: 'User display name',
|
|
182
|
+
example: 'John Doe',
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
email: z
|
|
186
|
+
.string()
|
|
187
|
+
.email()
|
|
188
|
+
.meta({
|
|
189
|
+
openapi: {
|
|
190
|
+
description: 'User email address',
|
|
191
|
+
example: 'john@example.com',
|
|
192
|
+
format: 'email',
|
|
193
|
+
},
|
|
194
|
+
}),
|
|
195
|
+
})
|
|
196
|
+
.meta({
|
|
197
|
+
openapi: {
|
|
198
|
+
title: 'User',
|
|
199
|
+
description: 'Represents a user in the system',
|
|
200
|
+
},
|
|
201
|
+
})
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## API Reference
|
|
205
|
+
|
|
206
|
+
### Decorators
|
|
207
|
+
|
|
208
|
+
- `@ApiTag(name: string, description?: string)` - Tag endpoints
|
|
209
|
+
- `@ApiOperation(options: ApiOperationOptions)` - Full operation metadata
|
|
210
|
+
- `@ApiSummary(summary: string)` - Quick summary
|
|
211
|
+
- `@ApiDeprecated(reason?: string)` - Mark as deprecated
|
|
212
|
+
- `@ApiSecurity(requirements: ApiSecurityRequirement)` - Security requirements
|
|
213
|
+
- `@ApiExclude()` - Exclude from docs
|
|
214
|
+
- `@ApiStream(options: ApiStreamOptions)` - Stream endpoint metadata
|
|
215
|
+
|
|
216
|
+
### Services
|
|
217
|
+
|
|
218
|
+
- `OpenApiGeneratorService` - Main service for generating OpenAPI specs
|
|
219
|
+
- `EndpointScannerService` - Discovers endpoints from controllers
|
|
220
|
+
- `MetadataExtractorService` - Extracts decorator metadata
|
|
221
|
+
- `SchemaConverterService` - Converts Zod schemas to OpenAPI
|
|
222
|
+
- `PathBuilderService` - Builds OpenAPI path items
|
|
223
|
+
|
|
224
|
+
### Types
|
|
225
|
+
|
|
226
|
+
- `OpenApiGeneratorOptions` - Options for generating OpenAPI spec
|
|
227
|
+
- `OpenApiEndpointMetadata` - Endpoint metadata type
|
|
228
|
+
- `ApiOperationOptions` - Options for @ApiOperation decorator
|
|
229
|
+
- `ApiSecurityRequirement` - Security requirement type
|
|
230
|
+
|
|
231
|
+
## Requirements
|
|
232
|
+
|
|
233
|
+
- **Dependencies**:
|
|
234
|
+
- `@navios/core` - Core Navios framework
|
|
235
|
+
- `zod` ^3.25.0 || ^4.0.0 - Schema validation
|
|
236
|
+
- **Peer Dependencies**:
|
|
237
|
+
- `@navios/di` - Dependency injection (for service usage)
|
|
238
|
+
|
|
239
|
+
## Provider Packages
|
|
240
|
+
|
|
241
|
+
This core package is used by provider packages that add runtime-specific UI:
|
|
242
|
+
|
|
243
|
+
- **[@navios/openapi-fastify](../openapi-fastify/README.md)** - Fastify integration with Scalar UI
|
|
244
|
+
- **[@navios/openapi-bun](../openapi-bun/README.md)** - Bun integration with Scalar UI
|
|
245
|
+
|
|
246
|
+
## Examples
|
|
247
|
+
|
|
248
|
+
For complete working examples, see:
|
|
249
|
+
|
|
250
|
+
- [OpenAPI Examples](../../examples/openapi) - Full examples for both Fastify and Bun
|
|
251
|
+
- [OpenAPI Guide](../../apps/docs/docs/server/guides/openapi.md) - Comprehensive documentation
|
|
252
|
+
|
|
253
|
+
## Documentation
|
|
254
|
+
|
|
255
|
+
For complete documentation on using OpenAPI with Navios, see:
|
|
256
|
+
|
|
257
|
+
- [OpenAPI Guide](../../apps/docs/docs/server/guides/openapi.md)
|
|
258
|
+
- [Controllers & Endpoints](../core/docs/controllers.md)
|
|
259
|
+
- [Streaming](../core/docs/streaming.md)
|
|
260
|
+
- [Multipart](../core/docs/multipart.md)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.spec.d.mts","sourceRoot":"","sources":["../../../src/__tests__/decorators.spec.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.spec.d.mts","sourceRoot":"","sources":["../../../src/__tests__/metadata.spec.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.spec.d.mts","sourceRoot":"","sources":["../../../src/__tests__/services.spec.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
declare const ApiDeprecatedSchema: z.ZodObject<{
|
|
3
|
+
message: z.ZodOptional<z.ZodString>;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
/** Options for the @ApiDeprecated decorator, inferred from the schema */
|
|
6
|
+
export type ApiDeprecatedOptions = z.infer<typeof ApiDeprecatedSchema>;
|
|
7
|
+
/**
|
|
8
|
+
* Marks an endpoint as deprecated.
|
|
9
|
+
*
|
|
10
|
+
* Deprecated endpoints are shown with a visual indicator in documentation
|
|
11
|
+
* and may include a migration message.
|
|
12
|
+
*
|
|
13
|
+
* @param message - Optional deprecation message
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* @Controller()
|
|
18
|
+
* export class UserController {
|
|
19
|
+
* // Simple deprecation
|
|
20
|
+
* @Endpoint(legacyGetUser)
|
|
21
|
+
* @ApiDeprecated()
|
|
22
|
+
* async getLegacyUser() {}
|
|
23
|
+
*
|
|
24
|
+
* // With migration message
|
|
25
|
+
* @Endpoint(oldCreateUser)
|
|
26
|
+
* @ApiDeprecated('Use POST /v2/users instead')
|
|
27
|
+
* async oldCreateUser() {}
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function ApiDeprecated(message?: string): <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=api-deprecated.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-deprecated.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/api-deprecated.decorator.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAI1B,QAAA,MAAM,mBAAmB;;iBAEvB,CAAA;AAEF,yEAAyE;AACzE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAOtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,qFAE7C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excludes an endpoint from OpenAPI documentation.
|
|
3
|
+
*
|
|
4
|
+
* Use this decorator for internal endpoints that should not be visible
|
|
5
|
+
* in the public API documentation.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Controller()
|
|
10
|
+
* export class HealthController {
|
|
11
|
+
* @Endpoint(healthCheck)
|
|
12
|
+
* @ApiExclude()
|
|
13
|
+
* async healthCheck() {
|
|
14
|
+
* return { status: 'ok' }
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @Endpoint(internalMetrics)
|
|
18
|
+
* @ApiExclude()
|
|
19
|
+
* async internalMetrics() {
|
|
20
|
+
* return { ... }
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const ApiExclude: import("@navios/core").ClassAttribute;
|
|
26
|
+
//# sourceMappingURL=api-exclude.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-exclude.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/api-exclude.decorator.mts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,UAAU,uCAAoD,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
declare const ApiOperationSchema: z.ZodObject<{
|
|
3
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
4
|
+
description: z.ZodOptional<z.ZodString>;
|
|
5
|
+
operationId: z.ZodOptional<z.ZodString>;
|
|
6
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
externalDocs: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
url: z.ZodString;
|
|
9
|
+
description: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/** Options for the @ApiOperation decorator, inferred from the schema */
|
|
13
|
+
export type ApiOperationOptions = z.infer<typeof ApiOperationSchema>;
|
|
14
|
+
/**
|
|
15
|
+
* Provides detailed operation metadata for an endpoint.
|
|
16
|
+
*
|
|
17
|
+
* Use this decorator when you need to specify multiple operation properties.
|
|
18
|
+
* For simple cases, consider using @ApiSummary instead.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Operation configuration options
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* @Controller()
|
|
25
|
+
* export class UserController {
|
|
26
|
+
* @Endpoint(getUser)
|
|
27
|
+
* @ApiOperation({
|
|
28
|
+
* summary: 'Get user by ID',
|
|
29
|
+
* description: 'Retrieves a user by their unique identifier. Returns 404 if not found.',
|
|
30
|
+
* operationId: 'getUserById',
|
|
31
|
+
* })
|
|
32
|
+
* async getUser(params: EndpointParams<typeof getUser>) {}
|
|
33
|
+
*
|
|
34
|
+
* @Endpoint(legacyGetUser)
|
|
35
|
+
* @ApiOperation({
|
|
36
|
+
* summary: 'Get user (legacy)',
|
|
37
|
+
* deprecated: true,
|
|
38
|
+
* externalDocs: {
|
|
39
|
+
* url: 'https://docs.example.com/migration',
|
|
40
|
+
* description: 'Migration guide'
|
|
41
|
+
* }
|
|
42
|
+
* })
|
|
43
|
+
* async getLegacyUser() {}
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare const ApiOperation: import("@navios/core").ClassSchemaAttribute<z.ZodObject<{
|
|
48
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
49
|
+
description: z.ZodOptional<z.ZodString>;
|
|
50
|
+
operationId: z.ZodOptional<z.ZodString>;
|
|
51
|
+
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
externalDocs: z.ZodOptional<z.ZodObject<{
|
|
53
|
+
url: z.ZodString;
|
|
54
|
+
description: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=api-operation.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-operation.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/api-operation.decorator.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAI1B,QAAA,MAAM,kBAAkB;;;;;;;;;iBAWtB,CAAA;AAEF,wEAAwE;AACxE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,YAAY;;;;;;;;;kBAGxB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
declare const ApiSecuritySchema: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
|
|
3
|
+
/** Security requirement for an endpoint, inferred from the schema */
|
|
4
|
+
export type ApiSecurityRequirement = z.infer<typeof ApiSecuritySchema>;
|
|
5
|
+
/**
|
|
6
|
+
* Specifies security requirements for an endpoint.
|
|
7
|
+
*
|
|
8
|
+
* The security requirement object maps security scheme names to their scopes.
|
|
9
|
+
* For schemes that don't use scopes (like API keys), use an empty array.
|
|
10
|
+
*
|
|
11
|
+
* @param requirements - Security requirements object
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @Controller()
|
|
16
|
+
* export class UserController {
|
|
17
|
+
* // Require bearer token authentication
|
|
18
|
+
* @Endpoint(getUser)
|
|
19
|
+
* @ApiSecurity({ bearerAuth: [] })
|
|
20
|
+
* async getUser() {}
|
|
21
|
+
*
|
|
22
|
+
* // Require multiple authentication methods
|
|
23
|
+
* @Endpoint(adminEndpoint)
|
|
24
|
+
* @ApiSecurity({ bearerAuth: [], apiKey: [] })
|
|
25
|
+
* async adminAction() {}
|
|
26
|
+
*
|
|
27
|
+
* // OAuth2 with specific scopes
|
|
28
|
+
* @Endpoint(writeUser)
|
|
29
|
+
* @ApiSecurity({ oauth2: ['users:write', 'users:read'] })
|
|
30
|
+
* async writeUser() {}
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const ApiSecurity: import("@navios/core").ClassSchemaAttribute<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=api-security.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-security.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/api-security.decorator.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAI1B,QAAA,MAAM,iBAAiB,mDAA4C,CAAA;AAEnE,qEAAqE;AACrE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,WAAW,gGAGvB,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
declare const ApiStreamSchema: z.ZodObject<{
|
|
3
|
+
contentType: z.ZodString;
|
|
4
|
+
description: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
/** Options for the @ApiStream decorator, inferred from the schema */
|
|
7
|
+
export type ApiStreamOptions = z.infer<typeof ApiStreamSchema>;
|
|
8
|
+
/**
|
|
9
|
+
* Specifies content type and description for stream endpoints.
|
|
10
|
+
*
|
|
11
|
+
* Stream endpoints don't have a responseSchema, so this decorator provides
|
|
12
|
+
* the necessary metadata for OpenAPI documentation.
|
|
13
|
+
*
|
|
14
|
+
* @param options - Stream response options
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* @Controller()
|
|
19
|
+
* export class FileController {
|
|
20
|
+
* // Binary file download
|
|
21
|
+
* @Stream(downloadFile)
|
|
22
|
+
* @ApiStream({
|
|
23
|
+
* contentType: 'application/octet-stream',
|
|
24
|
+
* description: 'Download file as binary stream'
|
|
25
|
+
* })
|
|
26
|
+
* async download(params: StreamParams<typeof downloadFile>, reply: Reply) {
|
|
27
|
+
* // Stream implementation
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* @Controller()
|
|
32
|
+
* export class EventController {
|
|
33
|
+
* // Server-Sent Events
|
|
34
|
+
* @Stream(streamEvents)
|
|
35
|
+
* @ApiStream({
|
|
36
|
+
* contentType: 'text/event-stream',
|
|
37
|
+
* description: 'Real-time event stream'
|
|
38
|
+
* })
|
|
39
|
+
* async stream(params: StreamParams<typeof streamEvents>, reply: Reply) {
|
|
40
|
+
* // SSE implementation
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const ApiStream: import("@navios/core").ClassSchemaAttribute<z.ZodObject<{
|
|
46
|
+
contentType: z.ZodString;
|
|
47
|
+
description: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=api-stream.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-stream.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/api-stream.decorator.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAI1B,QAAA,MAAM,eAAe;;;iBAGnB,CAAA;AAEF,qEAAqE;AACrE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,SAAS;;;kBAGrB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/**
|
|
3
|
+
* Shorthand decorator for adding just a summary to an endpoint.
|
|
4
|
+
*
|
|
5
|
+
* This is equivalent to `@ApiOperation({ summary: '...' })` but more concise.
|
|
6
|
+
*
|
|
7
|
+
* @param summary - Short summary text for the endpoint
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Controller()
|
|
12
|
+
* export class UserController {
|
|
13
|
+
* @Endpoint(getUser)
|
|
14
|
+
* @ApiSummary('Get user by ID')
|
|
15
|
+
* async getUser() {}
|
|
16
|
+
*
|
|
17
|
+
* @Endpoint(createUser)
|
|
18
|
+
* @ApiSummary('Create a new user')
|
|
19
|
+
* async createUser() {}
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const ApiSummary: import("@navios/core").ClassSchemaAttribute<z.ZodString>;
|
|
24
|
+
//# sourceMappingURL=api-summary.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-summary.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/api-summary.decorator.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAM1B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,UAAU,0DAGtB,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
declare const ApiTagSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
description: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
/** Options for the @ApiTag decorator, inferred from the schema */
|
|
7
|
+
export type ApiTagOptions = z.infer<typeof ApiTagSchema>;
|
|
8
|
+
/**
|
|
9
|
+
* Groups endpoints under a specific tag/folder in the documentation.
|
|
10
|
+
*
|
|
11
|
+
* Can be applied to controllers (affects all endpoints) or individual methods.
|
|
12
|
+
* When applied to both, the method-level tag takes precedence.
|
|
13
|
+
*
|
|
14
|
+
* @param name - The tag name
|
|
15
|
+
* @param description - Optional tag description
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Apply to entire controller
|
|
20
|
+
* @Controller()
|
|
21
|
+
* @ApiTag('Users', 'User management operations')
|
|
22
|
+
* export class UserController {
|
|
23
|
+
* @Endpoint(getUser)
|
|
24
|
+
* async getUser() {}
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* // Apply to individual endpoint
|
|
28
|
+
* @Controller()
|
|
29
|
+
* export class MixedController {
|
|
30
|
+
* @Endpoint(getUser)
|
|
31
|
+
* @ApiTag('Users')
|
|
32
|
+
* async getUser() {}
|
|
33
|
+
*
|
|
34
|
+
* @Endpoint(getOrder)
|
|
35
|
+
* @ApiTag('Orders')
|
|
36
|
+
* async getOrder() {}
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function ApiTag(name: string, description?: string): <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=api-tag.decorator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-tag.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/api-tag.decorator.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAI1B,QAAA,MAAM,YAAY;;;iBAGhB,CAAA;AAEF,kEAAkE;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,qFAExD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ApiTag, type ApiTagOptions } from './api-tag.decorator.mjs';
|
|
2
|
+
export { ApiOperation, type ApiOperationOptions } from './api-operation.decorator.mjs';
|
|
3
|
+
export { ApiSummary } from './api-summary.decorator.mjs';
|
|
4
|
+
export { ApiDeprecated, type ApiDeprecatedOptions } from './api-deprecated.decorator.mjs';
|
|
5
|
+
export { ApiSecurity, type ApiSecurityRequirement } from './api-security.decorator.mjs';
|
|
6
|
+
export { ApiExclude } from './api-exclude.decorator.mjs';
|
|
7
|
+
export { ApiStream, type ApiStreamOptions } from './api-stream.decorator.mjs';
|
|
8
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/decorators/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ApiTag, ApiOperation, ApiSummary, ApiDeprecated, ApiSecurity, ApiExclude, ApiStream, type ApiOperationOptions, type ApiTagOptions, type ApiStreamOptions, type ApiDeprecatedOptions, type ApiSecurityRequirement, } from './decorators/index.mjs';
|
|
2
|
+
export type { OpenApiEndpointMetadata } from './metadata/index.mjs';
|
|
3
|
+
export { OpenApiGeneratorService, type OpenApiGeneratorOptions, EndpointScannerService, type DiscoveredEndpoint, MetadataExtractorService, SchemaConverterService, type SchemaConversionResult, PathBuilderService, type PathItemResult, } from './services/index.mjs';
|
|
4
|
+
export { ApiTagToken, ApiOperationToken, ApiSummaryToken, ApiDeprecatedToken, ApiSecurityToken, ApiExcludeToken, ApiStreamToken, } from './tokens/index.mjs';
|
|
5
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,wBAAwB,CAAA;AAG/B,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAGnE,OAAO,EACL,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,kBAAkB,EAClB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/metadata/index.mts"],"names":[],"mappings":"AACA,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ApiSecurityRequirement, ApiStreamOptions } from '../decorators/index.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Extracted OpenAPI metadata for an endpoint
|
|
4
|
+
*/
|
|
5
|
+
export interface OpenApiEndpointMetadata {
|
|
6
|
+
/** Tags for grouping endpoints */
|
|
7
|
+
tags: string[];
|
|
8
|
+
/** Short summary */
|
|
9
|
+
summary?: string;
|
|
10
|
+
/** Detailed description */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Unique operation identifier */
|
|
13
|
+
operationId?: string;
|
|
14
|
+
/** Whether the endpoint is deprecated */
|
|
15
|
+
deprecated: boolean;
|
|
16
|
+
/** Deprecation message */
|
|
17
|
+
deprecationMessage?: string;
|
|
18
|
+
/** Security requirements */
|
|
19
|
+
security?: ApiSecurityRequirement[];
|
|
20
|
+
/** External documentation link */
|
|
21
|
+
externalDocs?: {
|
|
22
|
+
url: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
};
|
|
25
|
+
/** Stream content type (for stream endpoints) */
|
|
26
|
+
stream?: ApiStreamOptions;
|
|
27
|
+
/** Whether to exclude from documentation */
|
|
28
|
+
excluded: boolean;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=openapi.metadata.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/openapi.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAEvF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yCAAyC;IACzC,UAAU,EAAE,OAAO,CAAA;IACnB,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,sBAAsB,EAAE,CAAA;IACnC,kCAAkC;IAClC,YAAY,CAAC,EAAE;QACb,GAAG,EAAE,MAAM,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,iDAAiD;IACjD,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,4CAA4C;IAC5C,QAAQ,EAAE,OAAO,CAAA;CAClB"}
|