nestjs-openapi 0.2.2 → 0.3.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/dist/cli.mjs +1 -1
- package/dist/index.d.mts +91 -23
- package/dist/index.d.ts +91 -23
- package/dist/index.mjs +146 -28
- package/dist/internal.d.mts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/shared/{nestjs-openapi.NtbZNAvU.d.mts → nestjs-openapi.CAanamW0.d.mts} +219 -219
- package/dist/shared/{nestjs-openapi.NtbZNAvU.d.ts → nestjs-openapi.CAanamW0.d.ts} +219 -219
- package/dist/shared/{nestjs-openapi.DeikubMm.mjs → nestjs-openapi.Nd-wGr8A.mjs} +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import 'tsx';
|
|
3
3
|
import { Effect, Exit, Cause, Option } from 'effect';
|
|
4
|
-
import { ax as generateEffect, ak as generatorServicesLayer, az as runtimeLayerFor, aw as formatValidationResult } from './shared/nestjs-openapi.
|
|
4
|
+
import { ax as generateEffect, ak as generatorServicesLayer, az as runtimeLayerFor, aw as formatValidationResult } from './shared/nestjs-openapi.Nd-wGr8A.mjs';
|
|
5
5
|
import minimist from 'minimist';
|
|
6
6
|
import { relative } from 'node:path';
|
|
7
7
|
import { createRequire } from 'node:module';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as OpenApiSpec, S as SpecFileNotFoundError, a as SpecFileReadError, b as SpecFileParseError, M as MethodInfo, c as OpenApiPaths, d as OpenApiOperation, e as OpenApiPaths$1, G as GeneratedSchemas, f as OpenApiSchema,
|
|
2
|
-
export { a4 as AnalysisError, aJ as BrokenRef, aK as BrokenRefCategories, az as ClassValidationInfo, n as Config, a3 as ConfigError, X as ConfigLoadError, W as ConfigNotFoundError, Y as ConfigValidationError, o as ContactConfig, Z as DtoGlobResolutionError, U as EntryNotFoundError, E as GenerateOptions, s as GenerateOverrides, l as GenerateResult, a5 as GeneratorError, J as HttpMethod, I as InfoConfig, _ as InvalidMethodError, am as JsonSchema, L as LicenseConfig, $ as MissingGenericSchemaTempFileCleanupError, a0 as MissingGenericSchemaTempFileWriteError, ac as ModuleWithControllers, K as OpenApiGeneratorConfig, t as OpenApiOperation, u as OpenApiParameter, v as OpenApiRequestBody, w as OpenApiResponse, q as OutputFormat, F as ParameterLocation, a8 as ProjectContext, a2 as ProjectError, Q as ProjectInitError, a9 as ProjectOptions, a6 as ProjectServiceLive, ay as PropertyValidationInfo, a1 as PublicApiError, N as ResolvedConfig, R as ResolvedParameter, H as ReturnTypeInfo, ak as SchemaError, aj as SchemaGenerationError, al as SchemaGeneratorOptions, p as ServerConfig, T as TagConfig, r as TelemetryConfig, ax as ValidationConstraints, aI as ValidationResult, au as applyConstraintsToSchema, aG as categorizeBrokenRefs, m as defineConfig, as as extractClassConstraints, aq as extractClassValidationInfo, ar as extractClassValidationInfoEffect, an as extractPropertyConstraints, ap as extractPropertyValidationInfo, aA as findConfigFile, aH as formatValidationResult, k as generate, y as generateAsync, x as generateEffect, D as generateFromConfigAsync, B as generateFromConfigEffect, A as generatePathsAsync, z as generatePathsEffect, ah as generateSchemas, ai as generateSchemasFromFiles, ab as getAllControllers, af as getControllerMethodInfos, ag as getControllerMethodInfosEffect, ad as getMethodInfo, ae as getMethodInfoEffect, aa as getModules, at as getRequiredProperties, ao as isPropertyOptional, aE as loadAndResolveConfig, aC as loadConfig, aB as loadConfigFromFile, a7 as makeProjectContext, av as mergeValidationConstraints, aw as mergeValidationConstraintsEffect, aD as resolveConfig, aF as validateSpec } from './shared/nestjs-openapi.
|
|
1
|
+
import { O as OpenApiSpec, S as SpecFileNotFoundError, a as SpecFileReadError, b as SpecFileParseError, M as MethodInfo, c as OpenApiPaths, d as OpenApiOperation, e as OpenApiPaths$1, G as GeneratedSchemas, f as OpenApiSchema, P as ProjectService, g as ModuleTraversalService, C as ConfigService, h as SchemaService, V as ValidationService, i as MethodExtractionService, j as OutputService } from './shared/nestjs-openapi.CAanamW0.mjs';
|
|
2
|
+
export { a4 as AnalysisError, aJ as BrokenRef, aK as BrokenRefCategories, az as ClassValidationInfo, n as Config, a3 as ConfigError, X as ConfigLoadError, W as ConfigNotFoundError, Y as ConfigValidationError, o as ContactConfig, Z as DtoGlobResolutionError, U as EntryNotFoundError, E as GenerateOptions, s as GenerateOverrides, l as GenerateResult, a5 as GeneratorError, J as HttpMethod, I as InfoConfig, _ as InvalidMethodError, am as JsonSchema, L as LicenseConfig, $ as MissingGenericSchemaTempFileCleanupError, a0 as MissingGenericSchemaTempFileWriteError, ac as ModuleWithControllers, K as OpenApiGeneratorConfig, t as OpenApiOperation, u as OpenApiParameter, v as OpenApiRequestBody, w as OpenApiResponse, q as OutputFormat, F as ParameterLocation, a8 as ProjectContext, a2 as ProjectError, Q as ProjectInitError, a9 as ProjectOptions, a6 as ProjectServiceLive, ay as PropertyValidationInfo, a1 as PublicApiError, N as ResolvedConfig, R as ResolvedParameter, H as ReturnTypeInfo, ak as SchemaError, aj as SchemaGenerationError, al as SchemaGeneratorOptions, p as ServerConfig, T as TagConfig, r as TelemetryConfig, ax as ValidationConstraints, aI as ValidationResult, au as applyConstraintsToSchema, aG as categorizeBrokenRefs, m as defineConfig, as as extractClassConstraints, aq as extractClassValidationInfo, ar as extractClassValidationInfoEffect, an as extractPropertyConstraints, ap as extractPropertyValidationInfo, aA as findConfigFile, aH as formatValidationResult, k as generate, y as generateAsync, x as generateEffect, D as generateFromConfigAsync, B as generateFromConfigEffect, A as generatePathsAsync, z as generatePathsEffect, ah as generateSchemas, ai as generateSchemasFromFiles, ab as getAllControllers, af as getControllerMethodInfos, ag as getControllerMethodInfosEffect, ad as getMethodInfo, ae as getMethodInfoEffect, aa as getModules, at as getRequiredProperties, ao as isPropertyOptional, aE as loadAndResolveConfig, aC as loadConfig, aB as loadConfigFromFile, a7 as makeProjectContext, av as mergeValidationConstraints, aw as mergeValidationConstraintsEffect, aD as resolveConfig, aF as validateSpec } from './shared/nestjs-openapi.CAanamW0.mjs';
|
|
3
3
|
import { DynamicModule } from '@nestjs/common';
|
|
4
4
|
import { Effect, Option, Layer } from 'effect';
|
|
5
5
|
import { ClassDeclaration, MethodDeclaration, Decorator, Symbol, ObjectLiteralExpression, Expression } from 'ts-morph';
|
|
@@ -38,10 +38,24 @@ interface SwaggerOptions {
|
|
|
38
38
|
*/
|
|
39
39
|
readonly title?: string;
|
|
40
40
|
}
|
|
41
|
+
interface LoadSpecFileOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Additional spec files to try when the primary file is missing.
|
|
44
|
+
*/
|
|
45
|
+
readonly fallbackSpecFiles?: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
interface OpenApiDocumentFileSource extends LoadSpecFileOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Path to the generated OpenAPI JSON file.
|
|
50
|
+
* Can be absolute or relative to the current working directory.
|
|
51
|
+
*/
|
|
52
|
+
readonly specFile: string;
|
|
53
|
+
}
|
|
54
|
+
type OpenApiDocumentSource = OpenApiSpec | (() => OpenApiSpec) | OpenApiDocumentFileSource;
|
|
41
55
|
/**
|
|
42
56
|
* Configuration options for the OpenAPI module
|
|
43
57
|
*/
|
|
44
|
-
interface OpenApiModuleOptions {
|
|
58
|
+
interface OpenApiModuleOptions extends LoadSpecFileOptions {
|
|
45
59
|
/**
|
|
46
60
|
* Path to the generated OpenAPI JSON file.
|
|
47
61
|
* Can be absolute or relative to the current working directory.
|
|
@@ -72,6 +86,7 @@ interface OpenApiModuleOptions {
|
|
|
72
86
|
*/
|
|
73
87
|
interface ResolvedOpenApiModuleOptions {
|
|
74
88
|
readonly specFile: string;
|
|
89
|
+
readonly fallbackSpecFiles: readonly string[];
|
|
75
90
|
readonly enabled: boolean;
|
|
76
91
|
readonly jsonPath: string;
|
|
77
92
|
readonly swagger: {
|
|
@@ -88,6 +103,52 @@ declare const OPENAPI_MODULE_OPTIONS: unique symbol;
|
|
|
88
103
|
* Injection token for the loaded OpenAPI specification
|
|
89
104
|
*/
|
|
90
105
|
declare const OPENAPI_SPEC: unique symbol;
|
|
106
|
+
interface OpenApiRouteRegistrar {
|
|
107
|
+
readonly get: (path: string, handler: (request: unknown, response: unknown) => void) => void;
|
|
108
|
+
}
|
|
109
|
+
interface OpenApiHttpApplication {
|
|
110
|
+
readonly config?: {
|
|
111
|
+
readonly getGlobalPrefix?: () => string;
|
|
112
|
+
};
|
|
113
|
+
readonly getHttpAdapter: () => OpenApiRouteRegistrar;
|
|
114
|
+
}
|
|
115
|
+
interface OpenApiSetupOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Whether OpenAPI routes should be registered.
|
|
118
|
+
* @default true
|
|
119
|
+
*/
|
|
120
|
+
readonly enabled?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Prefix OpenAPI routes with the app's `setGlobalPrefix()` value.
|
|
123
|
+
* Matches @nestjs/swagger's `SwaggerCustomOptions.useGlobalPrefix`.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
readonly useGlobalPrefix?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Raw OpenAPI JSON endpoint path.
|
|
129
|
+
* Matches @nestjs/swagger's `SwaggerCustomOptions.jsonDocumentUrl`.
|
|
130
|
+
* @default `${docsPath}-json`
|
|
131
|
+
*/
|
|
132
|
+
readonly jsonDocumentUrl?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Whether Swagger UI should be served.
|
|
135
|
+
* Matches @nestjs/swagger's `SwaggerCustomOptions.ui`.
|
|
136
|
+
* @default true
|
|
137
|
+
*/
|
|
138
|
+
readonly ui?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Whether raw OpenAPI definitions should be served.
|
|
141
|
+
* Only JSON is supported.
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
144
|
+
readonly raw?: boolean | readonly 'json'[];
|
|
145
|
+
/**
|
|
146
|
+
* Browser title for Swagger UI.
|
|
147
|
+
* Matches @nestjs/swagger's `SwaggerCustomOptions.customSiteTitle`.
|
|
148
|
+
* Uses the spec's info.title if not provided.
|
|
149
|
+
*/
|
|
150
|
+
readonly customSiteTitle?: string;
|
|
151
|
+
}
|
|
91
152
|
/**
|
|
92
153
|
* Generate Swagger UI HTML page
|
|
93
154
|
*/
|
|
@@ -95,8 +156,8 @@ declare function generateSwaggerUiHtml(title: string, jsonPath: string): string;
|
|
|
95
156
|
/**
|
|
96
157
|
* Load the OpenAPI spec file from disk
|
|
97
158
|
*/
|
|
98
|
-
declare const loadSpecFileEffect: (filePath: string) => Effect.Effect<OpenApiSpec, SpecFileNotFoundError | SpecFileReadError | SpecFileParseError, never>;
|
|
99
|
-
declare function loadSpecFile(filePath: string): OpenApiSpec;
|
|
159
|
+
declare const loadSpecFileEffect: (filePath: string, options?: LoadSpecFileOptions | undefined) => Effect.Effect<OpenApiSpec, SpecFileNotFoundError | SpecFileReadError | SpecFileParseError, never>;
|
|
160
|
+
declare function loadSpecFile(filePath: string, options?: LoadSpecFileOptions): OpenApiSpec;
|
|
100
161
|
/**
|
|
101
162
|
* Resolve options with defaults
|
|
102
163
|
*/
|
|
@@ -143,6 +204,13 @@ declare class OpenApiModule {
|
|
|
143
204
|
* @returns Dynamic module configuration
|
|
144
205
|
*/
|
|
145
206
|
static forRoot(options: OpenApiModuleOptions): DynamicModule;
|
|
207
|
+
/**
|
|
208
|
+
* Register OpenAPI JSON and Swagger UI routes on an already-created Nest app.
|
|
209
|
+
*
|
|
210
|
+
* Use this when the route config depends on services that are only available
|
|
211
|
+
* during bootstrap. For module-level static config, prefer `forRoot()`.
|
|
212
|
+
*/
|
|
213
|
+
static setup(path: string, app: OpenApiHttpApplication, documentSource: OpenApiDocumentSource, options?: OpenApiSetupOptions): void;
|
|
146
214
|
}
|
|
147
215
|
|
|
148
216
|
declare const normalizePath: (path: string) => string;
|
|
@@ -159,8 +227,12 @@ declare const getHttpDecorator: (method: MethodDeclaration) => Decorator | undef
|
|
|
159
227
|
|
|
160
228
|
declare const transformMethod: (methodInfo: MethodInfo) => OpenApiPaths;
|
|
161
229
|
declare const transformMethodEffect: (methodInfo: {
|
|
162
|
-
readonly
|
|
230
|
+
readonly security: readonly {
|
|
231
|
+
readonly scopes: readonly string[];
|
|
232
|
+
readonly schemeName: string;
|
|
233
|
+
}[];
|
|
163
234
|
readonly path: string;
|
|
235
|
+
readonly httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD" | "ALL";
|
|
164
236
|
readonly methodName: string;
|
|
165
237
|
readonly controllerName: string;
|
|
166
238
|
readonly controllerTags: readonly string[];
|
|
@@ -172,10 +244,10 @@ declare const transformMethodEffect: (methodInfo: {
|
|
|
172
244
|
};
|
|
173
245
|
readonly parameters: readonly {
|
|
174
246
|
readonly name: string;
|
|
175
|
-
readonly
|
|
247
|
+
readonly description: Option.Option<string>;
|
|
248
|
+
readonly location: "query" | "header" | "cookie" | "path" | "body";
|
|
176
249
|
readonly tsType: string;
|
|
177
250
|
readonly required: boolean;
|
|
178
|
-
readonly description: Option.Option<string>;
|
|
179
251
|
}[];
|
|
180
252
|
readonly decorators: readonly string[];
|
|
181
253
|
readonly operation: {
|
|
@@ -185,18 +257,14 @@ declare const transformMethodEffect: (methodInfo: {
|
|
|
185
257
|
readonly deprecated: Option.Option<boolean>;
|
|
186
258
|
};
|
|
187
259
|
readonly responses: readonly {
|
|
188
|
-
readonly type: Option.Option<string>;
|
|
189
260
|
readonly description: Option.Option<string>;
|
|
261
|
+
readonly type: Option.Option<string>;
|
|
190
262
|
readonly statusCode: number;
|
|
191
263
|
readonly isArray: boolean;
|
|
192
264
|
}[];
|
|
193
265
|
readonly httpCode: Option.Option<number>;
|
|
194
266
|
readonly consumes: readonly string[];
|
|
195
267
|
readonly produces: readonly string[];
|
|
196
|
-
readonly security: readonly {
|
|
197
|
-
readonly schemeName: string;
|
|
198
|
-
readonly scopes: readonly string[];
|
|
199
|
-
}[];
|
|
200
268
|
}) => Effect.Effect<OpenApiPaths, never, never>;
|
|
201
269
|
type MutableOpenApiPaths = {
|
|
202
270
|
[path: string]: {
|
|
@@ -205,8 +273,12 @@ type MutableOpenApiPaths = {
|
|
|
205
273
|
};
|
|
206
274
|
declare const transformMethods: (methodInfos: readonly MethodInfo[]) => OpenApiPaths;
|
|
207
275
|
declare const transformMethodsEffect: (methodInfos: readonly {
|
|
208
|
-
readonly
|
|
276
|
+
readonly security: readonly {
|
|
277
|
+
readonly scopes: readonly string[];
|
|
278
|
+
readonly schemeName: string;
|
|
279
|
+
}[];
|
|
209
280
|
readonly path: string;
|
|
281
|
+
readonly httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD" | "ALL";
|
|
210
282
|
readonly methodName: string;
|
|
211
283
|
readonly controllerName: string;
|
|
212
284
|
readonly controllerTags: readonly string[];
|
|
@@ -218,10 +290,10 @@ declare const transformMethodsEffect: (methodInfos: readonly {
|
|
|
218
290
|
};
|
|
219
291
|
readonly parameters: readonly {
|
|
220
292
|
readonly name: string;
|
|
221
|
-
readonly
|
|
293
|
+
readonly description: Option.Option<string>;
|
|
294
|
+
readonly location: "query" | "header" | "cookie" | "path" | "body";
|
|
222
295
|
readonly tsType: string;
|
|
223
296
|
readonly required: boolean;
|
|
224
|
-
readonly description: Option.Option<string>;
|
|
225
297
|
}[];
|
|
226
298
|
readonly decorators: readonly string[];
|
|
227
299
|
readonly operation: {
|
|
@@ -231,18 +303,14 @@ declare const transformMethodsEffect: (methodInfos: readonly {
|
|
|
231
303
|
readonly deprecated: Option.Option<boolean>;
|
|
232
304
|
};
|
|
233
305
|
readonly responses: readonly {
|
|
234
|
-
readonly type: Option.Option<string>;
|
|
235
306
|
readonly description: Option.Option<string>;
|
|
307
|
+
readonly type: Option.Option<string>;
|
|
236
308
|
readonly statusCode: number;
|
|
237
309
|
readonly isArray: boolean;
|
|
238
310
|
}[];
|
|
239
311
|
readonly httpCode: Option.Option<number>;
|
|
240
312
|
readonly consumes: readonly string[];
|
|
241
313
|
readonly produces: readonly string[];
|
|
242
|
-
readonly security: readonly {
|
|
243
|
-
readonly schemeName: string;
|
|
244
|
-
readonly scopes: readonly string[];
|
|
245
|
-
}[];
|
|
246
314
|
}[]) => Effect.Effect<MutableOpenApiPaths, never, never>;
|
|
247
315
|
|
|
248
316
|
/**
|
|
@@ -309,7 +377,7 @@ declare const normalizeStructureRefsEffect: (schemas: GeneratedSchemas) => Effec
|
|
|
309
377
|
/**
|
|
310
378
|
* Shared service dependency graph for generation pipelines.
|
|
311
379
|
*/
|
|
312
|
-
declare const generatorServicesLayer: Layer.Layer<
|
|
380
|
+
declare const generatorServicesLayer: Layer.Layer<ProjectService | ModuleTraversalService | ConfigService | SchemaService | ValidationService | MethodExtractionService | OutputService, never, never>;
|
|
313
381
|
|
|
314
382
|
/** Handles aliased symbols (re-exports) */
|
|
315
383
|
declare const resolveClassFromSymbol: (sym: Symbol) => Option.Option<ClassDeclaration>;
|
|
@@ -329,4 +397,4 @@ interface ModuleMetadata {
|
|
|
329
397
|
declare const getModuleMetadata: (mod: ClassDeclaration) => ModuleMetadata;
|
|
330
398
|
|
|
331
399
|
export { ConfigService, GeneratedSchemas, MethodExtractionService, MethodInfo, ModuleTraversalService, OPENAPI_MODULE_OPTIONS, OPENAPI_SPEC, OpenApiModule, OpenApiPaths$1 as OpenApiPaths, OpenApiSchema, OpenApiSpec, OutputService, ProjectService, SchemaService, SpecFileNotFoundError, SpecFileParseError, SpecFileReadError, ValidationService, filterInternalSchemas, filterInternalSchemasEffect, filterSchemas, filterSchemasEffect, generateSwaggerUiHtml, generatorServicesLayer, getArrayInitializer, getControllerName, getControllerPrefix, getControllerTags, getDecoratorName, getHttpDecorator, getHttpMethods, getModuleDecoratorArg, getModuleMetadata, getStringLiteralValue, getSymbolFromIdentifier, isHttpDecorator, isHttpMethod, isModuleClass, loadSpecFile, loadSpecFileEffect, mergeGeneratedSchemas, mergeGeneratedSchemasEffect, mergeSchemas, mergeSchemasEffect, normalizePath, normalizeSchemas, normalizeSchemasEffect, normalizeStructureRefs, normalizeStructureRefsEffect, resolveArrayOfClasses, resolveClassFromExpression, resolveClassFromSymbol, resolveOptions, toPascalCase, transformMethod, transformMethodEffect, transformMethods, transformMethodsEffect };
|
|
332
|
-
export type { MergedResult, ModuleMetadata, NormalizerOptions, OpenApiModuleOptions, ResolvedOpenApiModuleOptions, SwaggerOptions };
|
|
400
|
+
export type { LoadSpecFileOptions, MergedResult, ModuleMetadata, NormalizerOptions, OpenApiDocumentFileSource, OpenApiDocumentSource, OpenApiHttpApplication, OpenApiModuleOptions, OpenApiSetupOptions, ResolvedOpenApiModuleOptions, SwaggerOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as OpenApiSpec, S as SpecFileNotFoundError, a as SpecFileReadError, b as SpecFileParseError, M as MethodInfo, c as OpenApiPaths, d as OpenApiOperation, e as OpenApiPaths$1, G as GeneratedSchemas, f as OpenApiSchema,
|
|
2
|
-
export { a4 as AnalysisError, aJ as BrokenRef, aK as BrokenRefCategories, az as ClassValidationInfo, n as Config, a3 as ConfigError, X as ConfigLoadError, W as ConfigNotFoundError, Y as ConfigValidationError, o as ContactConfig, Z as DtoGlobResolutionError, U as EntryNotFoundError, E as GenerateOptions, s as GenerateOverrides, l as GenerateResult, a5 as GeneratorError, J as HttpMethod, I as InfoConfig, _ as InvalidMethodError, am as JsonSchema, L as LicenseConfig, $ as MissingGenericSchemaTempFileCleanupError, a0 as MissingGenericSchemaTempFileWriteError, ac as ModuleWithControllers, K as OpenApiGeneratorConfig, t as OpenApiOperation, u as OpenApiParameter, v as OpenApiRequestBody, w as OpenApiResponse, q as OutputFormat, F as ParameterLocation, a8 as ProjectContext, a2 as ProjectError, Q as ProjectInitError, a9 as ProjectOptions, a6 as ProjectServiceLive, ay as PropertyValidationInfo, a1 as PublicApiError, N as ResolvedConfig, R as ResolvedParameter, H as ReturnTypeInfo, ak as SchemaError, aj as SchemaGenerationError, al as SchemaGeneratorOptions, p as ServerConfig, T as TagConfig, r as TelemetryConfig, ax as ValidationConstraints, aI as ValidationResult, au as applyConstraintsToSchema, aG as categorizeBrokenRefs, m as defineConfig, as as extractClassConstraints, aq as extractClassValidationInfo, ar as extractClassValidationInfoEffect, an as extractPropertyConstraints, ap as extractPropertyValidationInfo, aA as findConfigFile, aH as formatValidationResult, k as generate, y as generateAsync, x as generateEffect, D as generateFromConfigAsync, B as generateFromConfigEffect, A as generatePathsAsync, z as generatePathsEffect, ah as generateSchemas, ai as generateSchemasFromFiles, ab as getAllControllers, af as getControllerMethodInfos, ag as getControllerMethodInfosEffect, ad as getMethodInfo, ae as getMethodInfoEffect, aa as getModules, at as getRequiredProperties, ao as isPropertyOptional, aE as loadAndResolveConfig, aC as loadConfig, aB as loadConfigFromFile, a7 as makeProjectContext, av as mergeValidationConstraints, aw as mergeValidationConstraintsEffect, aD as resolveConfig, aF as validateSpec } from './shared/nestjs-openapi.
|
|
1
|
+
import { O as OpenApiSpec, S as SpecFileNotFoundError, a as SpecFileReadError, b as SpecFileParseError, M as MethodInfo, c as OpenApiPaths, d as OpenApiOperation, e as OpenApiPaths$1, G as GeneratedSchemas, f as OpenApiSchema, P as ProjectService, g as ModuleTraversalService, C as ConfigService, h as SchemaService, V as ValidationService, i as MethodExtractionService, j as OutputService } from './shared/nestjs-openapi.CAanamW0.js';
|
|
2
|
+
export { a4 as AnalysisError, aJ as BrokenRef, aK as BrokenRefCategories, az as ClassValidationInfo, n as Config, a3 as ConfigError, X as ConfigLoadError, W as ConfigNotFoundError, Y as ConfigValidationError, o as ContactConfig, Z as DtoGlobResolutionError, U as EntryNotFoundError, E as GenerateOptions, s as GenerateOverrides, l as GenerateResult, a5 as GeneratorError, J as HttpMethod, I as InfoConfig, _ as InvalidMethodError, am as JsonSchema, L as LicenseConfig, $ as MissingGenericSchemaTempFileCleanupError, a0 as MissingGenericSchemaTempFileWriteError, ac as ModuleWithControllers, K as OpenApiGeneratorConfig, t as OpenApiOperation, u as OpenApiParameter, v as OpenApiRequestBody, w as OpenApiResponse, q as OutputFormat, F as ParameterLocation, a8 as ProjectContext, a2 as ProjectError, Q as ProjectInitError, a9 as ProjectOptions, a6 as ProjectServiceLive, ay as PropertyValidationInfo, a1 as PublicApiError, N as ResolvedConfig, R as ResolvedParameter, H as ReturnTypeInfo, ak as SchemaError, aj as SchemaGenerationError, al as SchemaGeneratorOptions, p as ServerConfig, T as TagConfig, r as TelemetryConfig, ax as ValidationConstraints, aI as ValidationResult, au as applyConstraintsToSchema, aG as categorizeBrokenRefs, m as defineConfig, as as extractClassConstraints, aq as extractClassValidationInfo, ar as extractClassValidationInfoEffect, an as extractPropertyConstraints, ap as extractPropertyValidationInfo, aA as findConfigFile, aH as formatValidationResult, k as generate, y as generateAsync, x as generateEffect, D as generateFromConfigAsync, B as generateFromConfigEffect, A as generatePathsAsync, z as generatePathsEffect, ah as generateSchemas, ai as generateSchemasFromFiles, ab as getAllControllers, af as getControllerMethodInfos, ag as getControllerMethodInfosEffect, ad as getMethodInfo, ae as getMethodInfoEffect, aa as getModules, at as getRequiredProperties, ao as isPropertyOptional, aE as loadAndResolveConfig, aC as loadConfig, aB as loadConfigFromFile, a7 as makeProjectContext, av as mergeValidationConstraints, aw as mergeValidationConstraintsEffect, aD as resolveConfig, aF as validateSpec } from './shared/nestjs-openapi.CAanamW0.js';
|
|
3
3
|
import { DynamicModule } from '@nestjs/common';
|
|
4
4
|
import { Effect, Option, Layer } from 'effect';
|
|
5
5
|
import { ClassDeclaration, MethodDeclaration, Decorator, Symbol, ObjectLiteralExpression, Expression } from 'ts-morph';
|
|
@@ -38,10 +38,24 @@ interface SwaggerOptions {
|
|
|
38
38
|
*/
|
|
39
39
|
readonly title?: string;
|
|
40
40
|
}
|
|
41
|
+
interface LoadSpecFileOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Additional spec files to try when the primary file is missing.
|
|
44
|
+
*/
|
|
45
|
+
readonly fallbackSpecFiles?: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
interface OpenApiDocumentFileSource extends LoadSpecFileOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Path to the generated OpenAPI JSON file.
|
|
50
|
+
* Can be absolute or relative to the current working directory.
|
|
51
|
+
*/
|
|
52
|
+
readonly specFile: string;
|
|
53
|
+
}
|
|
54
|
+
type OpenApiDocumentSource = OpenApiSpec | (() => OpenApiSpec) | OpenApiDocumentFileSource;
|
|
41
55
|
/**
|
|
42
56
|
* Configuration options for the OpenAPI module
|
|
43
57
|
*/
|
|
44
|
-
interface OpenApiModuleOptions {
|
|
58
|
+
interface OpenApiModuleOptions extends LoadSpecFileOptions {
|
|
45
59
|
/**
|
|
46
60
|
* Path to the generated OpenAPI JSON file.
|
|
47
61
|
* Can be absolute or relative to the current working directory.
|
|
@@ -72,6 +86,7 @@ interface OpenApiModuleOptions {
|
|
|
72
86
|
*/
|
|
73
87
|
interface ResolvedOpenApiModuleOptions {
|
|
74
88
|
readonly specFile: string;
|
|
89
|
+
readonly fallbackSpecFiles: readonly string[];
|
|
75
90
|
readonly enabled: boolean;
|
|
76
91
|
readonly jsonPath: string;
|
|
77
92
|
readonly swagger: {
|
|
@@ -88,6 +103,52 @@ declare const OPENAPI_MODULE_OPTIONS: unique symbol;
|
|
|
88
103
|
* Injection token for the loaded OpenAPI specification
|
|
89
104
|
*/
|
|
90
105
|
declare const OPENAPI_SPEC: unique symbol;
|
|
106
|
+
interface OpenApiRouteRegistrar {
|
|
107
|
+
readonly get: (path: string, handler: (request: unknown, response: unknown) => void) => void;
|
|
108
|
+
}
|
|
109
|
+
interface OpenApiHttpApplication {
|
|
110
|
+
readonly config?: {
|
|
111
|
+
readonly getGlobalPrefix?: () => string;
|
|
112
|
+
};
|
|
113
|
+
readonly getHttpAdapter: () => OpenApiRouteRegistrar;
|
|
114
|
+
}
|
|
115
|
+
interface OpenApiSetupOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Whether OpenAPI routes should be registered.
|
|
118
|
+
* @default true
|
|
119
|
+
*/
|
|
120
|
+
readonly enabled?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Prefix OpenAPI routes with the app's `setGlobalPrefix()` value.
|
|
123
|
+
* Matches @nestjs/swagger's `SwaggerCustomOptions.useGlobalPrefix`.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
readonly useGlobalPrefix?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Raw OpenAPI JSON endpoint path.
|
|
129
|
+
* Matches @nestjs/swagger's `SwaggerCustomOptions.jsonDocumentUrl`.
|
|
130
|
+
* @default `${docsPath}-json`
|
|
131
|
+
*/
|
|
132
|
+
readonly jsonDocumentUrl?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Whether Swagger UI should be served.
|
|
135
|
+
* Matches @nestjs/swagger's `SwaggerCustomOptions.ui`.
|
|
136
|
+
* @default true
|
|
137
|
+
*/
|
|
138
|
+
readonly ui?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Whether raw OpenAPI definitions should be served.
|
|
141
|
+
* Only JSON is supported.
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
144
|
+
readonly raw?: boolean | readonly 'json'[];
|
|
145
|
+
/**
|
|
146
|
+
* Browser title for Swagger UI.
|
|
147
|
+
* Matches @nestjs/swagger's `SwaggerCustomOptions.customSiteTitle`.
|
|
148
|
+
* Uses the spec's info.title if not provided.
|
|
149
|
+
*/
|
|
150
|
+
readonly customSiteTitle?: string;
|
|
151
|
+
}
|
|
91
152
|
/**
|
|
92
153
|
* Generate Swagger UI HTML page
|
|
93
154
|
*/
|
|
@@ -95,8 +156,8 @@ declare function generateSwaggerUiHtml(title: string, jsonPath: string): string;
|
|
|
95
156
|
/**
|
|
96
157
|
* Load the OpenAPI spec file from disk
|
|
97
158
|
*/
|
|
98
|
-
declare const loadSpecFileEffect: (filePath: string) => Effect.Effect<OpenApiSpec, SpecFileNotFoundError | SpecFileReadError | SpecFileParseError, never>;
|
|
99
|
-
declare function loadSpecFile(filePath: string): OpenApiSpec;
|
|
159
|
+
declare const loadSpecFileEffect: (filePath: string, options?: LoadSpecFileOptions | undefined) => Effect.Effect<OpenApiSpec, SpecFileNotFoundError | SpecFileReadError | SpecFileParseError, never>;
|
|
160
|
+
declare function loadSpecFile(filePath: string, options?: LoadSpecFileOptions): OpenApiSpec;
|
|
100
161
|
/**
|
|
101
162
|
* Resolve options with defaults
|
|
102
163
|
*/
|
|
@@ -143,6 +204,13 @@ declare class OpenApiModule {
|
|
|
143
204
|
* @returns Dynamic module configuration
|
|
144
205
|
*/
|
|
145
206
|
static forRoot(options: OpenApiModuleOptions): DynamicModule;
|
|
207
|
+
/**
|
|
208
|
+
* Register OpenAPI JSON and Swagger UI routes on an already-created Nest app.
|
|
209
|
+
*
|
|
210
|
+
* Use this when the route config depends on services that are only available
|
|
211
|
+
* during bootstrap. For module-level static config, prefer `forRoot()`.
|
|
212
|
+
*/
|
|
213
|
+
static setup(path: string, app: OpenApiHttpApplication, documentSource: OpenApiDocumentSource, options?: OpenApiSetupOptions): void;
|
|
146
214
|
}
|
|
147
215
|
|
|
148
216
|
declare const normalizePath: (path: string) => string;
|
|
@@ -159,8 +227,12 @@ declare const getHttpDecorator: (method: MethodDeclaration) => Decorator | undef
|
|
|
159
227
|
|
|
160
228
|
declare const transformMethod: (methodInfo: MethodInfo) => OpenApiPaths;
|
|
161
229
|
declare const transformMethodEffect: (methodInfo: {
|
|
162
|
-
readonly
|
|
230
|
+
readonly security: readonly {
|
|
231
|
+
readonly scopes: readonly string[];
|
|
232
|
+
readonly schemeName: string;
|
|
233
|
+
}[];
|
|
163
234
|
readonly path: string;
|
|
235
|
+
readonly httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD" | "ALL";
|
|
164
236
|
readonly methodName: string;
|
|
165
237
|
readonly controllerName: string;
|
|
166
238
|
readonly controllerTags: readonly string[];
|
|
@@ -172,10 +244,10 @@ declare const transformMethodEffect: (methodInfo: {
|
|
|
172
244
|
};
|
|
173
245
|
readonly parameters: readonly {
|
|
174
246
|
readonly name: string;
|
|
175
|
-
readonly
|
|
247
|
+
readonly description: Option.Option<string>;
|
|
248
|
+
readonly location: "query" | "header" | "cookie" | "path" | "body";
|
|
176
249
|
readonly tsType: string;
|
|
177
250
|
readonly required: boolean;
|
|
178
|
-
readonly description: Option.Option<string>;
|
|
179
251
|
}[];
|
|
180
252
|
readonly decorators: readonly string[];
|
|
181
253
|
readonly operation: {
|
|
@@ -185,18 +257,14 @@ declare const transformMethodEffect: (methodInfo: {
|
|
|
185
257
|
readonly deprecated: Option.Option<boolean>;
|
|
186
258
|
};
|
|
187
259
|
readonly responses: readonly {
|
|
188
|
-
readonly type: Option.Option<string>;
|
|
189
260
|
readonly description: Option.Option<string>;
|
|
261
|
+
readonly type: Option.Option<string>;
|
|
190
262
|
readonly statusCode: number;
|
|
191
263
|
readonly isArray: boolean;
|
|
192
264
|
}[];
|
|
193
265
|
readonly httpCode: Option.Option<number>;
|
|
194
266
|
readonly consumes: readonly string[];
|
|
195
267
|
readonly produces: readonly string[];
|
|
196
|
-
readonly security: readonly {
|
|
197
|
-
readonly schemeName: string;
|
|
198
|
-
readonly scopes: readonly string[];
|
|
199
|
-
}[];
|
|
200
268
|
}) => Effect.Effect<OpenApiPaths, never, never>;
|
|
201
269
|
type MutableOpenApiPaths = {
|
|
202
270
|
[path: string]: {
|
|
@@ -205,8 +273,12 @@ type MutableOpenApiPaths = {
|
|
|
205
273
|
};
|
|
206
274
|
declare const transformMethods: (methodInfos: readonly MethodInfo[]) => OpenApiPaths;
|
|
207
275
|
declare const transformMethodsEffect: (methodInfos: readonly {
|
|
208
|
-
readonly
|
|
276
|
+
readonly security: readonly {
|
|
277
|
+
readonly scopes: readonly string[];
|
|
278
|
+
readonly schemeName: string;
|
|
279
|
+
}[];
|
|
209
280
|
readonly path: string;
|
|
281
|
+
readonly httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD" | "ALL";
|
|
210
282
|
readonly methodName: string;
|
|
211
283
|
readonly controllerName: string;
|
|
212
284
|
readonly controllerTags: readonly string[];
|
|
@@ -218,10 +290,10 @@ declare const transformMethodsEffect: (methodInfos: readonly {
|
|
|
218
290
|
};
|
|
219
291
|
readonly parameters: readonly {
|
|
220
292
|
readonly name: string;
|
|
221
|
-
readonly
|
|
293
|
+
readonly description: Option.Option<string>;
|
|
294
|
+
readonly location: "query" | "header" | "cookie" | "path" | "body";
|
|
222
295
|
readonly tsType: string;
|
|
223
296
|
readonly required: boolean;
|
|
224
|
-
readonly description: Option.Option<string>;
|
|
225
297
|
}[];
|
|
226
298
|
readonly decorators: readonly string[];
|
|
227
299
|
readonly operation: {
|
|
@@ -231,18 +303,14 @@ declare const transformMethodsEffect: (methodInfos: readonly {
|
|
|
231
303
|
readonly deprecated: Option.Option<boolean>;
|
|
232
304
|
};
|
|
233
305
|
readonly responses: readonly {
|
|
234
|
-
readonly type: Option.Option<string>;
|
|
235
306
|
readonly description: Option.Option<string>;
|
|
307
|
+
readonly type: Option.Option<string>;
|
|
236
308
|
readonly statusCode: number;
|
|
237
309
|
readonly isArray: boolean;
|
|
238
310
|
}[];
|
|
239
311
|
readonly httpCode: Option.Option<number>;
|
|
240
312
|
readonly consumes: readonly string[];
|
|
241
313
|
readonly produces: readonly string[];
|
|
242
|
-
readonly security: readonly {
|
|
243
|
-
readonly schemeName: string;
|
|
244
|
-
readonly scopes: readonly string[];
|
|
245
|
-
}[];
|
|
246
314
|
}[]) => Effect.Effect<MutableOpenApiPaths, never, never>;
|
|
247
315
|
|
|
248
316
|
/**
|
|
@@ -309,7 +377,7 @@ declare const normalizeStructureRefsEffect: (schemas: GeneratedSchemas) => Effec
|
|
|
309
377
|
/**
|
|
310
378
|
* Shared service dependency graph for generation pipelines.
|
|
311
379
|
*/
|
|
312
|
-
declare const generatorServicesLayer: Layer.Layer<
|
|
380
|
+
declare const generatorServicesLayer: Layer.Layer<ProjectService | ModuleTraversalService | ConfigService | SchemaService | ValidationService | MethodExtractionService | OutputService, never, never>;
|
|
313
381
|
|
|
314
382
|
/** Handles aliased symbols (re-exports) */
|
|
315
383
|
declare const resolveClassFromSymbol: (sym: Symbol) => Option.Option<ClassDeclaration>;
|
|
@@ -329,4 +397,4 @@ interface ModuleMetadata {
|
|
|
329
397
|
declare const getModuleMetadata: (mod: ClassDeclaration) => ModuleMetadata;
|
|
330
398
|
|
|
331
399
|
export { ConfigService, GeneratedSchemas, MethodExtractionService, MethodInfo, ModuleTraversalService, OPENAPI_MODULE_OPTIONS, OPENAPI_SPEC, OpenApiModule, OpenApiPaths$1 as OpenApiPaths, OpenApiSchema, OpenApiSpec, OutputService, ProjectService, SchemaService, SpecFileNotFoundError, SpecFileParseError, SpecFileReadError, ValidationService, filterInternalSchemas, filterInternalSchemasEffect, filterSchemas, filterSchemasEffect, generateSwaggerUiHtml, generatorServicesLayer, getArrayInitializer, getControllerName, getControllerPrefix, getControllerTags, getDecoratorName, getHttpDecorator, getHttpMethods, getModuleDecoratorArg, getModuleMetadata, getStringLiteralValue, getSymbolFromIdentifier, isHttpDecorator, isHttpMethod, isModuleClass, loadSpecFile, loadSpecFileEffect, mergeGeneratedSchemas, mergeGeneratedSchemasEffect, mergeSchemas, mergeSchemasEffect, normalizePath, normalizeSchemas, normalizeSchemasEffect, normalizeStructureRefs, normalizeStructureRefsEffect, resolveArrayOfClasses, resolveClassFromExpression, resolveClassFromSymbol, resolveOptions, toPascalCase, transformMethod, transformMethodEffect, transformMethods, transformMethodsEffect };
|
|
332
|
-
export type { MergedResult, ModuleMetadata, NormalizerOptions, OpenApiModuleOptions, ResolvedOpenApiModuleOptions, SwaggerOptions };
|
|
400
|
+
export type { LoadSpecFileOptions, MergedResult, ModuleMetadata, NormalizerOptions, OpenApiDocumentFileSource, OpenApiDocumentSource, OpenApiHttpApplication, OpenApiModuleOptions, OpenApiSetupOptions, ResolvedOpenApiModuleOptions, SwaggerOptions };
|