@visulima/jsdoc-open-api 3.0.0-alpha.4 → 3.0.0-alpha.5
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/CHANGELOG.md +33 -0
- package/LICENSE.md +1 -1
- package/dist/cli/command/generate-command.d.cts +7 -0
- package/dist/cli/command/generate-command.d.mts +7 -0
- package/dist/cli/command/generate-command.d.ts +7 -0
- package/dist/cli/command/init-command.d.cts +2 -0
- package/dist/cli/command/init-command.d.mts +2 -0
- package/dist/cli/command/init-command.d.ts +2 -0
- package/dist/cli/commander/command/generate-command.d.cts +3 -0
- package/dist/cli/commander/command/generate-command.d.mts +3 -0
- package/dist/cli/commander/command/generate-command.d.ts +3 -0
- package/dist/cli/commander/command/init-command.d.cts +3 -0
- package/dist/cli/commander/command/init-command.d.mts +3 -0
- package/dist/cli/commander/command/init-command.d.ts +3 -0
- package/dist/cli/commander/index.cjs +11 -0
- package/dist/cli/commander/index.d.cts +2 -0
- package/dist/cli/commander/index.d.mts +2 -7
- package/dist/cli/commander/index.d.ts +2 -7
- package/dist/cli/commander/index.mjs +2 -30
- package/dist/cli/index.cjs +11 -0
- package/dist/cli/index.d.cts +2 -0
- package/dist/cli/index.d.mts +2 -10
- package/dist/cli/index.d.ts +2 -10
- package/dist/cli/index.mjs +2 -4
- package/dist/constants.d.cts +1 -0
- package/dist/constants.d.mts +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/exported.d.cts +198 -0
- package/dist/exported.d.mts +198 -0
- package/dist/exported.d.ts +198 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -248
- package/dist/index.d.ts +7 -248
- package/dist/index.mjs +6 -85
- package/dist/jsdoc/comments-to-open-api.d.cts +6 -0
- package/dist/jsdoc/comments-to-open-api.d.mts +6 -0
- package/dist/jsdoc/comments-to-open-api.d.ts +6 -0
- package/dist/packem_shared/SpecBuilder-B7YiF7zR.mjs +61 -0
- package/dist/packem_shared/SpecBuilder-CCESkmm5.cjs +63 -0
- package/dist/packem_shared/SwaggerCompilerPlugin-BEbFO9Dt.mjs +86 -0
- package/dist/packem_shared/SwaggerCompilerPlugin-BHbHAPK-.cjs +88 -0
- package/dist/packem_shared/customizer-CoMXMU7a.mjs +8 -0
- package/dist/packem_shared/customizer-DDFwFqJl.cjs +10 -0
- package/dist/packem_shared/generateCommand-B1t3VSDX.mjs +15 -0
- package/dist/packem_shared/generateCommand-CZEFuXr9.mjs +83 -0
- package/dist/packem_shared/generateCommand-CmyavGTZ.cjs +17 -0
- package/dist/packem_shared/generateCommand-Cu0UQUh8.cjs +85 -0
- package/dist/packem_shared/initCommand-B6Z9EXHP.mjs +15 -0
- package/dist/packem_shared/initCommand-Ch-72dKZ.cjs +65 -0
- package/dist/packem_shared/initCommand-D3yVEMwO.cjs +17 -0
- package/dist/packem_shared/initCommand-zE4VRDGW.mjs +63 -0
- package/dist/packem_shared/jsDocumentCommentsToOpenApi-C8kxIQH2.cjs +334 -0
- package/dist/packem_shared/jsDocumentCommentsToOpenApi-eOlxMuMO.mjs +328 -0
- package/dist/packem_shared/parseFile-BJwu_na4.cjs +42 -0
- package/dist/packem_shared/parseFile-Bxis7tbW.mjs +35 -0
- package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-Cb5s1J29.mjs +130 -0
- package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-JFymRz50.cjs +137 -0
- package/dist/packem_shared/validate-DZHaKH07.mjs +30 -0
- package/dist/packem_shared/validate-FKieC3ln.cjs +37 -0
- package/dist/packem_shared/yamlLoc-BLoIYoXs.cjs +14 -0
- package/dist/packem_shared/yamlLoc-Cmx4vbRt.mjs +12 -0
- package/dist/parse-file.d.cts +9 -0
- package/dist/parse-file.d.mts +9 -0
- package/dist/parse-file.d.ts +9 -0
- package/dist/spec-builder.d.cts +14 -0
- package/dist/spec-builder.d.mts +14 -0
- package/dist/spec-builder.d.ts +14 -0
- package/dist/swagger-jsdoc/comments-to-open-api.d.cts +6 -0
- package/dist/swagger-jsdoc/comments-to-open-api.d.mts +6 -0
- package/dist/swagger-jsdoc/comments-to-open-api.d.ts +6 -0
- package/dist/swagger-jsdoc/organize-swagger-object.d.cts +7 -0
- package/dist/swagger-jsdoc/organize-swagger-object.d.mts +7 -0
- package/dist/swagger-jsdoc/organize-swagger-object.d.ts +7 -0
- package/dist/swagger-jsdoc/utils.d.cts +21 -0
- package/dist/swagger-jsdoc/utils.d.mts +21 -0
- package/dist/swagger-jsdoc/utils.d.ts +21 -0
- package/dist/util/customizer.d.cts +2 -0
- package/dist/util/customizer.d.mts +2 -0
- package/dist/util/customizer.d.ts +2 -0
- package/dist/util/object-merge.d.cts +2 -0
- package/dist/util/object-merge.d.mts +2 -0
- package/dist/util/object-merge.d.ts +2 -0
- package/dist/util/yaml-loc.d.cts +2 -0
- package/dist/util/yaml-loc.d.mts +2 -0
- package/dist/util/yaml-loc.d.ts +2 -0
- package/dist/validate.d.cts +2 -0
- package/dist/validate.d.mts +2 -0
- package/dist/validate.d.ts +2 -0
- package/dist/webpack/swagger-compiler-plugin.d.cts +15 -0
- package/dist/webpack/swagger-compiler-plugin.d.mts +15 -0
- package/dist/webpack/swagger-compiler-plugin.d.ts +15 -0
- package/package.json +32 -19
- package/dist/chunk-2T6HMUIL.mjs +0 -1215
- package/dist/chunk-2T6HMUIL.mjs.map +0 -1
- package/dist/chunk-PTFTJY7I.js +0 -1233
- package/dist/chunk-PTFTJY7I.js.map +0 -1
- package/dist/chunk-RGP6RTJO.mjs +0 -142
- package/dist/chunk-RGP6RTJO.mjs.map +0 -1
- package/dist/chunk-RVCK3H3U.js +0 -149
- package/dist/chunk-RVCK3H3U.js.map +0 -1
- package/dist/cli/commander/index.js +0 -33
- package/dist/cli/commander/index.js.map +0 -1
- package/dist/cli/commander/index.mjs.map +0 -1
- package/dist/cli/index.js +0 -17
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/index.mjs.map +0 -1
- package/dist/index.js +0 -106
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,248 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
paths?: PathsObject;
|
|
9
|
-
security?: SecurityRequirementObject[];
|
|
10
|
-
servers?: ServerObject[];
|
|
11
|
-
tags?: TagObject[];
|
|
12
|
-
}
|
|
13
|
-
interface OpenApiObject extends BaseDefinition {
|
|
14
|
-
paths?: PathsObject;
|
|
15
|
-
}
|
|
16
|
-
interface InfoObject {
|
|
17
|
-
contact?: ContactObject;
|
|
18
|
-
description?: string;
|
|
19
|
-
license?: LicenseObject;
|
|
20
|
-
termsOfService?: string;
|
|
21
|
-
title: string;
|
|
22
|
-
version: string;
|
|
23
|
-
}
|
|
24
|
-
interface ContactObject {
|
|
25
|
-
email?: string;
|
|
26
|
-
name?: string;
|
|
27
|
-
url?: string;
|
|
28
|
-
}
|
|
29
|
-
interface LicenseObject {
|
|
30
|
-
name: string;
|
|
31
|
-
url?: string;
|
|
32
|
-
}
|
|
33
|
-
interface ServerObject {
|
|
34
|
-
description?: string;
|
|
35
|
-
url: string;
|
|
36
|
-
variables?: Map<ServerVariable>;
|
|
37
|
-
}
|
|
38
|
-
interface ServerVariable {
|
|
39
|
-
default: string;
|
|
40
|
-
description?: string;
|
|
41
|
-
enum?: string[];
|
|
42
|
-
}
|
|
43
|
-
interface ComponentsObject {
|
|
44
|
-
callbacks?: Map<CallbackObject | ReferenceObject>;
|
|
45
|
-
examples?: Map<ExampleObject | ReferenceObject>;
|
|
46
|
-
headers?: Map<HeaderObject | ReferenceObject>;
|
|
47
|
-
links?: Map<LinkObject | ReferenceObject>;
|
|
48
|
-
parameters?: Map<ParameterObject | ReferenceObject>;
|
|
49
|
-
requestBodies?: Map<ReferenceObject | RequestBodyObject>;
|
|
50
|
-
responses?: Map<ReferenceObject | ResponseObject>;
|
|
51
|
-
schemas?: Map<ReferenceObject | SchemaObject>;
|
|
52
|
-
securitySchemes?: Map<ApiKeySecuritySchemeObject | HttpSecuritySchemeObject | Oauth2SecuritySchemeObject | OpenIdConnectSecuritySchemeObject | ReferenceObject>;
|
|
53
|
-
}
|
|
54
|
-
type PathsObject = Record<string, PathItemObject>;
|
|
55
|
-
interface PathItemObject {
|
|
56
|
-
$ref?: string;
|
|
57
|
-
delete?: OperationObject;
|
|
58
|
-
description?: string;
|
|
59
|
-
get?: OperationObject;
|
|
60
|
-
head?: OperationObject;
|
|
61
|
-
options?: OperationObject;
|
|
62
|
-
parameters?: (ParameterObject | ReferenceObject)[];
|
|
63
|
-
patch?: OperationObject;
|
|
64
|
-
post?: OperationObject;
|
|
65
|
-
put?: OperationObject;
|
|
66
|
-
servers?: ServerObject[];
|
|
67
|
-
summary?: string;
|
|
68
|
-
trace?: OperationObject;
|
|
69
|
-
}
|
|
70
|
-
interface OperationObject {
|
|
71
|
-
callbacks?: Map<CallbackObject | ReferenceObject>;
|
|
72
|
-
deprecated?: boolean;
|
|
73
|
-
description?: string;
|
|
74
|
-
externalDocs?: ExternalDocumentationObject;
|
|
75
|
-
operationId?: string;
|
|
76
|
-
parameters?: (ParameterObject | ReferenceObject)[];
|
|
77
|
-
requestBody?: ReferenceObject | RequestBodyObject;
|
|
78
|
-
responses: ResponsesObject;
|
|
79
|
-
security?: SecurityRequirementObject[];
|
|
80
|
-
servers?: ServerObject[];
|
|
81
|
-
summary?: string;
|
|
82
|
-
tags?: string[];
|
|
83
|
-
}
|
|
84
|
-
interface ExternalDocumentationObject {
|
|
85
|
-
description?: string;
|
|
86
|
-
url: string;
|
|
87
|
-
}
|
|
88
|
-
interface ParameterObject {
|
|
89
|
-
allowEmptyValue?: boolean;
|
|
90
|
-
allowReserved?: boolean;
|
|
91
|
-
content?: Map<MediaTypeObject>;
|
|
92
|
-
deprecated?: boolean;
|
|
93
|
-
description?: string;
|
|
94
|
-
example?: any;
|
|
95
|
-
examples?: Map<ExampleObject | ReferenceObject>;
|
|
96
|
-
explode?: string;
|
|
97
|
-
in: string;
|
|
98
|
-
name: string;
|
|
99
|
-
required?: boolean;
|
|
100
|
-
schema?: ReferenceObject | SchemaObject;
|
|
101
|
-
style?: string;
|
|
102
|
-
}
|
|
103
|
-
interface RequestBodyObject {
|
|
104
|
-
content: Map<MediaTypeObject>;
|
|
105
|
-
description?: string;
|
|
106
|
-
required?: boolean;
|
|
107
|
-
}
|
|
108
|
-
interface MediaTypeObject {
|
|
109
|
-
encoding?: Map<EncodingObject>;
|
|
110
|
-
example?: any;
|
|
111
|
-
examples?: Map<ExampleObject | ReferenceObject>;
|
|
112
|
-
schema?: ReferenceObject | SchemaObject;
|
|
113
|
-
}
|
|
114
|
-
interface EncodingObject {
|
|
115
|
-
allowReserved?: boolean;
|
|
116
|
-
contentType?: string;
|
|
117
|
-
explode?: boolean;
|
|
118
|
-
headers?: Map<HeaderObject | ReferenceObject>;
|
|
119
|
-
style?: string;
|
|
120
|
-
}
|
|
121
|
-
type ResponsesObject = Record<string, ReferenceObject | ResponseObject>;
|
|
122
|
-
interface ResponseObject {
|
|
123
|
-
content?: Map<MediaTypeObject>;
|
|
124
|
-
description: string;
|
|
125
|
-
headers?: Map<HeaderObject | ReferenceObject>;
|
|
126
|
-
links?: Map<LinkObject | ReferenceObject>;
|
|
127
|
-
}
|
|
128
|
-
type CallbackObject = Record<string, PathItemObject>;
|
|
129
|
-
interface ExampleObject {
|
|
130
|
-
description?: string;
|
|
131
|
-
externalValue?: string;
|
|
132
|
-
summary?: string;
|
|
133
|
-
value?: any;
|
|
134
|
-
}
|
|
135
|
-
interface LinkObject {
|
|
136
|
-
description?: string;
|
|
137
|
-
operationId?: string;
|
|
138
|
-
operationRef?: string;
|
|
139
|
-
parameters?: Map<any>;
|
|
140
|
-
requestBody?: any;
|
|
141
|
-
server?: ServerObject;
|
|
142
|
-
}
|
|
143
|
-
interface HeaderObject {
|
|
144
|
-
allowEmptyValue?: boolean;
|
|
145
|
-
allowReserved?: boolean;
|
|
146
|
-
content?: Map<MediaTypeObject>;
|
|
147
|
-
deprecated?: boolean;
|
|
148
|
-
description?: string;
|
|
149
|
-
example?: any;
|
|
150
|
-
examples?: Map<ExampleObject | ReferenceObject>;
|
|
151
|
-
explode?: string;
|
|
152
|
-
required?: boolean;
|
|
153
|
-
schema?: ReferenceObject | SchemaObject;
|
|
154
|
-
style?: string;
|
|
155
|
-
}
|
|
156
|
-
interface TagObject {
|
|
157
|
-
description?: string;
|
|
158
|
-
externalDocs?: ExternalDocumentationObject;
|
|
159
|
-
name: string;
|
|
160
|
-
}
|
|
161
|
-
interface ReferenceObject {
|
|
162
|
-
$ref: string;
|
|
163
|
-
}
|
|
164
|
-
type SchemaObject = Record<string, any>;
|
|
165
|
-
interface ApiKeySecuritySchemeObject {
|
|
166
|
-
description?: string;
|
|
167
|
-
in: string;
|
|
168
|
-
name: string;
|
|
169
|
-
type: string;
|
|
170
|
-
}
|
|
171
|
-
interface HttpSecuritySchemeObject {
|
|
172
|
-
bearerFormat?: string;
|
|
173
|
-
description?: string;
|
|
174
|
-
scheme: string;
|
|
175
|
-
type: string;
|
|
176
|
-
}
|
|
177
|
-
interface Oauth2SecuritySchemeObject {
|
|
178
|
-
description?: string;
|
|
179
|
-
flows: OAuthFlowsObject;
|
|
180
|
-
type: string;
|
|
181
|
-
}
|
|
182
|
-
interface OpenIdConnectSecuritySchemeObject {
|
|
183
|
-
description?: string;
|
|
184
|
-
openIdConnectUrl: string;
|
|
185
|
-
type: string;
|
|
186
|
-
}
|
|
187
|
-
interface OAuthFlowsObject {
|
|
188
|
-
authorizationCode?: OAuthFlowObject;
|
|
189
|
-
clientCredentials?: OAuthFlowObject;
|
|
190
|
-
implicit?: OAuthFlowObject;
|
|
191
|
-
password?: OAuthFlowObject;
|
|
192
|
-
}
|
|
193
|
-
interface OAuthFlowObject {
|
|
194
|
-
authorizationUrl?: string;
|
|
195
|
-
refreshUrl: string;
|
|
196
|
-
scopes: Map<string>;
|
|
197
|
-
tokenUrl?: string;
|
|
198
|
-
}
|
|
199
|
-
type SecurityRequirementObject = Record<string, string[]>;
|
|
200
|
-
type Map<T> = Record<string, T>;
|
|
201
|
-
|
|
202
|
-
declare const commentsToOpenApi$1: (fileContents: string, verbose?: boolean) => {
|
|
203
|
-
loc: number;
|
|
204
|
-
spec: OpenApiObject;
|
|
205
|
-
}[];
|
|
206
|
-
|
|
207
|
-
declare const parseFile: (file: string, commentsToOpenApi: (fileContent: string, verbose?: boolean) => {
|
|
208
|
-
loc: number;
|
|
209
|
-
spec: OpenApiObject;
|
|
210
|
-
}[], verbose?: boolean) => {
|
|
211
|
-
loc: number;
|
|
212
|
-
spec: OpenApiObject;
|
|
213
|
-
}[];
|
|
214
|
-
|
|
215
|
-
declare class SpecBuilder implements OpenApiObject {
|
|
216
|
-
components?: ComponentsObject;
|
|
217
|
-
externalDocs?: ExternalDocumentationObject;
|
|
218
|
-
info: InfoObject;
|
|
219
|
-
openapi: string;
|
|
220
|
-
paths: PathsObject;
|
|
221
|
-
security?: SecurityRequirementObject[];
|
|
222
|
-
servers?: ServerObject[];
|
|
223
|
-
tags?: TagObject[];
|
|
224
|
-
constructor(baseDefinition: BaseDefinition);
|
|
225
|
-
addData(parsedFile: OpenApiObject[]): void;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
declare const commentsToOpenApi: (fileContents: string, verbose?: boolean) => {
|
|
229
|
-
loc: number;
|
|
230
|
-
spec: OpenApiObject;
|
|
231
|
-
}[];
|
|
232
|
-
|
|
233
|
-
declare const yamlLoc: (string: string) => number;
|
|
234
|
-
|
|
235
|
-
declare class SwaggerCompilerPlugin {
|
|
236
|
-
private readonly assetsPath;
|
|
237
|
-
private readonly ignore;
|
|
238
|
-
private readonly sources;
|
|
239
|
-
private readonly swaggerDefinition;
|
|
240
|
-
private readonly verbose;
|
|
241
|
-
constructor(assetsPath: string, sources: string[], swaggerDefinition: BaseDefinition, options: {
|
|
242
|
-
ignore?: (RegExp | string)[];
|
|
243
|
-
verbose?: boolean;
|
|
244
|
-
});
|
|
245
|
-
apply(compiler: Compiler): void;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export { type BaseDefinition, type OpenApiObject, SpecBuilder, SwaggerCompilerPlugin, commentsToOpenApi$1 as jsDocumentCommentsToOpenApi, parseFile, commentsToOpenApi as swaggerJsDocumentCommentsToOpenApi, yamlLoc };
|
|
1
|
+
export type { BaseDefinition, OpenApiObject } from "./exported.d.ts";
|
|
2
|
+
export { default as jsDocumentCommentsToOpenApi } from "./jsdoc/comments-to-open-api.d.ts";
|
|
3
|
+
export { default as parseFile } from "./parse-file.d.ts";
|
|
4
|
+
export { default as SpecBuilder } from "./spec-builder.d.ts";
|
|
5
|
+
export { default as swaggerJsDocumentCommentsToOpenApi } from "./swagger-jsdoc/comments-to-open-api.d.ts";
|
|
6
|
+
export { default as yamlLoc } from "./util/yaml-loc.d.ts";
|
|
7
|
+
export { default as SwaggerCompilerPlugin } from "./webpack/swagger-compiler-plugin.d.ts";
|
package/dist/index.mjs
CHANGED
|
@@ -1,85 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var errorHandler = (error) => {
|
|
8
|
-
if (error) {
|
|
9
|
-
console.error(error);
|
|
10
|
-
exit(1);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
var SwaggerCompilerPlugin = class {
|
|
14
|
-
assetsPath;
|
|
15
|
-
ignore;
|
|
16
|
-
sources;
|
|
17
|
-
swaggerDefinition;
|
|
18
|
-
verbose;
|
|
19
|
-
constructor(assetsPath, sources, swaggerDefinition, options) {
|
|
20
|
-
this.assetsPath = assetsPath;
|
|
21
|
-
this.swaggerDefinition = swaggerDefinition;
|
|
22
|
-
this.sources = sources;
|
|
23
|
-
this.verbose = options.verbose ?? false;
|
|
24
|
-
this.ignore = options.ignore ?? [];
|
|
25
|
-
}
|
|
26
|
-
apply(compiler) {
|
|
27
|
-
const skip = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE, ...this.ignore]);
|
|
28
|
-
compiler.hooks.make.tapAsync("SwaggerCompilerPlugin", async (_, callback) => {
|
|
29
|
-
console.log("Build paused, switching to swagger build");
|
|
30
|
-
const spec = new spec_builder_default(this.swaggerDefinition);
|
|
31
|
-
for await (const dir of this.sources) {
|
|
32
|
-
const files = await collect(dir, {
|
|
33
|
-
extensions: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".yaml", ".yml"],
|
|
34
|
-
includeDirs: false,
|
|
35
|
-
skip: [...skip]
|
|
36
|
-
});
|
|
37
|
-
if (this.verbose) {
|
|
38
|
-
console.log(`Found ${String(files.length)} files in ${dir}`);
|
|
39
|
-
console.log(files);
|
|
40
|
-
}
|
|
41
|
-
files.forEach((file) => {
|
|
42
|
-
if (this.verbose) {
|
|
43
|
-
console.log(`Parsing file ${file}`);
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
const parsedJsDocumentFile = parse_file_default(file, comments_to_open_api_default, this.verbose);
|
|
47
|
-
spec.addData(parsedJsDocumentFile.map((item) => item.spec));
|
|
48
|
-
const parsedSwaggerJsDocumentFile = parse_file_default(file, comments_to_open_api_default2, this.verbose);
|
|
49
|
-
spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.error(error);
|
|
52
|
-
exit(1);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
if (this.verbose) {
|
|
58
|
-
console.log("Validating swagger spec");
|
|
59
|
-
console.log(JSON.stringify(spec, null, 2));
|
|
60
|
-
}
|
|
61
|
-
await validate_default(JSON.parse(JSON.stringify(spec)));
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error(error.toJSON());
|
|
64
|
-
exit(1);
|
|
65
|
-
}
|
|
66
|
-
const { assetsPath } = this;
|
|
67
|
-
mkdir(dirname(assetsPath), { recursive: true }, (error) => {
|
|
68
|
-
if (error) {
|
|
69
|
-
errorHandler(error);
|
|
70
|
-
}
|
|
71
|
-
writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);
|
|
72
|
-
});
|
|
73
|
-
if (this.verbose) {
|
|
74
|
-
console.log(`Written swagger spec to "${this.assetsPath}" file`);
|
|
75
|
-
}
|
|
76
|
-
console.log("switching back to normal build");
|
|
77
|
-
callback();
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
var swagger_compiler_plugin_default = SwaggerCompilerPlugin;
|
|
82
|
-
|
|
83
|
-
export { swagger_compiler_plugin_default as SwaggerCompilerPlugin };
|
|
84
|
-
//# sourceMappingURL=index.mjs.map
|
|
85
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export { default as jsDocumentCommentsToOpenApi } from './packem_shared/jsDocumentCommentsToOpenApi-eOlxMuMO.mjs';
|
|
2
|
+
export { default as parseFile } from './packem_shared/parseFile-Bxis7tbW.mjs';
|
|
3
|
+
export { default as SpecBuilder } from './packem_shared/SpecBuilder-B7YiF7zR.mjs';
|
|
4
|
+
export { default as swaggerJsDocumentCommentsToOpenApi } from './packem_shared/swaggerJsDocumentCommentsToOpenApi-Cb5s1J29.mjs';
|
|
5
|
+
export { default as yamlLoc } from './packem_shared/yamlLoc-Cmx4vbRt.mjs';
|
|
6
|
+
export { default as SwaggerCompilerPlugin } from './packem_shared/SwaggerCompilerPlugin-BEbFO9Dt.mjs';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const objectMerge = (a, b) => {
|
|
2
|
+
Object.keys(b).forEach((key) => {
|
|
3
|
+
if (a[key] === void 0) {
|
|
4
|
+
a[key] = {
|
|
5
|
+
...b[key]
|
|
6
|
+
};
|
|
7
|
+
} else {
|
|
8
|
+
Object.keys(b[key]).forEach((subKey) => {
|
|
9
|
+
a[key][subKey] = {
|
|
10
|
+
...a[key][subKey],
|
|
11
|
+
...b[key][subKey]
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
class SpecBuilder {
|
|
19
|
+
components;
|
|
20
|
+
externalDocs;
|
|
21
|
+
info;
|
|
22
|
+
openapi;
|
|
23
|
+
paths;
|
|
24
|
+
security;
|
|
25
|
+
servers;
|
|
26
|
+
tags;
|
|
27
|
+
constructor(baseDefinition) {
|
|
28
|
+
this.openapi = baseDefinition.openapi;
|
|
29
|
+
this.info = baseDefinition.info;
|
|
30
|
+
this.paths = baseDefinition.paths ?? {};
|
|
31
|
+
if (baseDefinition.servers) {
|
|
32
|
+
this.servers = baseDefinition.servers;
|
|
33
|
+
}
|
|
34
|
+
if (baseDefinition.components) {
|
|
35
|
+
this.components = baseDefinition.components;
|
|
36
|
+
}
|
|
37
|
+
if (baseDefinition.security) {
|
|
38
|
+
this.security = baseDefinition.security;
|
|
39
|
+
}
|
|
40
|
+
if (baseDefinition.tags) {
|
|
41
|
+
this.tags = baseDefinition.tags;
|
|
42
|
+
}
|
|
43
|
+
if (baseDefinition.externalDocs) {
|
|
44
|
+
this.externalDocs = baseDefinition.externalDocs;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
addData(parsedFile) {
|
|
48
|
+
parsedFile.forEach((file) => {
|
|
49
|
+
const { components, paths, ...rest } = file;
|
|
50
|
+
objectMerge(this, {
|
|
51
|
+
components: components ?? {},
|
|
52
|
+
paths: paths ?? {}
|
|
53
|
+
});
|
|
54
|
+
Object.entries(rest).forEach(([key, value]) => {
|
|
55
|
+
this[key] = value;
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { SpecBuilder as default };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const objectMerge = (a, b) => {
|
|
4
|
+
Object.keys(b).forEach((key) => {
|
|
5
|
+
if (a[key] === void 0) {
|
|
6
|
+
a[key] = {
|
|
7
|
+
...b[key]
|
|
8
|
+
};
|
|
9
|
+
} else {
|
|
10
|
+
Object.keys(b[key]).forEach((subKey) => {
|
|
11
|
+
a[key][subKey] = {
|
|
12
|
+
...a[key][subKey],
|
|
13
|
+
...b[key][subKey]
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
class SpecBuilder {
|
|
21
|
+
components;
|
|
22
|
+
externalDocs;
|
|
23
|
+
info;
|
|
24
|
+
openapi;
|
|
25
|
+
paths;
|
|
26
|
+
security;
|
|
27
|
+
servers;
|
|
28
|
+
tags;
|
|
29
|
+
constructor(baseDefinition) {
|
|
30
|
+
this.openapi = baseDefinition.openapi;
|
|
31
|
+
this.info = baseDefinition.info;
|
|
32
|
+
this.paths = baseDefinition.paths ?? {};
|
|
33
|
+
if (baseDefinition.servers) {
|
|
34
|
+
this.servers = baseDefinition.servers;
|
|
35
|
+
}
|
|
36
|
+
if (baseDefinition.components) {
|
|
37
|
+
this.components = baseDefinition.components;
|
|
38
|
+
}
|
|
39
|
+
if (baseDefinition.security) {
|
|
40
|
+
this.security = baseDefinition.security;
|
|
41
|
+
}
|
|
42
|
+
if (baseDefinition.tags) {
|
|
43
|
+
this.tags = baseDefinition.tags;
|
|
44
|
+
}
|
|
45
|
+
if (baseDefinition.externalDocs) {
|
|
46
|
+
this.externalDocs = baseDefinition.externalDocs;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
addData(parsedFile) {
|
|
50
|
+
parsedFile.forEach((file) => {
|
|
51
|
+
const { components, paths, ...rest } = file;
|
|
52
|
+
objectMerge(this, {
|
|
53
|
+
components: components ?? {},
|
|
54
|
+
paths: paths ?? {}
|
|
55
|
+
});
|
|
56
|
+
Object.entries(rest).forEach(([key, value]) => {
|
|
57
|
+
this[key] = value;
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = SpecBuilder;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { exit } from 'node:process';
|
|
4
|
+
import { collect } from '@visulima/fs';
|
|
5
|
+
import { v as validate, D as DEFAULT_EXCLUDE } from './validate-DZHaKH07.mjs';
|
|
6
|
+
import commentsToOpenApi from './jsDocumentCommentsToOpenApi-eOlxMuMO.mjs';
|
|
7
|
+
import parseFile from './parseFile-Bxis7tbW.mjs';
|
|
8
|
+
import SpecBuilder from './SpecBuilder-B7YiF7zR.mjs';
|
|
9
|
+
import commentsToOpenApi$1 from './swaggerJsDocumentCommentsToOpenApi-Cb5s1J29.mjs';
|
|
10
|
+
|
|
11
|
+
const errorHandler = (error) => {
|
|
12
|
+
if (error) {
|
|
13
|
+
console.error(error);
|
|
14
|
+
exit(1);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
class SwaggerCompilerPlugin {
|
|
18
|
+
assetsPath;
|
|
19
|
+
ignore;
|
|
20
|
+
sources;
|
|
21
|
+
swaggerDefinition;
|
|
22
|
+
verbose;
|
|
23
|
+
constructor(assetsPath, sources, swaggerDefinition, options) {
|
|
24
|
+
this.assetsPath = assetsPath;
|
|
25
|
+
this.swaggerDefinition = swaggerDefinition;
|
|
26
|
+
this.sources = sources;
|
|
27
|
+
this.verbose = options.verbose ?? false;
|
|
28
|
+
this.ignore = options.ignore ?? [];
|
|
29
|
+
}
|
|
30
|
+
apply(compiler) {
|
|
31
|
+
const skip = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE, ...this.ignore]);
|
|
32
|
+
compiler.hooks.make.tapAsync("SwaggerCompilerPlugin", async (_, callback) => {
|
|
33
|
+
console.log("Build paused, switching to swagger build");
|
|
34
|
+
const spec = new SpecBuilder(this.swaggerDefinition);
|
|
35
|
+
for await (const dir of this.sources) {
|
|
36
|
+
const files = await collect(dir, {
|
|
37
|
+
extensions: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".yaml", ".yml"],
|
|
38
|
+
includeDirs: false,
|
|
39
|
+
skip: [...skip]
|
|
40
|
+
});
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
console.log(`Found ${String(files.length)} files in ${dir}`);
|
|
43
|
+
console.log(files);
|
|
44
|
+
}
|
|
45
|
+
files.forEach((file) => {
|
|
46
|
+
if (this.verbose) {
|
|
47
|
+
console.log(`Parsing file ${file}`);
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const parsedJsDocumentFile = parseFile(file, commentsToOpenApi, this.verbose);
|
|
51
|
+
spec.addData(parsedJsDocumentFile.map((item) => item.spec));
|
|
52
|
+
const parsedSwaggerJsDocumentFile = parseFile(file, commentsToOpenApi$1, this.verbose);
|
|
53
|
+
spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error(error);
|
|
56
|
+
exit(1);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
if (this.verbose) {
|
|
62
|
+
console.log("Validating swagger spec");
|
|
63
|
+
console.log(JSON.stringify(spec, null, 2));
|
|
64
|
+
}
|
|
65
|
+
await validate(JSON.parse(JSON.stringify(spec)));
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error(error.toJSON());
|
|
68
|
+
exit(1);
|
|
69
|
+
}
|
|
70
|
+
const { assetsPath } = this;
|
|
71
|
+
mkdir(dirname(assetsPath), { recursive: true }, (error) => {
|
|
72
|
+
if (error) {
|
|
73
|
+
errorHandler(error);
|
|
74
|
+
}
|
|
75
|
+
writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);
|
|
76
|
+
});
|
|
77
|
+
if (this.verbose) {
|
|
78
|
+
console.log(`Written swagger spec to "${this.assetsPath}" file`);
|
|
79
|
+
}
|
|
80
|
+
console.log("switching back to normal build");
|
|
81
|
+
callback();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { SwaggerCompilerPlugin as default };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const node_fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const node_process = require('node:process');
|
|
6
|
+
const fs = require('@visulima/fs');
|
|
7
|
+
const validate = require('./validate-FKieC3ln.cjs');
|
|
8
|
+
const jsDocumentCommentsToOpenApi = require('./jsDocumentCommentsToOpenApi-C8kxIQH2.cjs');
|
|
9
|
+
const parseFile = require('./parseFile-BJwu_na4.cjs');
|
|
10
|
+
const SpecBuilder = require('./SpecBuilder-CCESkmm5.cjs');
|
|
11
|
+
const swaggerJsDocumentCommentsToOpenApi = require('./swaggerJsDocumentCommentsToOpenApi-JFymRz50.cjs');
|
|
12
|
+
|
|
13
|
+
const errorHandler = (error) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
console.error(error);
|
|
16
|
+
node_process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
class SwaggerCompilerPlugin {
|
|
20
|
+
assetsPath;
|
|
21
|
+
ignore;
|
|
22
|
+
sources;
|
|
23
|
+
swaggerDefinition;
|
|
24
|
+
verbose;
|
|
25
|
+
constructor(assetsPath, sources, swaggerDefinition, options) {
|
|
26
|
+
this.assetsPath = assetsPath;
|
|
27
|
+
this.swaggerDefinition = swaggerDefinition;
|
|
28
|
+
this.sources = sources;
|
|
29
|
+
this.verbose = options.verbose ?? false;
|
|
30
|
+
this.ignore = options.ignore ?? [];
|
|
31
|
+
}
|
|
32
|
+
apply(compiler) {
|
|
33
|
+
const skip = /* @__PURE__ */ new Set([...validate.DEFAULT_EXCLUDE, ...this.ignore]);
|
|
34
|
+
compiler.hooks.make.tapAsync("SwaggerCompilerPlugin", async (_, callback) => {
|
|
35
|
+
console.log("Build paused, switching to swagger build");
|
|
36
|
+
const spec = new SpecBuilder(this.swaggerDefinition);
|
|
37
|
+
for await (const dir of this.sources) {
|
|
38
|
+
const files = await fs.collect(dir, {
|
|
39
|
+
extensions: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".yaml", ".yml"],
|
|
40
|
+
includeDirs: false,
|
|
41
|
+
skip: [...skip]
|
|
42
|
+
});
|
|
43
|
+
if (this.verbose) {
|
|
44
|
+
console.log(`Found ${String(files.length)} files in ${dir}`);
|
|
45
|
+
console.log(files);
|
|
46
|
+
}
|
|
47
|
+
files.forEach((file) => {
|
|
48
|
+
if (this.verbose) {
|
|
49
|
+
console.log(`Parsing file ${file}`);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);
|
|
53
|
+
spec.addData(parsedJsDocumentFile.map((item) => item.spec));
|
|
54
|
+
const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);
|
|
55
|
+
spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error(error);
|
|
58
|
+
node_process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
if (this.verbose) {
|
|
64
|
+
console.log("Validating swagger spec");
|
|
65
|
+
console.log(JSON.stringify(spec, null, 2));
|
|
66
|
+
}
|
|
67
|
+
await validate.validate(JSON.parse(JSON.stringify(spec)));
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(error.toJSON());
|
|
70
|
+
node_process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
const { assetsPath } = this;
|
|
73
|
+
node_fs.mkdir(path.dirname(assetsPath), { recursive: true }, (error) => {
|
|
74
|
+
if (error) {
|
|
75
|
+
errorHandler(error);
|
|
76
|
+
}
|
|
77
|
+
node_fs.writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);
|
|
78
|
+
});
|
|
79
|
+
if (this.verbose) {
|
|
80
|
+
console.log(`Written swagger spec to "${this.assetsPath}" file`);
|
|
81
|
+
}
|
|
82
|
+
console.log("switching back to normal build");
|
|
83
|
+
callback();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module.exports = SwaggerCompilerPlugin;
|