@visulima/jsdoc-open-api 2.0.13 → 2.0.15

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/index.d.mts CHANGED
@@ -10,11 +10,9 @@ interface BaseDefinition {
10
10
  servers?: ServerObject[];
11
11
  tags?: TagObject[];
12
12
  }
13
-
14
13
  interface OpenApiObject extends BaseDefinition {
15
14
  paths?: PathsObject;
16
15
  }
17
-
18
16
  interface InfoObject {
19
17
  contact?: ContactObject;
20
18
  description?: string;
@@ -23,30 +21,25 @@ interface InfoObject {
23
21
  title: string;
24
22
  version: string;
25
23
  }
26
-
27
24
  interface ContactObject {
28
25
  email?: string;
29
26
  name?: string;
30
27
  url?: string;
31
28
  }
32
-
33
29
  interface LicenseObject {
34
30
  name: string;
35
31
  url?: string;
36
32
  }
37
-
38
33
  interface ServerObject {
39
34
  description?: string;
40
35
  url: string;
41
36
  variables?: Map<ServerVariable>;
42
37
  }
43
-
44
38
  interface ServerVariable {
45
39
  default: string;
46
40
  description?: string;
47
41
  enum?: string[];
48
42
  }
49
-
50
43
  interface ComponentsObject {
51
44
  callbacks?: Map<CallbackObject | ReferenceObject>;
52
45
  examples?: Map<ExampleObject | ReferenceObject>;
@@ -56,13 +49,9 @@ interface ComponentsObject {
56
49
  requestBodies?: Map<ReferenceObject | RequestBodyObject>;
57
50
  responses?: Map<ReferenceObject | ResponseObject>;
58
51
  schemas?: Map<ReferenceObject | SchemaObject>;
59
- securitySchemes?: Map<
60
- ApiKeySecuritySchemeObject | HttpSecuritySchemeObject | Oauth2SecuritySchemeObject | OpenIdConnectSecuritySchemeObject | ReferenceObject
61
- >;
52
+ securitySchemes?: Map<ApiKeySecuritySchemeObject | HttpSecuritySchemeObject | Oauth2SecuritySchemeObject | OpenIdConnectSecuritySchemeObject | ReferenceObject>;
62
53
  }
63
-
64
54
  type PathsObject = Record<string, PathItemObject>;
65
-
66
55
  interface PathItemObject {
67
56
  $ref?: string;
68
57
  delete?: OperationObject;
@@ -78,7 +67,6 @@ interface PathItemObject {
78
67
  summary?: string;
79
68
  trace?: OperationObject;
80
69
  }
81
-
82
70
  interface OperationObject {
83
71
  callbacks?: Map<CallbackObject | ReferenceObject>;
84
72
  deprecated?: boolean;
@@ -93,16 +81,13 @@ interface OperationObject {
93
81
  summary?: string;
94
82
  tags?: string[];
95
83
  }
96
-
97
84
  interface ExternalDocumentationObject {
98
85
  description?: string;
99
86
  url: string;
100
87
  }
101
-
102
88
  interface ParameterObject {
103
89
  allowEmptyValue?: boolean;
104
90
  allowReserved?: boolean;
105
- //
106
91
  content?: Map<MediaTypeObject>;
107
92
  deprecated?: boolean;
108
93
  description?: string;
@@ -113,25 +98,19 @@ interface ParameterObject {
113
98
  name: string;
114
99
  required?: boolean;
115
100
  schema?: ReferenceObject | SchemaObject;
116
- //
117
101
  style?: string;
118
- // ignoring stylings: matrix, label, form, simple, spaceDelimited,
119
- // pipeDelimited and deepObject
120
102
  }
121
-
122
103
  interface RequestBodyObject {
123
104
  content: Map<MediaTypeObject>;
124
105
  description?: string;
125
106
  required?: boolean;
126
107
  }
127
-
128
108
  interface MediaTypeObject {
129
109
  encoding?: Map<EncodingObject>;
130
110
  example?: any;
131
111
  examples?: Map<ExampleObject | ReferenceObject>;
132
112
  schema?: ReferenceObject | SchemaObject;
133
113
  }
134
-
135
114
  interface EncodingObject {
136
115
  allowReserved?: boolean;
137
116
  contentType?: string;
@@ -139,25 +118,20 @@ interface EncodingObject {
139
118
  headers?: Map<HeaderObject | ReferenceObject>;
140
119
  style?: string;
141
120
  }
142
-
143
121
  type ResponsesObject = Record<string, ReferenceObject | ResponseObject>;
144
-
145
122
  interface ResponseObject {
146
123
  content?: Map<MediaTypeObject>;
147
124
  description: string;
148
125
  headers?: Map<HeaderObject | ReferenceObject>;
149
126
  links?: Map<LinkObject | ReferenceObject>;
150
127
  }
151
-
152
128
  type CallbackObject = Record<string, PathItemObject>;
153
-
154
129
  interface ExampleObject {
155
130
  description?: string;
156
131
  externalValue?: string;
157
132
  summary?: string;
158
133
  value?: any;
159
134
  }
160
-
161
135
  interface LinkObject {
162
136
  description?: string;
163
137
  operationId?: string;
@@ -166,11 +140,9 @@ interface LinkObject {
166
140
  requestBody?: any;
167
141
  server?: ServerObject;
168
142
  }
169
-
170
143
  interface HeaderObject {
171
144
  allowEmptyValue?: boolean;
172
145
  allowReserved?: boolean;
173
- //
174
146
  content?: Map<MediaTypeObject>;
175
147
  deprecated?: boolean;
176
148
  description?: string;
@@ -179,67 +151,52 @@ interface HeaderObject {
179
151
  explode?: string;
180
152
  required?: boolean;
181
153
  schema?: ReferenceObject | SchemaObject;
182
- //
183
154
  style?: string;
184
- // ignoring stylings: matrix, label, form, simple, spaceDelimited,
185
- // pipeDelimited and deepObject
186
155
  }
187
-
188
156
  interface TagObject {
189
157
  description?: string;
190
158
  externalDocs?: ExternalDocumentationObject;
191
159
  name: string;
192
160
  }
193
-
194
161
  interface ReferenceObject {
195
162
  $ref: string;
196
163
  }
197
-
198
- // TODO: this could be expanded on.
199
164
  type SchemaObject = Record<string, any>;
200
-
201
165
  interface ApiKeySecuritySchemeObject {
202
166
  description?: string;
203
167
  in: string;
204
168
  name: string;
205
169
  type: string;
206
170
  }
207
-
208
171
  interface HttpSecuritySchemeObject {
209
172
  bearerFormat?: string;
210
173
  description?: string;
211
174
  scheme: string;
212
175
  type: string;
213
176
  }
214
-
215
177
  interface Oauth2SecuritySchemeObject {
216
178
  description?: string;
217
179
  flows: OAuthFlowsObject;
218
180
  type: string;
219
181
  }
220
-
221
182
  interface OpenIdConnectSecuritySchemeObject {
222
183
  description?: string;
223
184
  openIdConnectUrl: string;
224
185
  type: string;
225
186
  }
226
-
227
187
  interface OAuthFlowsObject {
228
188
  authorizationCode?: OAuthFlowObject;
229
189
  clientCredentials?: OAuthFlowObject;
230
190
  implicit?: OAuthFlowObject;
231
191
  password?: OAuthFlowObject;
232
192
  }
233
-
234
193
  interface OAuthFlowObject {
235
- authorizationUrl?: string; // required for some?
194
+ authorizationUrl?: string;
236
195
  refreshUrl: string;
237
196
  scopes: Map<string>;
238
- tokenUrl?: string; // required for some?
197
+ tokenUrl?: string;
239
198
  }
240
-
241
199
  type SecurityRequirementObject = Record<string, string[]>;
242
-
243
200
  type Map<T> = Record<string, T>;
244
201
 
245
202
  declare const commentsToOpenApi$1: (fileContents: string, verbose?: boolean) => {
package/dist/index.d.ts CHANGED
@@ -10,11 +10,9 @@ interface BaseDefinition {
10
10
  servers?: ServerObject[];
11
11
  tags?: TagObject[];
12
12
  }
13
-
14
13
  interface OpenApiObject extends BaseDefinition {
15
14
  paths?: PathsObject;
16
15
  }
17
-
18
16
  interface InfoObject {
19
17
  contact?: ContactObject;
20
18
  description?: string;
@@ -23,30 +21,25 @@ interface InfoObject {
23
21
  title: string;
24
22
  version: string;
25
23
  }
26
-
27
24
  interface ContactObject {
28
25
  email?: string;
29
26
  name?: string;
30
27
  url?: string;
31
28
  }
32
-
33
29
  interface LicenseObject {
34
30
  name: string;
35
31
  url?: string;
36
32
  }
37
-
38
33
  interface ServerObject {
39
34
  description?: string;
40
35
  url: string;
41
36
  variables?: Map<ServerVariable>;
42
37
  }
43
-
44
38
  interface ServerVariable {
45
39
  default: string;
46
40
  description?: string;
47
41
  enum?: string[];
48
42
  }
49
-
50
43
  interface ComponentsObject {
51
44
  callbacks?: Map<CallbackObject | ReferenceObject>;
52
45
  examples?: Map<ExampleObject | ReferenceObject>;
@@ -56,13 +49,9 @@ interface ComponentsObject {
56
49
  requestBodies?: Map<ReferenceObject | RequestBodyObject>;
57
50
  responses?: Map<ReferenceObject | ResponseObject>;
58
51
  schemas?: Map<ReferenceObject | SchemaObject>;
59
- securitySchemes?: Map<
60
- ApiKeySecuritySchemeObject | HttpSecuritySchemeObject | Oauth2SecuritySchemeObject | OpenIdConnectSecuritySchemeObject | ReferenceObject
61
- >;
52
+ securitySchemes?: Map<ApiKeySecuritySchemeObject | HttpSecuritySchemeObject | Oauth2SecuritySchemeObject | OpenIdConnectSecuritySchemeObject | ReferenceObject>;
62
53
  }
63
-
64
54
  type PathsObject = Record<string, PathItemObject>;
65
-
66
55
  interface PathItemObject {
67
56
  $ref?: string;
68
57
  delete?: OperationObject;
@@ -78,7 +67,6 @@ interface PathItemObject {
78
67
  summary?: string;
79
68
  trace?: OperationObject;
80
69
  }
81
-
82
70
  interface OperationObject {
83
71
  callbacks?: Map<CallbackObject | ReferenceObject>;
84
72
  deprecated?: boolean;
@@ -93,16 +81,13 @@ interface OperationObject {
93
81
  summary?: string;
94
82
  tags?: string[];
95
83
  }
96
-
97
84
  interface ExternalDocumentationObject {
98
85
  description?: string;
99
86
  url: string;
100
87
  }
101
-
102
88
  interface ParameterObject {
103
89
  allowEmptyValue?: boolean;
104
90
  allowReserved?: boolean;
105
- //
106
91
  content?: Map<MediaTypeObject>;
107
92
  deprecated?: boolean;
108
93
  description?: string;
@@ -113,25 +98,19 @@ interface ParameterObject {
113
98
  name: string;
114
99
  required?: boolean;
115
100
  schema?: ReferenceObject | SchemaObject;
116
- //
117
101
  style?: string;
118
- // ignoring stylings: matrix, label, form, simple, spaceDelimited,
119
- // pipeDelimited and deepObject
120
102
  }
121
-
122
103
  interface RequestBodyObject {
123
104
  content: Map<MediaTypeObject>;
124
105
  description?: string;
125
106
  required?: boolean;
126
107
  }
127
-
128
108
  interface MediaTypeObject {
129
109
  encoding?: Map<EncodingObject>;
130
110
  example?: any;
131
111
  examples?: Map<ExampleObject | ReferenceObject>;
132
112
  schema?: ReferenceObject | SchemaObject;
133
113
  }
134
-
135
114
  interface EncodingObject {
136
115
  allowReserved?: boolean;
137
116
  contentType?: string;
@@ -139,25 +118,20 @@ interface EncodingObject {
139
118
  headers?: Map<HeaderObject | ReferenceObject>;
140
119
  style?: string;
141
120
  }
142
-
143
121
  type ResponsesObject = Record<string, ReferenceObject | ResponseObject>;
144
-
145
122
  interface ResponseObject {
146
123
  content?: Map<MediaTypeObject>;
147
124
  description: string;
148
125
  headers?: Map<HeaderObject | ReferenceObject>;
149
126
  links?: Map<LinkObject | ReferenceObject>;
150
127
  }
151
-
152
128
  type CallbackObject = Record<string, PathItemObject>;
153
-
154
129
  interface ExampleObject {
155
130
  description?: string;
156
131
  externalValue?: string;
157
132
  summary?: string;
158
133
  value?: any;
159
134
  }
160
-
161
135
  interface LinkObject {
162
136
  description?: string;
163
137
  operationId?: string;
@@ -166,11 +140,9 @@ interface LinkObject {
166
140
  requestBody?: any;
167
141
  server?: ServerObject;
168
142
  }
169
-
170
143
  interface HeaderObject {
171
144
  allowEmptyValue?: boolean;
172
145
  allowReserved?: boolean;
173
- //
174
146
  content?: Map<MediaTypeObject>;
175
147
  deprecated?: boolean;
176
148
  description?: string;
@@ -179,67 +151,52 @@ interface HeaderObject {
179
151
  explode?: string;
180
152
  required?: boolean;
181
153
  schema?: ReferenceObject | SchemaObject;
182
- //
183
154
  style?: string;
184
- // ignoring stylings: matrix, label, form, simple, spaceDelimited,
185
- // pipeDelimited and deepObject
186
155
  }
187
-
188
156
  interface TagObject {
189
157
  description?: string;
190
158
  externalDocs?: ExternalDocumentationObject;
191
159
  name: string;
192
160
  }
193
-
194
161
  interface ReferenceObject {
195
162
  $ref: string;
196
163
  }
197
-
198
- // TODO: this could be expanded on.
199
164
  type SchemaObject = Record<string, any>;
200
-
201
165
  interface ApiKeySecuritySchemeObject {
202
166
  description?: string;
203
167
  in: string;
204
168
  name: string;
205
169
  type: string;
206
170
  }
207
-
208
171
  interface HttpSecuritySchemeObject {
209
172
  bearerFormat?: string;
210
173
  description?: string;
211
174
  scheme: string;
212
175
  type: string;
213
176
  }
214
-
215
177
  interface Oauth2SecuritySchemeObject {
216
178
  description?: string;
217
179
  flows: OAuthFlowsObject;
218
180
  type: string;
219
181
  }
220
-
221
182
  interface OpenIdConnectSecuritySchemeObject {
222
183
  description?: string;
223
184
  openIdConnectUrl: string;
224
185
  type: string;
225
186
  }
226
-
227
187
  interface OAuthFlowsObject {
228
188
  authorizationCode?: OAuthFlowObject;
229
189
  clientCredentials?: OAuthFlowObject;
230
190
  implicit?: OAuthFlowObject;
231
191
  password?: OAuthFlowObject;
232
192
  }
233
-
234
193
  interface OAuthFlowObject {
235
- authorizationUrl?: string; // required for some?
194
+ authorizationUrl?: string;
236
195
  refreshUrl: string;
237
196
  scopes: Map<string>;
238
- tokenUrl?: string; // required for some?
197
+ tokenUrl?: string;
239
198
  }
240
-
241
199
  type SecurityRequirementObject = Record<string, string[]>;
242
-
243
200
  type Map<T> = Record<string, T>;
244
201
 
245
202
  declare const commentsToOpenApi$1: (fileContents: string, verbose?: boolean) => {
package/dist/index.js CHANGED
@@ -1,32 +1,32 @@
1
1
  'use strict';
2
2
 
3
- var chunkT6JDVCNR_js = require('./chunk-T6JDVCNR.js');
3
+ var chunkRZ5CXKJD_js = require('./chunk-RZ5CXKJD.js');
4
4
  var fs = require('fs');
5
5
  var path = require('path');
6
6
  var process = require('process');
7
7
  var readdir = require('@visulima/readdir');
8
8
 
9
- var B=["coverage/**",".github/**","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,docker}.yml","**/.yamllint.{yaml,yml}","**/node_modules/**","**/pnpm-lock.yaml","**/pnpm-workspace.yaml","**/{package,package-lock}.json","**/yarn.lock","**/package.json5","**/.next/**"],b=t=>{t&&(console.error(t),process.exit(1));},d=class{constructor(r,u,i,e){this.assetsPath=r,this.swaggerDefinition=i,this.sources=u,this.verbose=e.verbose??!1,this.ignore=e.ignore??[];}apply(r){r.hooks.make.tapAsync("SwaggerCompilerPlugin",async(u,i)=>{console.log("Build paused, switching to swagger build");let e=new chunkT6JDVCNR_js.d(this.swaggerDefinition);for await(let s of this.sources){let a=await readdir.collect(s,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:!1,minimatchOptions:{match:{debug:this.verbose,matchBase:!0},skip:{debug:this.verbose,matchBase:!0}},skip:[...this.ignore,...B]});this.verbose&&(console.log(`Found ${a.length} files in ${s}`),console.log(a)),a.forEach(n=>{this.verbose&&console.log(`Parsing file ${n}`);try{let l=chunkT6JDVCNR_js.c(n,chunkT6JDVCNR_js.a,this.verbose);e.addData(l.map(c=>c.spec));let j=chunkT6JDVCNR_js.c(n,chunkT6JDVCNR_js.e,this.verbose);e.addData(j.map(c=>c.spec));}catch(l){console.error(l),process.exit(1);}});}try{this.verbose&&(console.log("Validating swagger spec"),console.log(JSON.stringify(e,null,2))),await chunkT6JDVCNR_js.f(JSON.parse(JSON.stringify(e)));}catch(s){console.error(s.toJSON()),process.exit(1);}let{assetsPath:y}=this;fs.mkdir(path.dirname(y),{recursive:!0},s=>{s&&b(s),fs.writeFile(y,JSON.stringify(e,null,2),b);}),this.verbose&&console.log(`Written swagger spec to "${this.assetsPath}" file`),console.log("switching back to normal build"),i();});}},J=d;
9
+ var B=["coverage/**",".github/**","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,docker}.yml","**/.yamllint.{yaml,yml}","**/node_modules/**","**/pnpm-lock.yaml","**/pnpm-workspace.yaml","**/{package,package-lock}.json","**/yarn.lock","**/package.json5","**/.next/**"],b=t=>{t&&(console.error(t),process.exit(1));},d=class{assetsPath;ignore;sources;swaggerDefinition;verbose;constructor(r,u,i,e){this.assetsPath=r,this.swaggerDefinition=i,this.sources=u,this.verbose=e.verbose??!1,this.ignore=e.ignore??[];}apply(r){r.hooks.make.tapAsync("SwaggerCompilerPlugin",async(u,i)=>{console.log("Build paused, switching to swagger build");let e=new chunkRZ5CXKJD_js.d(this.swaggerDefinition);for await(let s of this.sources){let a=await readdir.collect(s,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:!1,minimatchOptions:{match:{debug:this.verbose,matchBase:!0},skip:{debug:this.verbose,matchBase:!0}},skip:[...this.ignore,...B]});this.verbose&&(console.log(`Found ${a.length} files in ${s}`),console.log(a)),a.forEach(n=>{this.verbose&&console.log(`Parsing file ${n}`);try{let l=chunkRZ5CXKJD_js.c(n,chunkRZ5CXKJD_js.a,this.verbose);e.addData(l.map(c=>c.spec));let j=chunkRZ5CXKJD_js.c(n,chunkRZ5CXKJD_js.e,this.verbose);e.addData(j.map(c=>c.spec));}catch(l){console.error(l),process.exit(1);}});}try{this.verbose&&(console.log("Validating swagger spec"),console.log(JSON.stringify(e,null,2))),await chunkRZ5CXKJD_js.f(JSON.parse(JSON.stringify(e)));}catch(s){console.error(s.toJSON()),process.exit(1);}let{assetsPath:y}=this;fs.mkdir(path.dirname(y),{recursive:!0},s=>{s&&b(s),fs.writeFile(y,JSON.stringify(e,null,2),b);}),this.verbose&&console.log(`Written swagger spec to "${this.assetsPath}" file`),console.log("switching back to normal build"),i();});}},J=d;
10
10
 
11
11
  Object.defineProperty(exports, 'SpecBuilder', {
12
12
  enumerable: true,
13
- get: function () { return chunkT6JDVCNR_js.d; }
13
+ get: function () { return chunkRZ5CXKJD_js.d; }
14
14
  });
15
15
  Object.defineProperty(exports, 'jsDocumentCommentsToOpenApi', {
16
16
  enumerable: true,
17
- get: function () { return chunkT6JDVCNR_js.a; }
17
+ get: function () { return chunkRZ5CXKJD_js.a; }
18
18
  });
19
19
  Object.defineProperty(exports, 'parseFile', {
20
20
  enumerable: true,
21
- get: function () { return chunkT6JDVCNR_js.c; }
21
+ get: function () { return chunkRZ5CXKJD_js.c; }
22
22
  });
23
23
  Object.defineProperty(exports, 'swaggerJsDocumentCommentsToOpenApi', {
24
24
  enumerable: true,
25
- get: function () { return chunkT6JDVCNR_js.e; }
25
+ get: function () { return chunkRZ5CXKJD_js.e; }
26
26
  });
27
27
  Object.defineProperty(exports, 'yamlLoc', {
28
28
  enumerable: true,
29
- get: function () { return chunkT6JDVCNR_js.b; }
29
+ get: function () { return chunkRZ5CXKJD_js.b; }
30
30
  });
31
31
  exports.SwaggerCompilerPlugin = J;
32
32
  //# sourceMappingURL=out.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["mkdir","writeFile","dirname","exit","collect","exclude","errorHandler","error","SwaggerCompilerPlugin","assetsPath","sources","swaggerDefinition","options","compiler","_","callback","spec","spec_builder_default","dir","files","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","swagger_compiler_plugin_default"],"mappings":"2EAAA,OAAS,SAAAA,EAAO,aAAAC,MAAiB,KACjC,OAAS,WAAAC,MAAe,OACxB,OAAS,QAAAC,MAAY,UAErB,OAAS,WAAAC,MAAe,oBAUxB,IAAMC,EAAU,CACZ,cACA,aACA,yBACA,YACA,cACA,6CACA,iDACA,kBACA,yCACA,iCACA,sCACA,gCACA,0BACA,iCACA,0BACA,qBACA,oBACA,yBACA,iCACA,eACA,mBACA,aACJ,EAEMC,EAAgBC,GAAe,CAC7BA,IAEA,QAAQ,MAAMA,CAAK,EAEnBJ,EAAK,CAAC,EAEd,EAEMK,EAAN,KAA4B,CAWjB,YACHC,EACAC,EACAC,EACAC,EAIF,CACE,KAAK,WAAaH,EAClB,KAAK,kBAAoBE,EACzB,KAAK,QAAUD,EACf,KAAK,QAAUE,EAAQ,SAAW,GAClC,KAAK,OAASA,EAAQ,QAAU,CAAC,CACrC,CAEO,MAAMC,EAA0B,CA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CAEA,GAAM,CAAE,WAAAM,CAAW,EAAI,KAGvBT,EAAME,EAAQO,CAAU,EAAG,CAAE,UAAW,EAAK,EAAIF,GAAU,CACnDA,GACAD,EAAaC,CAAK,EAItBN,EAAUQ,EAAY,KAAK,UAAUO,EAAM,KAAM,CAAC,EAAGV,CAAY,CACrE,CAAC,EAEG,KAAK,SAEL,QAAQ,IAAI,4BAA4B,KAAK,UAAU,QAAQ,EAInE,QAAQ,IAAI,gCAAgC,EAE5CS,EAAS,CACb,CAAC,CACL,CACJ,EAEOY,EAAQnB","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\n\nimport { collect } from \"@visulima/readdir\";\nimport type { Compiler } from \"webpack\";\n\nimport type { BaseDefinition } from \"../exported.d\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst exclude = [\n \"coverage/**\",\n \".github/**\",\n \"packages/*/test{,s}/**\",\n \"**/*.d.ts\",\n \"test{,s}/**\",\n \"test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/__tests__/**\",\n \"**/{ava,babel,nyc}.config.{js,cjs,mjs}\",\n \"**/jest.config.{js,cjs,mjs,ts}\",\n \"**/{karma,rollup,webpack}.config.js\",\n \"**/.{eslint,mocha}rc.{js,cjs}\",\n \"**/.{travis,yarnrc}.yml\",\n \"**/{docker-compose,docker}.yml\",\n \"**/.yamllint.{yaml,yml}\",\n \"**/node_modules/**\",\n \"**/pnpm-lock.yaml\",\n \"**/pnpm-workspace.yaml\",\n \"**/{package,package-lock}.json\",\n \"**/yarn.lock\",\n \"**/package.json5\",\n \"**/.next/**\",\n];\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: ReadonlyArray<string> | string;\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: ReadonlyArray<string> | string;\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations,no-loops/no-loops\n for await (const dir of this.sources) {\n const files = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n minimatchOptions: {\n match: {\n debug: this.verbose,\n matchBase: true,\n },\n skip: {\n debug: this.verbose,\n matchBase: true,\n },\n },\n skip: [...this.ignore, ...exclude],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${files.length} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
1
+ {"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["mkdir","writeFile","dirname","exit","collect","exclude","errorHandler","error","SwaggerCompilerPlugin","assetsPath","sources","swaggerDefinition","options","compiler","_","callback","spec","spec_builder_default","dir","files","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","swagger_compiler_plugin_default"],"mappings":"2EAAA,OAAS,SAAAA,EAAO,aAAAC,MAAiB,KACjC,OAAS,WAAAC,MAAe,OACxB,OAAS,QAAAC,MAAY,UAErB,OAAS,WAAAC,MAAe,oBAUxB,IAAMC,EAAU,CACZ,cACA,aACA,yBACA,YACA,cACA,6CACA,iDACA,kBACA,yCACA,iCACA,sCACA,gCACA,0BACA,iCACA,0BACA,qBACA,oBACA,yBACA,iCACA,eACA,mBACA,aACJ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,CAEZ,QAAQ,MAAMA,CAAK,EAEnBJ,EAAK,CAAC,CACV,CACJ,CAAC,CACL,CAEA,GAAI,CACI,KAAK,UAEL,QAAQ,IAAI,yBAAyB,EAErC,QAAQ,IAAI,KAAK,UAAUa,EAAM,KAAM,CAAC,CAAC,GAG7C,MAAMU,EAAS,KAAK,MAAM,KAAK,UAAUV,CAAI,CAAC,CAAC,CACnD,OAAST,EAAY,CAEjB,QAAQ,MAAMA,EAAM,OAAO,CAAC,EAE5BJ,EAAK,CAAC,CACV,CAEA,GAAM,CAAE,WAAAM,CAAW,EAAI,KAGvBT,EAAME,EAAQO,CAAU,EAAG,CAAE,UAAW,EAAK,EAAIF,GAAU,CACnDA,GACAD,EAAaC,CAAK,EAItBN,EAAUQ,EAAY,KAAK,UAAUO,EAAM,KAAM,CAAC,EAAGV,CAAY,CACrE,CAAC,EAEG,KAAK,SAEL,QAAQ,IAAI,4BAA4B,KAAK,UAAU,QAAQ,EAInE,QAAQ,IAAI,gCAAgC,EAE5CS,EAAS,CACb,CAAC,CACL,CACJ,EAEOY,EAAQnB","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\n\nimport { collect } from \"@visulima/readdir\";\nimport type { Compiler } from \"webpack\";\n\nimport type { BaseDefinition } from \"../exported\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst exclude = [\n \"coverage/**\",\n \".github/**\",\n \"packages/*/test{,s}/**\",\n \"**/*.d.ts\",\n \"test{,s}/**\",\n \"test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/__tests__/**\",\n \"**/{ava,babel,nyc}.config.{js,cjs,mjs}\",\n \"**/jest.config.{js,cjs,mjs,ts}\",\n \"**/{karma,rollup,webpack}.config.js\",\n \"**/.{eslint,mocha}rc.{js,cjs}\",\n \"**/.{travis,yarnrc}.yml\",\n \"**/{docker-compose,docker}.yml\",\n \"**/.yamllint.{yaml,yml}\",\n \"**/node_modules/**\",\n \"**/pnpm-lock.yaml\",\n \"**/pnpm-workspace.yaml\",\n \"**/{package,package-lock}.json\",\n \"**/yarn.lock\",\n \"**/package.json5\",\n \"**/.next/**\",\n];\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: ReadonlyArray<string> | string;\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: ReadonlyArray<string> | string;\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations,no-loops/no-loops\n for await (const dir of this.sources) {\n const files = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n minimatchOptions: {\n match: {\n debug: this.verbose,\n matchBase: true,\n },\n skip: {\n debug: this.verbose,\n matchBase: true,\n },\n },\n skip: [...this.ignore, ...exclude],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${files.length} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { d as d$1, a, c, e, f } from './chunk-RMC27EXI.mjs';
2
- export { d as SpecBuilder, a as jsDocumentCommentsToOpenApi, c as parseFile, e as swaggerJsDocumentCommentsToOpenApi, b as yamlLoc } from './chunk-RMC27EXI.mjs';
3
- import { mkdir, writeFile } from 'fs';
4
- import { dirname } from 'path';
5
- import { exit } from 'process';
1
+ import { d as d$1, a, c, e, f } from './chunk-RGZ3JDMW.mjs';
2
+ export { d as SpecBuilder, a as jsDocumentCommentsToOpenApi, c as parseFile, e as swaggerJsDocumentCommentsToOpenApi, b as yamlLoc } from './chunk-RGZ3JDMW.mjs';
3
+ import { mkdir, writeFile } from 'node:fs';
4
+ import { dirname } from 'node:path';
5
+ import { exit } from 'node:process';
6
6
  import { collect } from '@visulima/readdir';
7
7
 
8
- var J=["coverage/**",".github/**","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,docker}.yml","**/.yamllint.{yaml,yml}","**/node_modules/**","**/pnpm-lock.yaml","**/pnpm-workspace.yaml","**/{package,package-lock}.json","**/yarn.lock","**/package.json5","**/.next/**"],b=t=>{t&&(console.error(t),exit(1));},d=class{constructor(r,u,i,e){this.assetsPath=r,this.swaggerDefinition=i,this.sources=u,this.verbose=e.verbose??!1,this.ignore=e.ignore??[];}apply(r){r.hooks.make.tapAsync("SwaggerCompilerPlugin",async(u,i)=>{console.log("Build paused, switching to swagger build");let e$1=new d$1(this.swaggerDefinition);for await(let s of this.sources){let a$1=await collect(s,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:!1,minimatchOptions:{match:{debug:this.verbose,matchBase:!0},skip:{debug:this.verbose,matchBase:!0}},skip:[...this.ignore,...J]});this.verbose&&(console.log(`Found ${a$1.length} files in ${s}`),console.log(a$1)),a$1.forEach(n=>{this.verbose&&console.log(`Parsing file ${n}`);try{let l=c(n,a,this.verbose);e$1.addData(l.map(c=>c.spec));let j=c(n,e,this.verbose);e$1.addData(j.map(c=>c.spec));}catch(l){console.error(l),exit(1);}});}try{this.verbose&&(console.log("Validating swagger spec"),console.log(JSON.stringify(e$1,null,2))),await f(JSON.parse(JSON.stringify(e$1)));}catch(s){console.error(s.toJSON()),exit(1);}let{assetsPath:y}=this;mkdir(dirname(y),{recursive:!0},s=>{s&&b(s),writeFile(y,JSON.stringify(e$1,null,2),b);}),this.verbose&&console.log(`Written swagger spec to "${this.assetsPath}" file`),console.log("switching back to normal build"),i();});}},S=d;
8
+ var J=["coverage/**",".github/**","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,docker}.yml","**/.yamllint.{yaml,yml}","**/node_modules/**","**/pnpm-lock.yaml","**/pnpm-workspace.yaml","**/{package,package-lock}.json","**/yarn.lock","**/package.json5","**/.next/**"],b=t=>{t&&(console.error(t),exit(1));},d=class{assetsPath;ignore;sources;swaggerDefinition;verbose;constructor(r,u,i,e){this.assetsPath=r,this.swaggerDefinition=i,this.sources=u,this.verbose=e.verbose??!1,this.ignore=e.ignore??[];}apply(r){r.hooks.make.tapAsync("SwaggerCompilerPlugin",async(u,i)=>{console.log("Build paused, switching to swagger build");let e$1=new d$1(this.swaggerDefinition);for await(let s of this.sources){let a$1=await collect(s,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:!1,minimatchOptions:{match:{debug:this.verbose,matchBase:!0},skip:{debug:this.verbose,matchBase:!0}},skip:[...this.ignore,...J]});this.verbose&&(console.log(`Found ${a$1.length} files in ${s}`),console.log(a$1)),a$1.forEach(n=>{this.verbose&&console.log(`Parsing file ${n}`);try{let l=c(n,a,this.verbose);e$1.addData(l.map(c=>c.spec));let j=c(n,e,this.verbose);e$1.addData(j.map(c=>c.spec));}catch(l){console.error(l),exit(1);}});}try{this.verbose&&(console.log("Validating swagger spec"),console.log(JSON.stringify(e$1,null,2))),await f(JSON.parse(JSON.stringify(e$1)));}catch(s){console.error(s.toJSON()),exit(1);}let{assetsPath:y}=this;mkdir(dirname(y),{recursive:!0},s=>{s&&b(s),writeFile(y,JSON.stringify(e$1,null,2),b);}),this.verbose&&console.log(`Written swagger spec to "${this.assetsPath}" file`),console.log("switching back to normal build"),i();});}},S=d;
9
9
 
10
10
  export { S as SwaggerCompilerPlugin };
11
11
  //# sourceMappingURL=out.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["mkdir","writeFile","dirname","exit","collect","exclude","errorHandler","error","SwaggerCompilerPlugin","assetsPath","sources","swaggerDefinition","options","compiler","_","callback","spec","spec_builder_default","dir","files","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","swagger_compiler_plugin_default"],"mappings":"4EAAA,OAAS,SAAAA,EAAO,aAAAC,MAAiB,KACjC,OAAS,WAAAC,MAAe,OACxB,OAAS,QAAAC,MAAY,UAErB,OAAS,WAAAC,MAAe,oBAUxB,IAAMC,EAAU,CACZ,cACA,aACA,yBACA,YACA,cACA,6CACA,iDACA,kBACA,yCACA,iCACA,sCACA,gCACA,0BACA,iCACA,0BACA,qBACA,oBACA,yBACA,iCACA,eACA,mBACA,aACJ,EAEMC,EAAgBC,GAAe,CAC7BA,IAEA,QAAQ,MAAMA,CAAK,EAEnBJ,EAAK,CAAC,EAEd,EAEMK,EAAN,KAA4B,CAWjB,YACHC,EACAC,EACAC,EACAC,EAIF,CACE,KAAK,WAAaH,EAClB,KAAK,kBAAoBE,EACzB,KAAK,QAAUD,EACf,KAAK,QAAUE,EAAQ,SAAW,GAClC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B,QAAQ,MAAMA,EAAM,OAAO,CAAC,EAE5BJ,EAAK,CAAC,CACV,CAEA,GAAM,CAAE,WAAAM,CAAW,EAAI,KAGvBT,EAAME,EAAQO,CAAU,EAAG,CAAE,UAAW,EAAK,EAAIF,GAAU,CACnDA,GACAD,EAAaC,CAAK,EAItBN,EAAUQ,EAAY,KAAK,UAAUO,EAAM,KAAM,CAAC,EAAGV,CAAY,CACrE,CAAC,EAEG,KAAK,SAEL,QAAQ,IAAI,4BAA4B,KAAK,UAAU,QAAQ,EAInE,QAAQ,IAAI,gCAAgC,EAE5CS,EAAS,CACb,CAAC,CACL,CACJ,EAEOY,EAAQnB","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\n\nimport { collect } from \"@visulima/readdir\";\nimport type { Compiler } from \"webpack\";\n\nimport type { BaseDefinition } from \"../exported.d\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst exclude = [\n \"coverage/**\",\n \".github/**\",\n \"packages/*/test{,s}/**\",\n \"**/*.d.ts\",\n \"test{,s}/**\",\n \"test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/__tests__/**\",\n \"**/{ava,babel,nyc}.config.{js,cjs,mjs}\",\n \"**/jest.config.{js,cjs,mjs,ts}\",\n \"**/{karma,rollup,webpack}.config.js\",\n \"**/.{eslint,mocha}rc.{js,cjs}\",\n \"**/.{travis,yarnrc}.yml\",\n \"**/{docker-compose,docker}.yml\",\n \"**/.yamllint.{yaml,yml}\",\n \"**/node_modules/**\",\n \"**/pnpm-lock.yaml\",\n \"**/pnpm-workspace.yaml\",\n \"**/{package,package-lock}.json\",\n \"**/yarn.lock\",\n \"**/package.json5\",\n \"**/.next/**\",\n];\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: ReadonlyArray<string> | string;\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: ReadonlyArray<string> | string;\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations,no-loops/no-loops\n for await (const dir of this.sources) {\n const files = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n minimatchOptions: {\n match: {\n debug: this.verbose,\n matchBase: true,\n },\n skip: {\n debug: this.verbose,\n matchBase: true,\n },\n },\n skip: [...this.ignore, ...exclude],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${files.length} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
1
+ {"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["mkdir","writeFile","dirname","exit","collect","exclude","errorHandler","error","SwaggerCompilerPlugin","assetsPath","sources","swaggerDefinition","options","compiler","_","callback","spec","spec_builder_default","dir","files","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","swagger_compiler_plugin_default"],"mappings":"4EAAA,OAAS,SAAAA,EAAO,aAAAC,MAAiB,UACjC,OAAS,WAAAC,MAAe,YACxB,OAAS,QAAAC,MAAY,eAErB,OAAS,WAAAC,MAAe,oBAUxB,IAAMC,EAAU,CACZ,cACA,aACA,yBACA,YACA,cACA,6CACA,iDACA,kBACA,yCACA,iCACA,sCACA,gC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AQS,EAA4B,IAAKD,GAASA,EAAK,IAAI,CAAC,CACrE,OAASjB,EAAO,CAEZ,QAAQ,MAAMA,CAAK,EAEnBJ,EAAK,CAAC,CACV,CACJ,CAAC,CACL,CAEA,GAAI,CACI,KAAK,UAEL,QAAQ,IAAI,yBAAyB,EAErC,QAAQ,IAAI,KAAK,UAAUa,EAAM,KAAM,CAAC,CAAC,GAG7C,MAAMU,EAAS,KAAK,MAAM,KAAK,UAAUV,CAAI,CAAC,CAAC,CACnD,OAAST,EAAY,CAEjB,QAAQ,MAAMA,EAAM,OAAO,CAAC,EAE5BJ,EAAK,CAAC,CACV,CAEA,GAAM,CAAE,WAAAM,CAAW,EAAI,KAGvBT,EAAME,EAAQO,CAAU,EAAG,CAAE,UAAW,EAAK,EAAIF,GAAU,CACnDA,GACAD,EAAaC,CAAK,EAItBN,EAAUQ,EAAY,KAAK,UAAUO,EAAM,KAAM,CAAC,EAAGV,CAAY,CACrE,CAAC,EAEG,KAAK,SAEL,QAAQ,IAAI,4BAA4B,KAAK,UAAU,QAAQ,EAInE,QAAQ,IAAI,gCAAgC,EAE5CS,EAAS,CACb,CAAC,CACL,CACJ,EAEOY,EAAQnB","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\n\nimport { collect } from \"@visulima/readdir\";\nimport type { Compiler } from \"webpack\";\n\nimport type { BaseDefinition } from \"../exported\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst exclude = [\n \"coverage/**\",\n \".github/**\",\n \"packages/*/test{,s}/**\",\n \"**/*.d.ts\",\n \"test{,s}/**\",\n \"test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}\",\n \"**/__tests__/**\",\n \"**/{ava,babel,nyc}.config.{js,cjs,mjs}\",\n \"**/jest.config.{js,cjs,mjs,ts}\",\n \"**/{karma,rollup,webpack}.config.js\",\n \"**/.{eslint,mocha}rc.{js,cjs}\",\n \"**/.{travis,yarnrc}.yml\",\n \"**/{docker-compose,docker}.yml\",\n \"**/.yamllint.{yaml,yml}\",\n \"**/node_modules/**\",\n \"**/pnpm-lock.yaml\",\n \"**/pnpm-workspace.yaml\",\n \"**/{package,package-lock}.json\",\n \"**/yarn.lock\",\n \"**/package.json5\",\n \"**/.next/**\",\n];\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: ReadonlyArray<string> | string;\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: ReadonlyArray<string> | string;\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line no-restricted-syntax,unicorn/prevent-abbreviations,no-loops/no-loops\n for await (const dir of this.sources) {\n const files = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n minimatchOptions: {\n match: {\n debug: this.verbose,\n matchBase: true,\n },\n skip: {\n debug: this.verbose,\n matchBase: true,\n },\n },\n skip: [...this.ignore, ...exclude],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${files.length} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/jsdoc-open-api",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "description": "Generates swagger doc based on JSDoc.",
5
5
  "keywords": [
6
6
  "visulima",
@@ -104,17 +104,17 @@
104
104
  },
105
105
  "dependencies": {
106
106
  "@apidevtools/swagger-parser": "^10.1.0",
107
- "@visulima/readdir": "2.0.11",
107
+ "@visulima/readdir": "2.0.12",
108
108
  "comment-parser": "^1.4.1",
109
109
  "lodash.mergewith": "^4.6.2",
110
110
  "read-pkg-up": "^7.0.1",
111
- "yaml": "^2.4.0"
111
+ "yaml": "^2.4.1"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@anolilab/eslint-config": "^15.0.3",
115
115
  "@anolilab/prettier-config": "^5.0.14",
116
116
  "@anolilab/semantic-release-preset": "^8.0.3",
117
- "@babel/core": "^7.23.9",
117
+ "@babel/core": "^7.24.0",
118
118
  "@rushstack/eslint-plugin-security": "^0.8.1",
119
119
  "@types/cli-progress": "^3.11.5",
120
120
  "@types/http-errors": "^2.0.4",
@@ -139,7 +139,7 @@
139
139
  "semantic-release": "^23.0.2",
140
140
  "sort-package-json": "^2.8.0",
141
141
  "tsup": "^8.0.2",
142
- "typescript": "^5.3.3",
142
+ "typescript": "^5.4.2",
143
143
  "vitest": "^1.3.1",
144
144
  "webpack": "^5.90.3"
145
145
  },