@hestjs/scalar 0.1.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/README.md +115 -0
- package/dist/decorators/openapi.decorators.d.ts +266 -0
- package/dist/decorators/openapi.decorators.d.ts.map +1 -0
- package/dist/decorators/openapi.decorators.js +113 -0
- package/dist/decorators/openapi.decorators.js.map +1 -0
- package/dist/extensions.d.ts +22 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +27 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi-generator.d.ts +61 -0
- package/dist/openapi-generator.d.ts.map +1 -0
- package/dist/openapi-generator.js +215 -0
- package/dist/openapi-generator.js.map +1 -0
- package/dist/scalar-config.interface.d.ts +73 -0
- package/dist/scalar-config.interface.d.ts.map +1 -0
- package/dist/scalar-config.interface.js +2 -0
- package/dist/scalar-config.interface.js.map +1 -0
- package/dist/scalar.middleware.d.ts +20 -0
- package/dist/scalar.middleware.d.ts.map +1 -0
- package/dist/scalar.middleware.js +149 -0
- package/dist/scalar.middleware.js.map +1 -0
- package/dist/scalar.module.d.ts +15 -0
- package/dist/scalar.module.d.ts.map +1 -0
- package/dist/scalar.module.js +42 -0
- package/dist/scalar.module.js.map +1 -0
- package/dist/utils/index.d.ts +25 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +212 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +68 -0
package/README.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# @hestjs/scalar
|
2
|
+
|
3
|
+
HestJS Scalar API Reference Integration - Beautiful API documentation for HestJS applications
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
npm install @hestjs/scalar
|
9
|
+
```
|
10
|
+
|
11
|
+
## Quick Start
|
12
|
+
|
13
|
+
```typescript
|
14
|
+
import { HestFactory } from '@hestjs/core';
|
15
|
+
import { ScalarModule } from '@hestjs/scalar';
|
16
|
+
import { AppModule } from './app.module';
|
17
|
+
|
18
|
+
async function bootstrap() {
|
19
|
+
const app = await HestFactory.create(AppModule);
|
20
|
+
|
21
|
+
// Configure Scalar API Reference
|
22
|
+
app.useScalar({
|
23
|
+
path: '/docs', // Documentation path
|
24
|
+
spec: '/openapi.json', // OpenAPI spec endpoint
|
25
|
+
theme: 'hest', // Custom HestJS theme
|
26
|
+
title: 'My API Documentation'
|
27
|
+
});
|
28
|
+
|
29
|
+
// Start server
|
30
|
+
Bun.serve({
|
31
|
+
port: 3000,
|
32
|
+
fetch: app.hono().fetch,
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
bootstrap();
|
37
|
+
```
|
38
|
+
|
39
|
+
## Features
|
40
|
+
|
41
|
+
- 🎨 Beautiful API documentation with multiple themes
|
42
|
+
- 📱 Responsive design for mobile and desktop
|
43
|
+
- 🔍 Interactive API explorer
|
44
|
+
- 📋 Copy-paste code examples
|
45
|
+
- 🌙 Dark/light mode support
|
46
|
+
- 📄 Markdown export for LLMs
|
47
|
+
- 🎯 HestJS-specific theme and branding
|
48
|
+
|
49
|
+
## Configuration Options
|
50
|
+
|
51
|
+
| Option | Type | Default | Description |
|
52
|
+
|--------|------|---------|-------------|
|
53
|
+
| `path` | `string` | `'/docs'` | Path where documentation will be served |
|
54
|
+
| `spec` | `string \| object` | - | OpenAPI specification (URL or object) |
|
55
|
+
| `theme` | `string` | `'hest'` | UI theme (`hest`, `default`, `purple`, `moon`, etc.) |
|
56
|
+
| `title` | `string` | `'API Documentation'` | Page title |
|
57
|
+
| `cdn` | `string` | - | Custom CDN URL for Scalar assets |
|
58
|
+
| `proxyUrl` | `string` | - | Proxy URL for CORS issues in development |
|
59
|
+
|
60
|
+
## Usage with OpenAPI Generation
|
61
|
+
|
62
|
+
```typescript
|
63
|
+
// Coming soon: Integration with OpenAPI generation from decorators
|
64
|
+
import { ApiProperty, ApiResponse } from '@hestjs/scalar';
|
65
|
+
|
66
|
+
@Controller('/users')
|
67
|
+
export class UserController {
|
68
|
+
@Get('/')
|
69
|
+
@ApiResponse({ status: 200, description: 'List of users' })
|
70
|
+
async getUsers() {
|
71
|
+
// ...
|
72
|
+
}
|
73
|
+
}
|
74
|
+
```
|
75
|
+
|
76
|
+
## Themes
|
77
|
+
|
78
|
+
HestJS Scalar comes with a custom HestJS theme by default. You can also use:
|
79
|
+
|
80
|
+
- `hest` - Custom HestJS theme (default)
|
81
|
+
- `default` - Scalar default theme
|
82
|
+
- `purple` - Purple theme
|
83
|
+
- `moon` - Dark theme
|
84
|
+
- `solarized` - Solarized theme
|
85
|
+
- `none` - No theme (custom styling)
|
86
|
+
|
87
|
+
## Advanced Configuration
|
88
|
+
|
89
|
+
```typescript
|
90
|
+
app.useScalar({
|
91
|
+
path: '/docs',
|
92
|
+
spec: {
|
93
|
+
openapi: '3.0.0',
|
94
|
+
info: {
|
95
|
+
title: 'My API',
|
96
|
+
version: '1.0.0',
|
97
|
+
},
|
98
|
+
// ... your OpenAPI spec
|
99
|
+
},
|
100
|
+
theme: 'hest',
|
101
|
+
customCss: `
|
102
|
+
.scalar-app {
|
103
|
+
--scalar-color-1: #your-brand-color;
|
104
|
+
}
|
105
|
+
`,
|
106
|
+
servers: [
|
107
|
+
{ url: 'https://api.example.com', description: 'Production' },
|
108
|
+
{ url: 'http://localhost:3000', description: 'Development' }
|
109
|
+
]
|
110
|
+
});
|
111
|
+
```
|
112
|
+
|
113
|
+
## License
|
114
|
+
|
115
|
+
MIT
|
@@ -0,0 +1,266 @@
|
|
1
|
+
import 'reflect-metadata';
|
2
|
+
export type OpenAPIV3 = {
|
3
|
+
openapi: string;
|
4
|
+
info: OpenAPIV3.InfoObject;
|
5
|
+
servers?: OpenAPIV3.ServerObject[];
|
6
|
+
paths: OpenAPIV3.PathsObject;
|
7
|
+
components?: OpenAPIV3.ComponentsObject;
|
8
|
+
security?: OpenAPIV3.SecurityRequirementObject[];
|
9
|
+
tags?: OpenAPIV3.TagObject[];
|
10
|
+
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
11
|
+
};
|
12
|
+
export declare namespace OpenAPIV3 {
|
13
|
+
interface InfoObject {
|
14
|
+
title: string;
|
15
|
+
description?: string;
|
16
|
+
termsOfService?: string;
|
17
|
+
contact?: ContactObject;
|
18
|
+
license?: LicenseObject;
|
19
|
+
version: string;
|
20
|
+
}
|
21
|
+
interface ContactObject {
|
22
|
+
name?: string;
|
23
|
+
url?: string;
|
24
|
+
email?: string;
|
25
|
+
}
|
26
|
+
interface LicenseObject {
|
27
|
+
name: string;
|
28
|
+
url?: string;
|
29
|
+
}
|
30
|
+
interface ServerObject {
|
31
|
+
url: string;
|
32
|
+
description?: string;
|
33
|
+
variables?: Record<string, ServerVariableObject>;
|
34
|
+
}
|
35
|
+
interface ServerVariableObject {
|
36
|
+
enum?: string[];
|
37
|
+
default: string;
|
38
|
+
description?: string;
|
39
|
+
}
|
40
|
+
interface PathsObject {
|
41
|
+
[pattern: string]: PathItemObject | undefined;
|
42
|
+
}
|
43
|
+
interface PathItemObject {
|
44
|
+
$ref?: string;
|
45
|
+
summary?: string;
|
46
|
+
description?: string;
|
47
|
+
get?: OperationObject;
|
48
|
+
put?: OperationObject;
|
49
|
+
post?: OperationObject;
|
50
|
+
delete?: OperationObject;
|
51
|
+
options?: OperationObject;
|
52
|
+
head?: OperationObject;
|
53
|
+
patch?: OperationObject;
|
54
|
+
trace?: OperationObject;
|
55
|
+
servers?: ServerObject[];
|
56
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
57
|
+
}
|
58
|
+
interface OperationObject {
|
59
|
+
tags?: string[];
|
60
|
+
summary?: string;
|
61
|
+
description?: string;
|
62
|
+
externalDocs?: ExternalDocumentationObject;
|
63
|
+
operationId?: string;
|
64
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
65
|
+
requestBody?: ReferenceObject | RequestBodyObject;
|
66
|
+
responses: ResponsesObject;
|
67
|
+
callbacks?: Record<string, ReferenceObject | CallbackObject>;
|
68
|
+
deprecated?: boolean;
|
69
|
+
security?: SecurityRequirementObject[];
|
70
|
+
servers?: ServerObject[];
|
71
|
+
}
|
72
|
+
interface ParameterObject {
|
73
|
+
name: string;
|
74
|
+
in: 'query' | 'header' | 'path' | 'cookie';
|
75
|
+
description?: string;
|
76
|
+
required?: boolean;
|
77
|
+
deprecated?: boolean;
|
78
|
+
allowEmptyValue?: boolean;
|
79
|
+
style?: string;
|
80
|
+
explode?: boolean;
|
81
|
+
allowReserved?: boolean;
|
82
|
+
schema?: ReferenceObject | SchemaObject;
|
83
|
+
example?: any;
|
84
|
+
examples?: Record<string, ReferenceObject | ExampleObject>;
|
85
|
+
content?: Record<string, MediaTypeObject>;
|
86
|
+
}
|
87
|
+
interface RequestBodyObject {
|
88
|
+
description?: string;
|
89
|
+
content: Record<string, MediaTypeObject>;
|
90
|
+
required?: boolean;
|
91
|
+
}
|
92
|
+
interface ResponsesObject {
|
93
|
+
[code: string]: ReferenceObject | ResponseObject;
|
94
|
+
}
|
95
|
+
interface ResponseObject {
|
96
|
+
description: string;
|
97
|
+
headers?: Record<string, ReferenceObject | HeaderObject>;
|
98
|
+
content?: Record<string, MediaTypeObject>;
|
99
|
+
links?: Record<string, ReferenceObject | LinkObject>;
|
100
|
+
}
|
101
|
+
interface MediaTypeObject {
|
102
|
+
schema?: ReferenceObject | SchemaObject;
|
103
|
+
example?: any;
|
104
|
+
examples?: Record<string, ReferenceObject | ExampleObject>;
|
105
|
+
encoding?: Record<string, EncodingObject>;
|
106
|
+
}
|
107
|
+
interface SchemaObject {
|
108
|
+
title?: string;
|
109
|
+
multipleOf?: number;
|
110
|
+
maximum?: number;
|
111
|
+
exclusiveMaximum?: boolean;
|
112
|
+
minimum?: number;
|
113
|
+
exclusiveMinimum?: boolean;
|
114
|
+
maxLength?: number;
|
115
|
+
minLength?: number;
|
116
|
+
pattern?: string;
|
117
|
+
maxItems?: number;
|
118
|
+
minItems?: number;
|
119
|
+
uniqueItems?: boolean;
|
120
|
+
maxProperties?: number;
|
121
|
+
minProperties?: number;
|
122
|
+
required?: string[];
|
123
|
+
enum?: any[];
|
124
|
+
type?: string;
|
125
|
+
allOf?: (ReferenceObject | SchemaObject)[];
|
126
|
+
oneOf?: (ReferenceObject | SchemaObject)[];
|
127
|
+
anyOf?: (ReferenceObject | SchemaObject)[];
|
128
|
+
not?: ReferenceObject | SchemaObject;
|
129
|
+
items?: ReferenceObject | SchemaObject;
|
130
|
+
properties?: Record<string, ReferenceObject | SchemaObject>;
|
131
|
+
additionalProperties?: boolean | ReferenceObject | SchemaObject;
|
132
|
+
description?: string;
|
133
|
+
format?: string;
|
134
|
+
default?: any;
|
135
|
+
nullable?: boolean;
|
136
|
+
discriminator?: DiscriminatorObject;
|
137
|
+
readOnly?: boolean;
|
138
|
+
writeOnly?: boolean;
|
139
|
+
xml?: XMLObject;
|
140
|
+
externalDocs?: ExternalDocumentationObject;
|
141
|
+
example?: any;
|
142
|
+
deprecated?: boolean;
|
143
|
+
}
|
144
|
+
interface ComponentsObject {
|
145
|
+
schemas?: Record<string, ReferenceObject | SchemaObject>;
|
146
|
+
responses?: Record<string, ReferenceObject | ResponseObject>;
|
147
|
+
parameters?: Record<string, ReferenceObject | ParameterObject>;
|
148
|
+
examples?: Record<string, ReferenceObject | ExampleObject>;
|
149
|
+
requestBodies?: Record<string, ReferenceObject | RequestBodyObject>;
|
150
|
+
headers?: Record<string, ReferenceObject | HeaderObject>;
|
151
|
+
securitySchemes?: Record<string, ReferenceObject | SecuritySchemeObject>;
|
152
|
+
links?: Record<string, ReferenceObject | LinkObject>;
|
153
|
+
callbacks?: Record<string, ReferenceObject | CallbackObject>;
|
154
|
+
}
|
155
|
+
interface ReferenceObject {
|
156
|
+
$ref: string;
|
157
|
+
}
|
158
|
+
interface ExampleObject {
|
159
|
+
summary?: string;
|
160
|
+
description?: string;
|
161
|
+
value?: any;
|
162
|
+
externalValue?: string;
|
163
|
+
}
|
164
|
+
interface HeaderObject extends Omit<ParameterObject, 'name' | 'in'> {
|
165
|
+
}
|
166
|
+
interface TagObject {
|
167
|
+
name: string;
|
168
|
+
description?: string;
|
169
|
+
externalDocs?: ExternalDocumentationObject;
|
170
|
+
}
|
171
|
+
interface ExternalDocumentationObject {
|
172
|
+
description?: string;
|
173
|
+
url: string;
|
174
|
+
}
|
175
|
+
interface SecurityRequirementObject {
|
176
|
+
[name: string]: string[];
|
177
|
+
}
|
178
|
+
interface SecuritySchemeObject {
|
179
|
+
type: string;
|
180
|
+
description?: string;
|
181
|
+
name?: string;
|
182
|
+
in?: string;
|
183
|
+
scheme?: string;
|
184
|
+
bearerFormat?: string;
|
185
|
+
flows?: OAuthFlowsObject;
|
186
|
+
openIdConnectUrl?: string;
|
187
|
+
}
|
188
|
+
interface OAuthFlowsObject {
|
189
|
+
implicit?: OAuthFlowObject;
|
190
|
+
password?: OAuthFlowObject;
|
191
|
+
clientCredentials?: OAuthFlowObject;
|
192
|
+
authorizationCode?: OAuthFlowObject;
|
193
|
+
}
|
194
|
+
interface OAuthFlowObject {
|
195
|
+
authorizationUrl?: string;
|
196
|
+
tokenUrl?: string;
|
197
|
+
refreshUrl?: string;
|
198
|
+
scopes: Record<string, string>;
|
199
|
+
}
|
200
|
+
interface DiscriminatorObject {
|
201
|
+
propertyName: string;
|
202
|
+
mapping?: Record<string, string>;
|
203
|
+
}
|
204
|
+
interface XMLObject {
|
205
|
+
name?: string;
|
206
|
+
namespace?: string;
|
207
|
+
prefix?: string;
|
208
|
+
attribute?: boolean;
|
209
|
+
wrapped?: boolean;
|
210
|
+
}
|
211
|
+
interface EncodingObject {
|
212
|
+
contentType?: string;
|
213
|
+
headers?: Record<string, ReferenceObject | HeaderObject>;
|
214
|
+
style?: string;
|
215
|
+
explode?: boolean;
|
216
|
+
allowReserved?: boolean;
|
217
|
+
}
|
218
|
+
interface LinkObject {
|
219
|
+
operationRef?: string;
|
220
|
+
operationId?: string;
|
221
|
+
parameters?: Record<string, any>;
|
222
|
+
requestBody?: any;
|
223
|
+
description?: string;
|
224
|
+
server?: ServerObject;
|
225
|
+
}
|
226
|
+
interface CallbackObject {
|
227
|
+
[expression: string]: PathItemObject;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
/**
|
231
|
+
* OpenAPI Tags 装饰器 - OpenAPI 标准
|
232
|
+
*/
|
233
|
+
export declare function ApiTags(...tags: string[]): ClassDecorator;
|
234
|
+
/**
|
235
|
+
* OpenAPI Operation 装饰器 - OpenAPI 标准
|
236
|
+
*/
|
237
|
+
export declare function ApiOperation(operation: Partial<OpenAPIV3.OperationObject>): MethodDecorator;
|
238
|
+
/**
|
239
|
+
* OpenAPI Response 装饰器 - OpenAPI 标准
|
240
|
+
*/
|
241
|
+
export declare function ApiResponse(status: string | number, response: OpenAPIV3.ResponseObject): MethodDecorator;
|
242
|
+
/**
|
243
|
+
* OpenAPI Parameter 装饰器 - OpenAPI 标准
|
244
|
+
*/
|
245
|
+
export declare function ApiParameter(param: OpenAPIV3.ParameterObject): MethodDecorator;
|
246
|
+
/**
|
247
|
+
* OpenAPI Request Body 装饰器 - OpenAPI 标准
|
248
|
+
*/
|
249
|
+
export declare function ApiRequestBody(requestBody: OpenAPIV3.RequestBodyObject): MethodDecorator;
|
250
|
+
/**
|
251
|
+
* OpenAPI Security 装饰器 - OpenAPI 标准
|
252
|
+
*/
|
253
|
+
export declare function ApiSecurity(security: OpenAPIV3.SecurityRequirementObject[]): MethodDecorator;
|
254
|
+
/**
|
255
|
+
* OpenAPI Schema 装饰器 - OpenAPI 标准
|
256
|
+
*/
|
257
|
+
export declare function ApiSchema(schema: OpenAPIV3.SchemaObject): ClassDecorator;
|
258
|
+
/**
|
259
|
+
* OpenAPI Property 装饰器 - OpenAPI 标准
|
260
|
+
*/
|
261
|
+
export declare function ApiProperty(property: OpenAPIV3.SchemaObject): PropertyDecorator;
|
262
|
+
export declare function ApiQuery(name: string, options?: Partial<Omit<OpenAPIV3.ParameterObject, 'name' | 'in'>>): MethodDecorator;
|
263
|
+
export declare function ApiParam(name: string, options?: Partial<Omit<OpenAPIV3.ParameterObject, 'name' | 'in'>>): MethodDecorator;
|
264
|
+
export declare function ApiHeader(name: string, options?: Partial<Omit<OpenAPIV3.ParameterObject, 'name' | 'in'>>): MethodDecorator;
|
265
|
+
export declare function ApiBody(content: Record<string, OpenAPIV3.MediaTypeObject>, options?: Partial<Omit<OpenAPIV3.RequestBodyObject, 'content'>>): MethodDecorator;
|
266
|
+
//# sourceMappingURL=openapi.decorators.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"openapi.decorators.d.ts","sourceRoot":"","sources":["../../src/decorators/openapi.decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC;IAC3B,OAAO,CAAC,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC;IACnC,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAC,yBAAyB,EAAE,CAAC;IACjD,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,SAAS,CAAC,2BAA2B,CAAC;CACtD,CAAC;AAEF,yBAAiB,SAAS,CAAC;IACzB,UAAiB,UAAU;QACzB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,OAAO,CAAC,EAAE,aAAa,CAAC;QACxB,OAAO,CAAC,EAAE,aAAa,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;KACjB;IAED,UAAiB,aAAa;QAC5B,IAAI,CAAC,EAAE,MAA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AI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC,CAAM,GAAG,eAAe,CAM9H;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,CAAC,EAAE,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAM,GAAG,eAAe,CAKhK"}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import 'reflect-metadata';
|
2
|
+
/**
|
3
|
+
* OpenAPI Tags 装饰器 - OpenAPI 标准
|
4
|
+
*/
|
5
|
+
export function ApiTags(...tags) {
|
6
|
+
return (target) => {
|
7
|
+
Reflect.defineMetadata('openapi:tags', tags, target);
|
8
|
+
};
|
9
|
+
}
|
10
|
+
/**
|
11
|
+
* OpenAPI Operation 装饰器 - OpenAPI 标准
|
12
|
+
*/
|
13
|
+
export function ApiOperation(operation) {
|
14
|
+
return (target, propertyKey) => {
|
15
|
+
if (!propertyKey)
|
16
|
+
return;
|
17
|
+
Reflect.defineMetadata('openapi:operation', operation, target, propertyKey);
|
18
|
+
};
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* OpenAPI Response 装饰器 - OpenAPI 标准
|
22
|
+
*/
|
23
|
+
export function ApiResponse(status, response) {
|
24
|
+
return (target, propertyKey) => {
|
25
|
+
if (!propertyKey)
|
26
|
+
return;
|
27
|
+
const existingResponses = Reflect.getMetadata('openapi:responses', target, propertyKey) || {};
|
28
|
+
existingResponses[status] = response;
|
29
|
+
Reflect.defineMetadata('openapi:responses', existingResponses, target, propertyKey);
|
30
|
+
};
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* OpenAPI Parameter 装饰器 - OpenAPI 标准
|
34
|
+
*/
|
35
|
+
export function ApiParameter(param) {
|
36
|
+
return (target, propertyKey) => {
|
37
|
+
if (!propertyKey)
|
38
|
+
return;
|
39
|
+
const existingParams = Reflect.getMetadata('openapi:parameters', target, propertyKey) || [];
|
40
|
+
existingParams.push(param);
|
41
|
+
Reflect.defineMetadata('openapi:parameters', existingParams, target, propertyKey);
|
42
|
+
};
|
43
|
+
}
|
44
|
+
/**
|
45
|
+
* OpenAPI Request Body 装饰器 - OpenAPI 标准
|
46
|
+
*/
|
47
|
+
export function ApiRequestBody(requestBody) {
|
48
|
+
return (target, propertyKey) => {
|
49
|
+
if (!propertyKey)
|
50
|
+
return;
|
51
|
+
Reflect.defineMetadata('openapi:requestBody', requestBody, target, propertyKey);
|
52
|
+
};
|
53
|
+
}
|
54
|
+
/**
|
55
|
+
* OpenAPI Security 装饰器 - OpenAPI 标准
|
56
|
+
*/
|
57
|
+
export function ApiSecurity(security) {
|
58
|
+
return (target, propertyKey) => {
|
59
|
+
if (!propertyKey)
|
60
|
+
return;
|
61
|
+
Reflect.defineMetadata('openapi:security', security, target, propertyKey);
|
62
|
+
};
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* OpenAPI Schema 装饰器 - OpenAPI 标准
|
66
|
+
*/
|
67
|
+
export function ApiSchema(schema) {
|
68
|
+
return (target) => {
|
69
|
+
Reflect.defineMetadata('openapi:schema', schema, target);
|
70
|
+
};
|
71
|
+
}
|
72
|
+
/**
|
73
|
+
* OpenAPI Property 装饰器 - OpenAPI 标准
|
74
|
+
*/
|
75
|
+
export function ApiProperty(property) {
|
76
|
+
return (target, propertyKey) => {
|
77
|
+
if (!propertyKey)
|
78
|
+
return;
|
79
|
+
const existingProperties = Reflect.getMetadata('openapi:properties', target.constructor) || {};
|
80
|
+
existingProperties[propertyKey] = property;
|
81
|
+
Reflect.defineMetadata('openapi:properties', existingProperties, target.constructor);
|
82
|
+
};
|
83
|
+
}
|
84
|
+
// 便捷装饰器 - 基于 OpenAPI 标准的常用场景
|
85
|
+
export function ApiQuery(name, options = {}) {
|
86
|
+
return ApiParameter({
|
87
|
+
name,
|
88
|
+
in: 'query',
|
89
|
+
...options
|
90
|
+
});
|
91
|
+
}
|
92
|
+
export function ApiParam(name, options = {}) {
|
93
|
+
return ApiParameter({
|
94
|
+
name,
|
95
|
+
in: 'path',
|
96
|
+
required: true,
|
97
|
+
...options
|
98
|
+
});
|
99
|
+
}
|
100
|
+
export function ApiHeader(name, options = {}) {
|
101
|
+
return ApiParameter({
|
102
|
+
name,
|
103
|
+
in: 'header',
|
104
|
+
...options
|
105
|
+
});
|
106
|
+
}
|
107
|
+
export function ApiBody(content, options = {}) {
|
108
|
+
return ApiRequestBody({
|
109
|
+
content,
|
110
|
+
...options
|
111
|
+
});
|
112
|
+
}
|
113
|
+
//# sourceMappingURL=openapi.decorators.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"openapi.decorators.js","sourceRoot":"","sources":["../../src/decorators/openapi.decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAoQ1B;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,GAAG,IAAc;IACvC,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,SAA6C;IACxE,OAAO,CAAC,MAAW,EAAE,WAAwC,EAAE,EAAE;QAC/D,IAAI,CAAC,WAAW;YAAE,OAAO;QACzB,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACD,MAAM,UAAU,WAAW,CAAC,MAAuB,EAAE,QAAkC;IACvF,OAAO,CAAC,MAAW,EAAE,WAAwC,EAAE,EAAE;QAC/D,IAAI,CAAC,WAAW;YAAE,OAAO;QACzB,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,MAAM,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import type { OpenAPIGeneratorConfig } from './openapi-generator';
|
3
|
+
/**
|
4
|
+
* 扩展 HestApplicationInstance 以支持 Scalar
|
5
|
+
*/
|
6
|
+
declare module "@hestjs/core" {
|
7
|
+
interface HestApplicationInstance {
|
8
|
+
/**
|
9
|
+
* 配置 Scalar API 文档
|
10
|
+
*/
|
11
|
+
useScalar(config: ScalarConfig): void;
|
12
|
+
/**
|
13
|
+
* 从控制器自动生成 OpenAPI 并配置 Scalar
|
14
|
+
*/
|
15
|
+
useScalarWithControllers(controllers: any[], generatorConfig: OpenAPIGeneratorConfig, scalarConfig?: Omit<ScalarConfig, 'spec'>): void;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* 为 HestApplicationInstance 添加 Scalar 方法
|
20
|
+
*/
|
21
|
+
export declare function extendWithScalar(): void;
|
22
|
+
//# sourceMappingURL=extensions.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE;;GAEG;AACH,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,uBAAuB;QAC/B;;WAEG;QACH,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;QAEtC;;WAEG;QACH,wBAAwB,CACtB,WAAW,EAAE,GAAG,EAAE,EAClB,eAAe,EAAE,sBAAsB,EACvC,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GACxC,IAAI,CAAC;KACT;CACF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,SA0B/B"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { setupScalar, setupScalarWithControllers } from "./scalar.middleware";
|
2
|
+
/**
|
3
|
+
* 为 HestApplicationInstance 添加 Scalar 方法
|
4
|
+
*/
|
5
|
+
export function extendWithScalar() {
|
6
|
+
const HestApplicationInstancePrototype = require("@hestjs/core").HestApplicationInstance.prototype;
|
7
|
+
HestApplicationInstancePrototype.useScalar = function (config) {
|
8
|
+
setupScalar(this.hono(), config);
|
9
|
+
};
|
10
|
+
HestApplicationInstancePrototype.useScalarWithControllers = function (controllers, generatorConfig, scalarConfig = {}) {
|
11
|
+
// 如果没有传入控制器,尝试从容器中获取
|
12
|
+
if (controllers.length === 0) {
|
13
|
+
try {
|
14
|
+
// 这里可以尝试从容器中获取所有控制器
|
15
|
+
// 暂时使用一个简单的实现
|
16
|
+
console.warn('Auto-discovery of controllers not yet implemented. Please pass controllers explicitly.');
|
17
|
+
}
|
18
|
+
catch (error) {
|
19
|
+
console.warn('Failed to auto-discover controllers:', error);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
setupScalarWithControllers(this.hono(), controllers, generatorConfig, scalarConfig);
|
23
|
+
};
|
24
|
+
}
|
25
|
+
// 自动扩展
|
26
|
+
extendWithScalar();
|
27
|
+
//# sourceMappingURL=extensions.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAwB9E;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,gCAAgC,GACpC,OAAO,CAAC,cAAc,CAAC,CAAC,uBAAuB,CAAC,SAAS,CAAC;IAE5D,gCAAgC,CAAC,SAAS,GAAG,UAAU,MAAoB;QACzE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,gCAAgC,CAAC,wBAAwB,GAAG,UAC1D,WAAkB,EAClB,eAAuC,EACvC,eAA2C,EAAE;QAE7C,qBAAqB;QACrB,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,oBAAoB;gBACpB,cAAc;gBACd,OAAO,CAAC,IAAI,CAAC,wFAAwF,CAAC,CAAC;YACzG,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;QAED,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC;AAED,OAAO;AACP,gBAAgB,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
import "./extensions";
|
2
|
+
export * from "./decorators/openapi.decorators";
|
3
|
+
export * from "./scalar-config.interface";
|
4
|
+
export * from "./scalar.middleware";
|
5
|
+
export * from "./scalar.module";
|
6
|
+
export * from "./openapi-generator";
|
7
|
+
export * from "./utils";
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAC;AAEtB,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
// 首先应用扩展
|
2
|
+
import "./extensions";
|
3
|
+
export * from "./decorators/openapi.decorators";
|
4
|
+
export * from "./scalar-config.interface";
|
5
|
+
export * from "./scalar.middleware";
|
6
|
+
export * from "./scalar.module";
|
7
|
+
export * from "./openapi-generator";
|
8
|
+
export * from "./utils";
|
9
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,cAAc,CAAC;AAEtB,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC"}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import 'reflect-metadata';
|
2
|
+
import type { OpenAPIV3 } from './decorators/openapi.decorators';
|
3
|
+
/**
|
4
|
+
* OpenAPI 生成器配置
|
5
|
+
*/
|
6
|
+
export interface OpenAPIGeneratorConfig {
|
7
|
+
/** 基础文档信息 */
|
8
|
+
info: OpenAPIV3.InfoObject;
|
9
|
+
/** 服务器配置 */
|
10
|
+
servers?: OpenAPIV3.ServerObject[];
|
11
|
+
/** 安全方案 */
|
12
|
+
security?: OpenAPIV3.SecurityRequirementObject[];
|
13
|
+
/** 全局标签 */
|
14
|
+
tags?: OpenAPIV3.TagObject[];
|
15
|
+
/** 外部文档 */
|
16
|
+
externalDocs?: OpenAPIV3.ExternalDocumentationObject;
|
17
|
+
/** 全局组件 */
|
18
|
+
components?: OpenAPIV3.ComponentsObject;
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* OpenAPI 文档生成器
|
22
|
+
*/
|
23
|
+
export declare class OpenAPIGenerator {
|
24
|
+
private config;
|
25
|
+
private paths;
|
26
|
+
private components;
|
27
|
+
constructor(config: OpenAPIGeneratorConfig);
|
28
|
+
/**
|
29
|
+
* 从控制器类生成 OpenAPI 路径
|
30
|
+
*/
|
31
|
+
addController(controller: any, basePath?: string): void;
|
32
|
+
/**
|
33
|
+
* 生成操作对象
|
34
|
+
*/
|
35
|
+
private generateOperation;
|
36
|
+
/**
|
37
|
+
* 从类添加 Schema
|
38
|
+
*/
|
39
|
+
private addSchemaFromClass;
|
40
|
+
/**
|
41
|
+
* 标准化路径
|
42
|
+
*/
|
43
|
+
private normalizePath;
|
44
|
+
/**
|
45
|
+
* 拼接路径
|
46
|
+
*/
|
47
|
+
private joinPaths;
|
48
|
+
/**
|
49
|
+
* 添加全局组件
|
50
|
+
*/
|
51
|
+
addComponent(type: keyof OpenAPIV3.ComponentsObject, name: string, component: any): void;
|
52
|
+
/**
|
53
|
+
* 生成完整的 OpenAPI 文档
|
54
|
+
*/
|
55
|
+
generateDocument(): OpenAPIV3;
|
56
|
+
/**
|
57
|
+
* 重置生成器
|
58
|
+
*/
|
59
|
+
reset(): void;
|
60
|
+
}
|
61
|
+
//# sourceMappingURL=openapi-generator.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"openapi-generator.d.ts","sourceRoot":"","sources":["../src/openapi-generator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa;IACb,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC;IAC3B,YAAY;IACZ,OAAO,CAAC,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC;IACnC,WAAW;IACX,QAAQ,CAAC,EAAE,SAAS,CAAC,yBAAyB,EAAE,CAAC;IACjD,WAAW;IACX,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;IAC7B,WAAW;IACX,YAAY,CAAC,EAAE,SAAS,CAAC,2BAA2B,CAAC;IACrD,WAAW;IACX,UAAU,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC;CACzC;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,UAAU,CAUhB;gBAEU,MAAM,EAAE,sBAAsB;IAO1C;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAW,GAAG,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