@visulima/jsdoc-open-api 3.0.0-alpha.4 → 3.0.0-alpha.41
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 +371 -0
- package/LICENSE.md +35 -1
- package/README.md +44 -33
- package/bin/index.js +12 -9
- package/dist/cli/commander/index.d.ts +996 -3
- package/dist/cli/commander/index.js +1 -33
- package/dist/cli/index.d.ts +5 -6
- package/dist/cli/index.js +1 -17
- package/dist/index.d.ts +200 -182
- package/dist/index.js +1 -106
- package/dist/packem_shared/DEFAULT_OPTIONS-C7o6qjwP.js +1 -0
- package/dist/packem_shared/SpecBuilder-Vbq42UbW.js +1 -0
- package/dist/packem_shared/SwaggerCompilerPlugin-PUOALp2i.js +1 -0
- package/dist/packem_shared/constants-CdEv9ZcD.js +1 -0
- package/dist/packem_shared/customizer-BXFVpImq.js +1 -0
- package/dist/packem_shared/generateCommand-C_XPsbS6.js +5 -0
- package/dist/packem_shared/generateCommand-ClL9Mnc3.js +1 -0
- package/dist/packem_shared/initCommand-Ca1hGdYS.js +35 -0
- package/dist/packem_shared/initCommand-TixxsVQU.js +1 -0
- package/dist/packem_shared/jsDocumentCommentsToOpenApi-TjPhUj5G.js +1 -0
- package/dist/packem_shared/loadDefinition-7r9qpfuE.js +1 -0
- package/dist/packem_shared/parseFile-RDlR4tEF.js +1 -0
- package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-Bm9R1BnW.js +10 -0
- package/dist/packem_shared/validate-9Rwe2A3r.js +1 -0
- package/dist/packem_shared/yamlLoc-DPq-xUM4.js +1 -0
- package/package.json +38 -45
- 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.d.mts +0 -7
- package/dist/cli/commander/index.js.map +0 -1
- package/dist/cli/commander/index.mjs +0 -30
- package/dist/cli/commander/index.mjs.map +0 -1
- package/dist/cli/index.d.mts +0 -10
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/index.mjs +0 -4
- package/dist/cli/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -248
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -85
- package/dist/index.mjs.map +0 -1
|
@@ -1,33 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var chunkRVCK3H3U_js = require('../../chunk-RVCK3H3U.js');
|
|
4
|
-
require('../../chunk-PTFTJY7I.js');
|
|
5
|
-
var process = require('process');
|
|
6
|
-
|
|
7
|
-
var generateCommand = (program, commandName = "generate", configName = ".openapirc.js") => {
|
|
8
|
-
program.command(commandName).description("Generates OpenAPI (Swagger) documentation from JSDoc's").usage("[options] <path ...>").argument("[path ...]", "Paths to files or directories to parse").option("-c, --config [.openapirc.js]", "@visulima/jsdoc-open-api config file path.").option("-o, --output [swaggerSpec.json]", "Output swagger specification.").option("-v, --verbose", "Verbose output.").option("-d, --very-verbose", "Very verbose output.").action(async (paths, options) => {
|
|
9
|
-
try {
|
|
10
|
-
await chunkRVCK3H3U_js.generate_command_default(configName, paths, options);
|
|
11
|
-
} catch (error) {
|
|
12
|
-
console.error(error);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var generate_command_default2 = generateCommand;
|
|
18
|
-
var initCommand = (program, commandName = "init", description = "Inits a pre-configured @visulima/jsdoc-open-api config file.", configName = ".openapirc.js") => {
|
|
19
|
-
program.command(commandName).description(description).action(() => {
|
|
20
|
-
try {
|
|
21
|
-
chunkRVCK3H3U_js.init_command_default(configName);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.error(error);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var init_command_default2 = initCommand;
|
|
29
|
-
|
|
30
|
-
exports.generateCommand = generate_command_default2;
|
|
31
|
-
exports.initCommand = init_command_default2;
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{default as m}from"../../packem_shared/generateCommand-ClL9Mnc3.js";import{default as t}from"../../packem_shared/initCommand-TixxsVQU.js";export{m as generateCommand,t as initCommand};
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
declare const generateCommand: (configName: string, paths: string[], options: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
config?: string;
|
|
3
|
+
definition?: string;
|
|
4
|
+
output?: string;
|
|
5
|
+
verbose?: boolean;
|
|
6
|
+
veryVerbose?: boolean;
|
|
6
7
|
}) => Promise<void>;
|
|
7
|
-
|
|
8
8
|
declare const initCommand: (configName: string, packageJsonPath?: string) => void;
|
|
9
|
-
|
|
10
9
|
export { generateCommand, initCommand };
|
package/dist/cli/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var chunkRVCK3H3U_js = require('../chunk-RVCK3H3U.js');
|
|
4
|
-
require('../chunk-PTFTJY7I.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "generateCommand", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () { return chunkRVCK3H3U_js.generate_command_default; }
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "initCommand", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return chunkRVCK3H3U_js.init_command_default; }
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{default as m}from"../packem_shared/generateCommand-C_XPsbS6.js";import{default as t}from"../packem_shared/initCommand-Ca1hGdYS.js";export{m as generateCommand,t as initCommand};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,248 +1,266 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Block } from 'comment-parser';
|
|
2
|
+
import 'buffer';
|
|
3
|
+
import 'http';
|
|
4
|
+
import 'https';
|
|
5
|
+
import 'inspector';
|
|
6
|
+
import 'net';
|
|
7
|
+
import 'url';
|
|
8
|
+
import 'vm';
|
|
3
9
|
interface BaseDefinition {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
components?: ComponentsObject;
|
|
11
|
+
externalDocs?: ExternalDocumentationObject;
|
|
12
|
+
info: InfoObject;
|
|
13
|
+
openapi: string;
|
|
14
|
+
paths?: PathsObject;
|
|
15
|
+
security?: SecurityRequirementObject[];
|
|
16
|
+
servers?: ServerObject[];
|
|
17
|
+
tags?: TagObject[];
|
|
12
18
|
}
|
|
13
19
|
interface OpenApiObject extends BaseDefinition {
|
|
14
|
-
|
|
20
|
+
paths?: PathsObject;
|
|
15
21
|
}
|
|
16
22
|
interface InfoObject {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
contact?: ContactObject;
|
|
24
|
+
description?: string;
|
|
25
|
+
license?: LicenseObject;
|
|
26
|
+
termsOfService?: string;
|
|
27
|
+
title: string;
|
|
28
|
+
version: string;
|
|
23
29
|
}
|
|
24
30
|
interface ContactObject {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
email?: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
url?: string;
|
|
28
34
|
}
|
|
29
35
|
interface LicenseObject {
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
name: string;
|
|
37
|
+
url?: string;
|
|
32
38
|
}
|
|
33
39
|
interface ServerObject {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
description?: string;
|
|
41
|
+
url: string;
|
|
42
|
+
variables?: Map<ServerVariable>;
|
|
37
43
|
}
|
|
38
44
|
interface ServerVariable {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
default: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
enum?: string[];
|
|
42
48
|
}
|
|
43
49
|
interface ComponentsObject {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
callbacks?: Map<CallbackObject | ReferenceObject>;
|
|
51
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
52
|
+
headers?: Map<HeaderObject | ReferenceObject>;
|
|
53
|
+
links?: Map<LinkObject | ReferenceObject>;
|
|
54
|
+
parameters?: Map<ParameterObject | ReferenceObject>;
|
|
55
|
+
requestBodies?: Map<ReferenceObject | RequestBodyObject>;
|
|
56
|
+
responses?: Map<ReferenceObject | ResponseObject>;
|
|
57
|
+
schemas?: Map<ReferenceObject | SchemaObject>;
|
|
58
|
+
securitySchemes?: Map<ApiKeySecuritySchemeObject | HttpSecuritySchemeObject | Oauth2SecuritySchemeObject | OpenIdConnectSecuritySchemeObject | ReferenceObject>;
|
|
53
59
|
}
|
|
54
60
|
type PathsObject = Record<string, PathItemObject>;
|
|
55
61
|
interface PathItemObject {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
$ref?: string;
|
|
63
|
+
delete?: OperationObject;
|
|
64
|
+
description?: string;
|
|
65
|
+
get?: OperationObject;
|
|
66
|
+
head?: OperationObject;
|
|
67
|
+
options?: OperationObject;
|
|
68
|
+
parameters?: (ParameterObject | ReferenceObject)[];
|
|
69
|
+
patch?: OperationObject;
|
|
70
|
+
post?: OperationObject;
|
|
71
|
+
put?: OperationObject;
|
|
72
|
+
servers?: ServerObject[];
|
|
73
|
+
summary?: string;
|
|
74
|
+
trace?: OperationObject;
|
|
69
75
|
}
|
|
70
76
|
interface OperationObject {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
callbacks?: Map<CallbackObject | ReferenceObject>;
|
|
78
|
+
deprecated?: boolean;
|
|
79
|
+
description?: string;
|
|
80
|
+
externalDocs?: ExternalDocumentationObject;
|
|
81
|
+
operationId?: string;
|
|
82
|
+
parameters?: (ParameterObject | ReferenceObject)[];
|
|
83
|
+
requestBody?: ReferenceObject | RequestBodyObject;
|
|
84
|
+
responses: ResponsesObject;
|
|
85
|
+
security?: SecurityRequirementObject[];
|
|
86
|
+
servers?: ServerObject[];
|
|
87
|
+
summary?: string;
|
|
88
|
+
tags?: string[];
|
|
83
89
|
}
|
|
84
90
|
interface ExternalDocumentationObject {
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
description?: string;
|
|
92
|
+
url: string;
|
|
87
93
|
}
|
|
88
94
|
interface ParameterObject {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
allowEmptyValue?: boolean;
|
|
96
|
+
allowReserved?: boolean;
|
|
97
|
+
content?: Map<MediaTypeObject>;
|
|
98
|
+
deprecated?: boolean;
|
|
99
|
+
description?: string;
|
|
100
|
+
example?: any;
|
|
101
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
102
|
+
explode?: string;
|
|
103
|
+
in: string;
|
|
104
|
+
name: string;
|
|
105
|
+
required?: boolean;
|
|
106
|
+
schema?: ReferenceObject | SchemaObject;
|
|
107
|
+
style?: string;
|
|
102
108
|
}
|
|
103
109
|
interface RequestBodyObject {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
content: Map<MediaTypeObject>;
|
|
111
|
+
description?: string;
|
|
112
|
+
required?: boolean;
|
|
107
113
|
}
|
|
108
114
|
interface MediaTypeObject {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
encoding?: Map<EncodingObject>;
|
|
116
|
+
example?: any;
|
|
117
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
118
|
+
schema?: ReferenceObject | SchemaObject;
|
|
113
119
|
}
|
|
114
120
|
interface EncodingObject {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
allowReserved?: boolean;
|
|
122
|
+
contentType?: string;
|
|
123
|
+
explode?: boolean;
|
|
124
|
+
headers?: Map<HeaderObject | ReferenceObject>;
|
|
125
|
+
style?: string;
|
|
120
126
|
}
|
|
121
127
|
type ResponsesObject = Record<string, ReferenceObject | ResponseObject>;
|
|
122
128
|
interface ResponseObject {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
content?: Map<MediaTypeObject>;
|
|
130
|
+
description: string;
|
|
131
|
+
headers?: Map<HeaderObject | ReferenceObject>;
|
|
132
|
+
links?: Map<LinkObject | ReferenceObject>;
|
|
127
133
|
}
|
|
128
134
|
type CallbackObject = Record<string, PathItemObject>;
|
|
129
135
|
interface ExampleObject {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
description?: string;
|
|
137
|
+
externalValue?: string;
|
|
138
|
+
summary?: string;
|
|
139
|
+
value?: any;
|
|
134
140
|
}
|
|
135
141
|
interface LinkObject {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
description?: string;
|
|
143
|
+
operationId?: string;
|
|
144
|
+
operationRef?: string;
|
|
145
|
+
parameters?: Map<any>;
|
|
146
|
+
requestBody?: any;
|
|
147
|
+
server?: ServerObject;
|
|
142
148
|
}
|
|
143
149
|
interface HeaderObject {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
allowEmptyValue?: boolean;
|
|
151
|
+
allowReserved?: boolean;
|
|
152
|
+
content?: Map<MediaTypeObject>;
|
|
153
|
+
deprecated?: boolean;
|
|
154
|
+
description?: string;
|
|
155
|
+
example?: any;
|
|
156
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
157
|
+
explode?: string;
|
|
158
|
+
required?: boolean;
|
|
159
|
+
schema?: ReferenceObject | SchemaObject;
|
|
160
|
+
style?: string;
|
|
155
161
|
}
|
|
156
162
|
interface TagObject {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
description?: string;
|
|
164
|
+
externalDocs?: ExternalDocumentationObject;
|
|
165
|
+
name: string;
|
|
160
166
|
}
|
|
161
167
|
interface ReferenceObject {
|
|
162
|
-
|
|
168
|
+
$ref: string;
|
|
163
169
|
}
|
|
164
170
|
type SchemaObject = Record<string, any>;
|
|
165
171
|
interface ApiKeySecuritySchemeObject {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
description?: string;
|
|
173
|
+
in: string;
|
|
174
|
+
name: string;
|
|
175
|
+
type: string;
|
|
170
176
|
}
|
|
171
177
|
interface HttpSecuritySchemeObject {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
bearerFormat?: string;
|
|
179
|
+
description?: string;
|
|
180
|
+
scheme: string;
|
|
181
|
+
type: string;
|
|
176
182
|
}
|
|
177
183
|
interface Oauth2SecuritySchemeObject {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
184
|
+
description?: string;
|
|
185
|
+
flows: OAuthFlowsObject;
|
|
186
|
+
type: string;
|
|
181
187
|
}
|
|
182
188
|
interface OpenIdConnectSecuritySchemeObject {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
description?: string;
|
|
190
|
+
openIdConnectUrl: string;
|
|
191
|
+
type: string;
|
|
186
192
|
}
|
|
187
193
|
interface OAuthFlowsObject {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
authorizationCode?: OAuthFlowObject;
|
|
195
|
+
clientCredentials?: OAuthFlowObject;
|
|
196
|
+
implicit?: OAuthFlowObject;
|
|
197
|
+
password?: OAuthFlowObject;
|
|
192
198
|
}
|
|
193
199
|
interface OAuthFlowObject {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
200
|
+
authorizationUrl?: string;
|
|
201
|
+
refreshUrl: string;
|
|
202
|
+
scopes: Map<string>;
|
|
203
|
+
tokenUrl?: string;
|
|
198
204
|
}
|
|
199
205
|
type SecurityRequirementObject = Record<string, string[]>;
|
|
200
206
|
type Map<T> = Record<string, T>;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
spec: OpenApiObject;
|
|
207
|
+
declare const commentsToOpenApi$1: (fileContents: string, verbose?: boolean, comments?: Block[]) => {
|
|
208
|
+
loc: number;
|
|
209
|
+
spec: OpenApiObject;
|
|
205
210
|
}[];
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
declare const DEFAULT_OPTIONS: {
|
|
212
|
+
cwd: undefined;
|
|
213
|
+
exclude: string[];
|
|
214
|
+
excludeNodeModules: boolean;
|
|
215
|
+
extension: string[];
|
|
216
|
+
include: string[];
|
|
217
|
+
verbose: boolean;
|
|
218
|
+
};
|
|
219
|
+
type CommentsToOpenApi = (fileContent: string, verbose?: boolean, comments?: Block[]) => {
|
|
220
|
+
loc: number;
|
|
221
|
+
spec: OpenApiObject;
|
|
222
|
+
}[];
|
|
223
|
+
declare const parseFile$1: (file: string, commentsToOpenApi: CommentsToOpenApi, verbose?: boolean) => {
|
|
224
|
+
loc: number;
|
|
225
|
+
spec: OpenApiObject;
|
|
226
|
+
}[];
|
|
227
|
+
declare const parseFileMulti: (file: string, translators: CommentsToOpenApi[], verbose?: boolean) => {
|
|
228
|
+
loc: number;
|
|
229
|
+
spec: OpenApiObject;
|
|
213
230
|
}[];
|
|
214
|
-
|
|
215
231
|
declare class SpecBuilder implements OpenApiObject {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
spec: OpenApiObject;
|
|
232
|
+
components?: ComponentsObject;
|
|
233
|
+
externalDocs?: ExternalDocumentationObject;
|
|
234
|
+
info: InfoObject;
|
|
235
|
+
openapi: string;
|
|
236
|
+
paths: PathsObject;
|
|
237
|
+
security?: SecurityRequirementObject[];
|
|
238
|
+
servers?: ServerObject[];
|
|
239
|
+
tags?: TagObject[];
|
|
240
|
+
constructor(baseDefinition: BaseDefinition);
|
|
241
|
+
addData(parsedFile: OpenApiObject[]): void;
|
|
242
|
+
}
|
|
243
|
+
declare const commentsToOpenApi: (fileContents: string, verbose?: boolean, comments?: Block[]) => {
|
|
244
|
+
loc: number;
|
|
245
|
+
spec: OpenApiObject;
|
|
231
246
|
}[];
|
|
232
|
-
|
|
247
|
+
declare const parseFile: (file: string) => BaseDefinition;
|
|
233
248
|
declare const yamlLoc: (string: string) => number;
|
|
234
|
-
|
|
249
|
+
declare const validate: (spec: Record<string, unknown>) => Promise<void>;
|
|
250
|
+
type WebpackCompiler = undefined;
|
|
235
251
|
declare class SwaggerCompilerPlugin {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
252
|
+
private readonly assetsPath;
|
|
253
|
+
private readonly ignore;
|
|
254
|
+
private readonly silent;
|
|
255
|
+
private readonly sources;
|
|
256
|
+
private readonly swaggerDefinition;
|
|
257
|
+
private readonly verbose;
|
|
258
|
+
constructor(assetsPath: string, sources: string[], swaggerDefinition: BaseDefinition, options: {
|
|
259
|
+
ignore?: (RegExp | string)[];
|
|
260
|
+
silent?: boolean;
|
|
261
|
+
verbose?: boolean;
|
|
262
|
+
});
|
|
263
|
+
apply(compiler: WebpackCompiler): void;
|
|
264
|
+
private log;
|
|
265
|
+
}
|
|
266
|
+
export { type BaseDefinition, type CommentsToOpenApi, DEFAULT_OPTIONS, type OpenApiObject, SpecBuilder, SwaggerCompilerPlugin, commentsToOpenApi$1 as jsDocumentCommentsToOpenApi, parseFile as loadDefinition, parseFile$1 as parseFile, parseFileMulti, commentsToOpenApi as swaggerJsDocumentCommentsToOpenApi, validate, yamlLoc };
|
package/dist/index.js
CHANGED
|
@@ -1,106 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var chunkPTFTJY7I_js = require('./chunk-PTFTJY7I.js');
|
|
4
|
-
var fs = require('fs');
|
|
5
|
-
var path = require('path');
|
|
6
|
-
var process = require('process');
|
|
7
|
-
|
|
8
|
-
var errorHandler = (error) => {
|
|
9
|
-
if (error) {
|
|
10
|
-
console.error(error);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var SwaggerCompilerPlugin = class {
|
|
15
|
-
assetsPath;
|
|
16
|
-
ignore;
|
|
17
|
-
sources;
|
|
18
|
-
swaggerDefinition;
|
|
19
|
-
verbose;
|
|
20
|
-
constructor(assetsPath, sources, swaggerDefinition, options) {
|
|
21
|
-
this.assetsPath = assetsPath;
|
|
22
|
-
this.swaggerDefinition = swaggerDefinition;
|
|
23
|
-
this.sources = sources;
|
|
24
|
-
this.verbose = options.verbose ?? false;
|
|
25
|
-
this.ignore = options.ignore ?? [];
|
|
26
|
-
}
|
|
27
|
-
apply(compiler) {
|
|
28
|
-
const skip = /* @__PURE__ */ new Set([...chunkPTFTJY7I_js.DEFAULT_EXCLUDE, ...this.ignore]);
|
|
29
|
-
compiler.hooks.make.tapAsync("SwaggerCompilerPlugin", async (_, callback) => {
|
|
30
|
-
console.log("Build paused, switching to swagger build");
|
|
31
|
-
const spec = new chunkPTFTJY7I_js.spec_builder_default(this.swaggerDefinition);
|
|
32
|
-
for await (const dir of this.sources) {
|
|
33
|
-
const files = await chunkPTFTJY7I_js.collect(dir, {
|
|
34
|
-
extensions: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".yaml", ".yml"],
|
|
35
|
-
includeDirs: false,
|
|
36
|
-
skip: [...skip]
|
|
37
|
-
});
|
|
38
|
-
if (this.verbose) {
|
|
39
|
-
console.log(`Found ${String(files.length)} files in ${dir}`);
|
|
40
|
-
console.log(files);
|
|
41
|
-
}
|
|
42
|
-
files.forEach((file) => {
|
|
43
|
-
if (this.verbose) {
|
|
44
|
-
console.log(`Parsing file ${file}`);
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const parsedJsDocumentFile = chunkPTFTJY7I_js.parse_file_default(file, chunkPTFTJY7I_js.comments_to_open_api_default, this.verbose);
|
|
48
|
-
spec.addData(parsedJsDocumentFile.map((item) => item.spec));
|
|
49
|
-
const parsedSwaggerJsDocumentFile = chunkPTFTJY7I_js.parse_file_default(file, chunkPTFTJY7I_js.comments_to_open_api_default2, this.verbose);
|
|
50
|
-
spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error(error);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
if (this.verbose) {
|
|
59
|
-
console.log("Validating swagger spec");
|
|
60
|
-
console.log(JSON.stringify(spec, null, 2));
|
|
61
|
-
}
|
|
62
|
-
await chunkPTFTJY7I_js.validate_default(JSON.parse(JSON.stringify(spec)));
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error(error.toJSON());
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
const { assetsPath } = this;
|
|
68
|
-
fs.mkdir(path.dirname(assetsPath), { recursive: true }, (error) => {
|
|
69
|
-
if (error) {
|
|
70
|
-
errorHandler(error);
|
|
71
|
-
}
|
|
72
|
-
fs.writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);
|
|
73
|
-
});
|
|
74
|
-
if (this.verbose) {
|
|
75
|
-
console.log(`Written swagger spec to "${this.assetsPath}" file`);
|
|
76
|
-
}
|
|
77
|
-
console.log("switching back to normal build");
|
|
78
|
-
callback();
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var swagger_compiler_plugin_default = SwaggerCompilerPlugin;
|
|
83
|
-
|
|
84
|
-
Object.defineProperty(exports, "SpecBuilder", {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: function () { return chunkPTFTJY7I_js.spec_builder_default; }
|
|
87
|
-
});
|
|
88
|
-
Object.defineProperty(exports, "jsDocumentCommentsToOpenApi", {
|
|
89
|
-
enumerable: true,
|
|
90
|
-
get: function () { return chunkPTFTJY7I_js.comments_to_open_api_default; }
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(exports, "parseFile", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () { return chunkPTFTJY7I_js.parse_file_default; }
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(exports, "swaggerJsDocumentCommentsToOpenApi", {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
get: function () { return chunkPTFTJY7I_js.comments_to_open_api_default2; }
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(exports, "yamlLoc", {
|
|
101
|
-
enumerable: true,
|
|
102
|
-
get: function () { return chunkPTFTJY7I_js.yaml_loc_default; }
|
|
103
|
-
});
|
|
104
|
-
exports.SwaggerCompilerPlugin = swagger_compiler_plugin_default;
|
|
105
|
-
//# sourceMappingURL=index.js.map
|
|
106
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{default as a}from"./packem_shared/jsDocumentCommentsToOpenApi-TjPhUj5G.js";import{default as r}from"./packem_shared/DEFAULT_OPTIONS-C7o6qjwP.js";import{default as l,parseFileMulti as m}from"./packem_shared/parseFile-RDlR4tEF.js";import{default as s}from"./packem_shared/SpecBuilder-Vbq42UbW.js";import{default as d}from"./packem_shared/swaggerJsDocumentCommentsToOpenApi-Bm9R1BnW.js";import{default as n}from"./packem_shared/loadDefinition-7r9qpfuE.js";import{default as g}from"./packem_shared/yamlLoc-DPq-xUM4.js";import{default as D}from"./packem_shared/validate-9Rwe2A3r.js";import{default as T}from"./packem_shared/SwaggerCompilerPlugin-PUOALp2i.js";export{r as DEFAULT_OPTIONS,s as SpecBuilder,T as SwaggerCompilerPlugin,a as jsDocumentCommentsToOpenApi,n as loadDefinition,l as parseFile,m as parseFileMulti,d as swaggerJsDocumentCommentsToOpenApi,D as validate,g as yamlLoc};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s={cwd:void 0,exclude:["coverage/**","packages/*/test{,s}/**","**/*.d.ts","test{,s}/**","test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/__tests__/**","**/{ava,babel,nyc}.config.{js,cjs,mjs}","**/jest.config.{js,cjs,mjs,ts}","**/{karma,rollup,webpack}.config.js","**/.{eslint,mocha}rc.{js,cjs}","**/.{travis,yarnrc}.yml","**/{docker-compose}.yml"],excludeNodeModules:!0,extension:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],include:["**"],verbose:!0};export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c=new Set(["__proto__","constructor","prototype"]),h=(o,s)=>{Object.keys(s).forEach(t=>{c.has(t)||(o[t]===void 0?o[t]={...s[t]}:Object.keys(s[t]).forEach(e=>{c.has(e)||(o[t][e]={...o[t][e],...s[t][e]})}))})},i=new Set(["__proto__","constructor","prototype"]);class u{components;externalDocs;info;openapi;paths;security;servers;tags;constructor(s){this.openapi=s.openapi,this.info=s.info,this.paths=s.paths??{},s.servers&&(this.servers=s.servers),s.components&&(this.components=s.components),s.security&&(this.security=s.security),s.tags&&(this.tags=s.tags),s.externalDocs&&(this.externalDocs=s.externalDocs)}addData(s){s.forEach(t=>{const{components:e,paths:n,...a}=t;h(this,{components:e??{},paths:n??{}}),Object.entries(a).forEach(([r,p])=>{i.has(r)||(this[r]=p)})})}}export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdir as c,writeFile as m}from"node:fs/promises";import{dirname as f}from"node:path";import{collect as p}from"@visulima/fs";import{D as u}from"./constants-CdEv9ZcD.js";import w from"./jsDocumentCommentsToOpenApi-TjPhUj5G.js";import{parseFileMulti as d}from"./parseFile-RDlR4tEF.js";import b from"./SpecBuilder-Vbq42UbW.js";import v from"./swaggerJsDocumentCommentsToOpenApi-Bm9R1BnW.js";import y from"./validate-9Rwe2A3r.js";const D=[w,v],E=r=>r instanceof Error?r:new Error(String(r));class J{assetsPath;ignore;silent;sources;swaggerDefinition;verbose;constructor(t,n,o,s){this.assetsPath=t,this.swaggerDefinition=o,this.sources=n,this.verbose=s.verbose??!1,this.silent=s.silent??!1,this.ignore=s.ignore??[]}apply(t){const n=new Set([...u,...this.ignore]);t.hooks.make.tapAsync("SwaggerCompilerPlugin",async(o,s)=>{this.log("Build paused, switching to swagger build");const e=new b(this.swaggerDefinition);try{for(const i of this.sources){const l=await p(i,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:!1,skip:[...n]});this.verbose&&(this.log(`Found ${String(l.length)} files in ${i}`),this.log(JSON.stringify(l))),l.forEach(g=>{this.verbose&&this.log(`Parsing file ${g}`),e.addData(d(g,D,this.verbose).map(h=>h.spec))})}this.verbose&&(this.log("Validating swagger spec"),this.log(JSON.stringify(e,void 0,2))),await y(structuredClone(e));const{assetsPath:a}=this;await c(f(a),{recursive:!0}),await m(a,JSON.stringify(e,void 0,2)),this.verbose&&this.log(`Written swagger spec to "${this.assetsPath}" file`)}catch(a){const i=E(a);Array.isArray(o.errors)&&o.errors.push(i),s(i);return}this.log("switching back to normal build"),s()})}log(t){this.silent||console.log(t)}}export{J as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=["coverage/**",".github/**","**/*.d.ts","**/test{,s}/**","**/test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/__tests__/**","**/{ava,babel,nyc}.config.{js,cjs,mjs}","**/jest.config.{js,cjs,mjs,ts}","**/{karma,rollup,webpack}.config.js","**/.{eslint,mocha}rc.{js,cjs}","**/.{travis,yarnrc}.yml","**/{docker-compose,docker}.yml","**/.yamllint.{yaml,yml}","**/node_modules/**","**/{pnpm-workspace,pnpm-lock}.yaml","**/{package,package-lock}.json","**/yarn.lock","**/package.json5","**/.next/**"];export{s as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a=(r,t)=>{if(Array.isArray(r))return[...r,...t]};export{a as u};
|