@loopback/openapi-spec-builder 4.0.0-alpha.8 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +57 -28
- package/dist/index.d.ts +18 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi-spec-builder.d.ts +188 -0
- package/dist/openapi-spec-builder.js +352 -0
- package/dist/openapi-spec-builder.js.map +1 -0
- package/package.json +37 -27
- package/src/index.ts +24 -0
- package/src/openapi-spec-builder.ts +394 -0
- package/CHANGELOG.md +0 -12
- package/api-docs/apple-touch-icon-114x114-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-144x144-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-57x57-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-72x72-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-precomposed.png +0 -0
- package/api-docs/apple-touch-icon.png +0 -0
- package/api-docs/css/bootstrap.min.css +0 -9
- package/api-docs/css/code-themes/arta.css +0 -158
- package/api-docs/css/code-themes/ascetic.css +0 -50
- package/api-docs/css/code-themes/brown_paper.css +0 -104
- package/api-docs/css/code-themes/brown_papersq.png +0 -0
- package/api-docs/css/code-themes/dark.css +0 -103
- package/api-docs/css/code-themes/default.css +0 -135
- package/api-docs/css/code-themes/far.css +0 -111
- package/api-docs/css/code-themes/github.css +0 -127
- package/api-docs/css/code-themes/googlecode.css +0 -144
- package/api-docs/css/code-themes/idea.css +0 -121
- package/api-docs/css/code-themes/ir_black.css +0 -104
- package/api-docs/css/code-themes/magula.css +0 -121
- package/api-docs/css/code-themes/monokai.css +0 -114
- package/api-docs/css/code-themes/pojoaque.css +0 -104
- package/api-docs/css/code-themes/pojoaque.jpg +0 -0
- package/api-docs/css/code-themes/rainbow.css +0 -114
- package/api-docs/css/code-themes/school_book.css +0 -111
- package/api-docs/css/code-themes/school_book.png +0 -0
- package/api-docs/css/code-themes/sl-theme.css +0 -45
- package/api-docs/css/code-themes/solarized_dark.css +0 -88
- package/api-docs/css/code-themes/solarized_light.css +0 -88
- package/api-docs/css/code-themes/sunburst.css +0 -158
- package/api-docs/css/code-themes/tomorrow-night-blue.css +0 -52
- package/api-docs/css/code-themes/tomorrow-night-bright.css +0 -51
- package/api-docs/css/code-themes/tomorrow-night-eighties.css +0 -51
- package/api-docs/css/code-themes/tomorrow-night.css +0 -52
- package/api-docs/css/code-themes/tomorrow.css +0 -49
- package/api-docs/css/code-themes/vs.css +0 -86
- package/api-docs/css/code-themes/xcode.css +0 -154
- package/api-docs/css/code-themes/zenburn.css +0 -115
- package/api-docs/css/main.css +0 -139
- package/api-docs/favicon.ico +0 -0
- package/api-docs/fonts/0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/fonts/OsJ2DjdpjqFRVUSto6IffLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/fonts/_aijTyevf54tkVDLy-dlnLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/index.html +0 -1021
- package/api-docs/js/main.js +0 -19
- package/api-docs/js/vendor/bootstrap.min.js +0 -6
- package/api-docs/js/vendor/jquery-1.10.1.min.js +0 -6
- package/api-docs/js/vendor/jquery.scrollTo-1.4.3.1.js +0 -218
- package/api-docs/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js +0 -11
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -11
- package/dist/src/index.js.map +0 -1
- package/dist/src/openapi-spec-builder.d.ts +0 -82
- package/dist/src/openapi-spec-builder.js +0 -138
- package/dist/src/openapi-spec-builder.js.map +0 -1
- package/dist6/src/index.d.ts +0 -1
- package/dist6/src/index.js +0 -11
- package/dist6/src/index.js.map +0 -1
- package/dist6/src/openapi-spec-builder.d.ts +0 -82
- package/dist6/src/openapi-spec-builder.js +0 -138
- package/dist6/src/openapi-spec-builder.js.map +0 -1
- package/index.d.ts +0 -6
- package/index.js +0 -9
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/openapi-spec-builder
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ComponentsSpecBuilder = exports.OperationSpecBuilder = exports.OpenApiSpecBuilder = exports.BuilderBase = exports.aComponentsSpec = exports.anOperationSpec = exports.anOpenApiSpec = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const assert_1 = (0, tslib_1.__importDefault)(require("assert"));
|
|
10
|
+
/**
|
|
11
|
+
* Create a new instance of OpenApiSpecBuilder.
|
|
12
|
+
*
|
|
13
|
+
* @param basePath - The base path on which the API is served.
|
|
14
|
+
*/
|
|
15
|
+
function anOpenApiSpec() {
|
|
16
|
+
return new OpenApiSpecBuilder();
|
|
17
|
+
}
|
|
18
|
+
exports.anOpenApiSpec = anOpenApiSpec;
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of OperationSpecBuilder.
|
|
21
|
+
*/
|
|
22
|
+
function anOperationSpec() {
|
|
23
|
+
return new OperationSpecBuilder();
|
|
24
|
+
}
|
|
25
|
+
exports.anOperationSpec = anOperationSpec;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new instance of ComponentsSpecBuilder.
|
|
28
|
+
*/
|
|
29
|
+
function aComponentsSpec() {
|
|
30
|
+
return new ComponentsSpecBuilder();
|
|
31
|
+
}
|
|
32
|
+
exports.aComponentsSpec = aComponentsSpec;
|
|
33
|
+
class BuilderBase {
|
|
34
|
+
constructor(initialSpec) {
|
|
35
|
+
this._spec = initialSpec;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Add a custom (extension) property to the spec object.
|
|
39
|
+
*
|
|
40
|
+
* @param key - The property name starting with "x-".
|
|
41
|
+
* @param value - The property value.
|
|
42
|
+
*/
|
|
43
|
+
withExtension(key,
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
value) {
|
|
46
|
+
(0, assert_1.default)(key.startsWith('x-'), `Invalid extension ${key}, extension keys must be prefixed with "x-"`);
|
|
47
|
+
// `this._spec[key] = value;` is broken in TypeScript 3.5
|
|
48
|
+
// See https://github.com/microsoft/TypeScript/issues/31661
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
this._spec[key] = value;
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Build the spec object.
|
|
55
|
+
*/
|
|
56
|
+
build() {
|
|
57
|
+
// TODO(bajtos): deep-clone
|
|
58
|
+
return this._spec;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.BuilderBase = BuilderBase;
|
|
62
|
+
/**
|
|
63
|
+
* A builder for creating OpenApiSpec documents.
|
|
64
|
+
*/
|
|
65
|
+
class OpenApiSpecBuilder extends BuilderBase {
|
|
66
|
+
/**
|
|
67
|
+
* @param basePath - The base path on which the API is served.
|
|
68
|
+
*/
|
|
69
|
+
constructor() {
|
|
70
|
+
super({
|
|
71
|
+
openapi: '3.0.0',
|
|
72
|
+
info: {
|
|
73
|
+
title: 'LoopBack Application',
|
|
74
|
+
version: '1.0.0',
|
|
75
|
+
},
|
|
76
|
+
paths: {},
|
|
77
|
+
servers: [{ url: '/' }],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Define a new OperationObject at the given path and verb (method).
|
|
82
|
+
*
|
|
83
|
+
* @param verb - The HTTP verb.
|
|
84
|
+
* @param path - The path relative to basePath.
|
|
85
|
+
* @param spec - Additional specification of the operation.
|
|
86
|
+
*/
|
|
87
|
+
withOperation(verb, path, spec) {
|
|
88
|
+
if (spec instanceof OperationSpecBuilder)
|
|
89
|
+
spec = spec.build();
|
|
90
|
+
if (!this._spec.paths[path])
|
|
91
|
+
this._spec.paths[path] = {};
|
|
92
|
+
this._spec.paths[path][verb] = spec;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Define a new operation that returns a string response.
|
|
97
|
+
*
|
|
98
|
+
* @param verb - The HTTP verb.
|
|
99
|
+
* @param path - The path relative to basePath.
|
|
100
|
+
* @param operationName - The name of the controller method implementing
|
|
101
|
+
* this operation (`x-operation-name` field).
|
|
102
|
+
*/
|
|
103
|
+
withOperationReturningString(verb, path, operationName) {
|
|
104
|
+
const spec = anOperationSpec().withStringResponse(200);
|
|
105
|
+
if (operationName)
|
|
106
|
+
spec.withOperationName(operationName);
|
|
107
|
+
return this.withOperation(verb, path, spec);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Define a new ComponentsObject.
|
|
111
|
+
*
|
|
112
|
+
* @param spec - Specification of the components.
|
|
113
|
+
*/
|
|
114
|
+
withComponents(spec) {
|
|
115
|
+
if (spec instanceof ComponentsSpecBuilder)
|
|
116
|
+
spec = spec.build();
|
|
117
|
+
if (!this._spec.components)
|
|
118
|
+
this._spec.components = spec;
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.OpenApiSpecBuilder = OpenApiSpecBuilder;
|
|
123
|
+
/**
|
|
124
|
+
* A builder for creating OperationObject specifications.
|
|
125
|
+
*/
|
|
126
|
+
class OperationSpecBuilder extends BuilderBase {
|
|
127
|
+
constructor() {
|
|
128
|
+
super({
|
|
129
|
+
responses: { '200': { description: 'An undocumented response body.' } },
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Describe a response for a given HTTP status code.
|
|
134
|
+
* @param status - HTTP status code or string "default"
|
|
135
|
+
* @param responseSpec - Specification of the response
|
|
136
|
+
*/
|
|
137
|
+
withResponse(status, responseSpec) {
|
|
138
|
+
// OpenAPI spec uses string indices, i.e. 200 OK uses "200" as the index
|
|
139
|
+
this._spec.responses[status.toString()] = responseSpec;
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
withStringResponse(status = 200) {
|
|
143
|
+
return this.withResponse(status, {
|
|
144
|
+
description: 'The string result.',
|
|
145
|
+
content: {
|
|
146
|
+
'text/plain': {
|
|
147
|
+
schema: { type: 'string' },
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Describe one more parameters accepted by the operation.
|
|
154
|
+
* Note that parameters are positional in OpenAPI Spec, therefore
|
|
155
|
+
* the first call of `withParameter` defines the first parameter,
|
|
156
|
+
* the second call defines the second parameter, etc.
|
|
157
|
+
* @param parameterSpecs
|
|
158
|
+
*/
|
|
159
|
+
withParameter(...parameterSpecs) {
|
|
160
|
+
if (!this._spec.parameters)
|
|
161
|
+
this._spec.parameters = [];
|
|
162
|
+
this._spec.parameters.push(...parameterSpecs);
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
withRequestBody(requestBodySpec) {
|
|
166
|
+
this._spec.requestBody = requestBodySpec;
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Define the operation name (controller method name).
|
|
171
|
+
*
|
|
172
|
+
* @param name - The name of the controller method implementing this operation.
|
|
173
|
+
*/
|
|
174
|
+
withOperationName(name) {
|
|
175
|
+
this.withExtension('x-operation-name', name);
|
|
176
|
+
this.setupOperationId();
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Define the controller name (controller name).
|
|
181
|
+
*
|
|
182
|
+
* @param name - The name of the controller containing this operation.
|
|
183
|
+
*/
|
|
184
|
+
withControllerName(name) {
|
|
185
|
+
this.withExtension('x-controller-name', name);
|
|
186
|
+
this.setupOperationId();
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Set up the `operationId` if not configured
|
|
191
|
+
*/
|
|
192
|
+
setupOperationId() {
|
|
193
|
+
if (this._spec.operationId)
|
|
194
|
+
return;
|
|
195
|
+
const controllerName = this._spec['x-controller-name'];
|
|
196
|
+
const operationName = this._spec['x-operation-name'];
|
|
197
|
+
if (controllerName && operationName) {
|
|
198
|
+
// Build the operationId as `<controllerName>.<operationName>`
|
|
199
|
+
// Please note API explorer (https://github.com/swagger-api/swagger-js/)
|
|
200
|
+
// will normalize it as `<controllerName>_<operationName>`
|
|
201
|
+
this._spec.operationId = controllerName + '.' + operationName;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Define the operationId
|
|
206
|
+
* @param operationId - Operation id
|
|
207
|
+
*/
|
|
208
|
+
withOperationId(operationId) {
|
|
209
|
+
this._spec.operationId = operationId;
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Describe tags associated with the operation
|
|
214
|
+
* @param tags
|
|
215
|
+
*/
|
|
216
|
+
withTags(tags) {
|
|
217
|
+
if (!this._spec.tags)
|
|
218
|
+
this._spec.tags = [];
|
|
219
|
+
if (typeof tags === 'string')
|
|
220
|
+
tags = [tags];
|
|
221
|
+
this._spec.tags.push(...tags);
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.OperationSpecBuilder = OperationSpecBuilder;
|
|
226
|
+
/**
|
|
227
|
+
* A builder for creating ComponentsObject specifications.
|
|
228
|
+
*/
|
|
229
|
+
class ComponentsSpecBuilder extends BuilderBase {
|
|
230
|
+
constructor() {
|
|
231
|
+
super({});
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Define a component schema.
|
|
235
|
+
*
|
|
236
|
+
* @param name - The name of the schema
|
|
237
|
+
* @param schema - Specification of the schema
|
|
238
|
+
*
|
|
239
|
+
*/
|
|
240
|
+
withSchema(name, schema) {
|
|
241
|
+
if (!this._spec.schemas)
|
|
242
|
+
this._spec.schemas = {};
|
|
243
|
+
this._spec.schemas[name] = schema;
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Define a component response.
|
|
248
|
+
*
|
|
249
|
+
* @param name - The name of the response
|
|
250
|
+
* @param response - Specification of the response
|
|
251
|
+
*
|
|
252
|
+
*/
|
|
253
|
+
withResponse(name, response) {
|
|
254
|
+
if (!this._spec.responses)
|
|
255
|
+
this._spec.responses = {};
|
|
256
|
+
this._spec.responses[name] = response;
|
|
257
|
+
return this;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Define a component parameter.
|
|
261
|
+
*
|
|
262
|
+
* @param name - The name of the parameter
|
|
263
|
+
* @param parameter - Specification of the parameter
|
|
264
|
+
*
|
|
265
|
+
*/
|
|
266
|
+
withParameter(name, parameter) {
|
|
267
|
+
if (!this._spec.parameters)
|
|
268
|
+
this._spec.parameters = {};
|
|
269
|
+
this._spec.parameters[name] = parameter;
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Define a component example.
|
|
274
|
+
*
|
|
275
|
+
* @param name - The name of the example
|
|
276
|
+
* @param example - Specification of the example
|
|
277
|
+
*
|
|
278
|
+
*/
|
|
279
|
+
withExample(name, example) {
|
|
280
|
+
if (!this._spec.examples)
|
|
281
|
+
this._spec.examples = {};
|
|
282
|
+
this._spec.examples[name] = example;
|
|
283
|
+
return this;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Define a component request body.
|
|
287
|
+
*
|
|
288
|
+
* @param name - The name of the request body
|
|
289
|
+
* @param requestBody - Specification of the request body
|
|
290
|
+
*
|
|
291
|
+
*/
|
|
292
|
+
withRequestBody(name, requestBody) {
|
|
293
|
+
if (!this._spec.requestBodies)
|
|
294
|
+
this._spec.requestBodies = {};
|
|
295
|
+
this._spec.requestBodies[name] = requestBody;
|
|
296
|
+
return this;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Define a component header.
|
|
300
|
+
*
|
|
301
|
+
* @param name - The name of the header
|
|
302
|
+
* @param header - Specification of the header
|
|
303
|
+
*
|
|
304
|
+
*/
|
|
305
|
+
withHeader(name, header) {
|
|
306
|
+
if (!this._spec.headers)
|
|
307
|
+
this._spec.headers = {};
|
|
308
|
+
this._spec.headers[name] = header;
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Define a component security scheme.
|
|
313
|
+
*
|
|
314
|
+
* @param name - The name of the security scheme
|
|
315
|
+
* @param securityScheme - Specification of the security scheme
|
|
316
|
+
*
|
|
317
|
+
*/
|
|
318
|
+
withSecurityScheme(name, securityScheme) {
|
|
319
|
+
if (!this._spec.securitySchemes)
|
|
320
|
+
this._spec.securitySchemes = {};
|
|
321
|
+
this._spec.securitySchemes[name] = securityScheme;
|
|
322
|
+
return this;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Define a component link.
|
|
326
|
+
*
|
|
327
|
+
* @param name - The name of the link
|
|
328
|
+
* @param link - Specification of the link
|
|
329
|
+
*
|
|
330
|
+
*/
|
|
331
|
+
withLink(name, link) {
|
|
332
|
+
if (!this._spec.links)
|
|
333
|
+
this._spec.links = {};
|
|
334
|
+
this._spec.links[name] = link;
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Define a component callback.
|
|
339
|
+
*
|
|
340
|
+
* @param name - The name of the callback
|
|
341
|
+
* @param callback - Specification of the callback
|
|
342
|
+
*
|
|
343
|
+
*/
|
|
344
|
+
withCallback(name, callback) {
|
|
345
|
+
if (!this._spec.callbacks)
|
|
346
|
+
this._spec.callbacks = {};
|
|
347
|
+
this._spec.callbacks[name] = callback;
|
|
348
|
+
return this;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
exports.ComponentsSpecBuilder = ComponentsSpecBuilder;
|
|
352
|
+
//# sourceMappingURL=openapi-spec-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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B,IAAY,EACZ,cAAsD;QAEtD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe;YAAE,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;QACjE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,IAAY,EAAE,IAAkC;QACvD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CAAC,IAAY,EAAE,QAA0C;QACnE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS;YAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlID,sDAkIC"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/openapi-spec-builder",
|
|
3
|
-
"version": "4.0.0-alpha.8",
|
|
4
3
|
"description": "Make it easy to create OpenAPI (Swagger) specification documents in your tests using the builder pattern.",
|
|
5
|
-
"
|
|
6
|
-
"node": ">=6"
|
|
7
|
-
},
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "npm run build:dist && npm run build:dist6",
|
|
10
|
-
"build:current": "node ../../bin/compile-package",
|
|
11
|
-
"build:dist": "node ../../bin/compile-package es2017",
|
|
12
|
-
"build:dist6": "node ../../bin/compile-package es2015",
|
|
13
|
-
"build:apidocs": "node ../../bin/generate-apidocs",
|
|
14
|
-
"clean": "rm -rf loopback-openapi-spec*.tgz dist* package",
|
|
15
|
-
"prepublish": "npm run build && npm run build:apidocs",
|
|
16
|
-
"verify": "npm pack && tar xf loopback-openapi-spec*.tgz && tree package && npm run clean"
|
|
17
|
-
},
|
|
18
|
-
"author": "IBM",
|
|
19
|
-
"license": "MIT",
|
|
4
|
+
"version": "4.1.0",
|
|
20
5
|
"keywords": [
|
|
21
6
|
"Swagger",
|
|
22
7
|
"OpenAPI Spec",
|
|
@@ -24,19 +9,44 @@
|
|
|
24
9
|
"Builder",
|
|
25
10
|
"Testing"
|
|
26
11
|
],
|
|
27
|
-
"
|
|
28
|
-
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"author": "IBM Corp.",
|
|
16
|
+
"copyright.owner": "IBM Corp.",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/loopbackio/loopback-next.git",
|
|
20
|
+
"directory": "packages/openapi-spec-builder"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": "12 || 14 || 16 || 17"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "lb-tsc",
|
|
27
|
+
"clean": "lb-clean loopback-openapi-spec-builder*.tgz dist *.tsbuildinfo package",
|
|
28
|
+
"pretest": "npm run build",
|
|
29
|
+
"test": "lb-mocha \"dist/__tests__/**/*.js\"",
|
|
30
|
+
"verify": "npm pack && tar xf loopback-openapi-spec-builder*.tgz && tree package && npm run clean"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
29
34
|
},
|
|
30
35
|
"files": [
|
|
31
36
|
"README.md",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"dist6/src",
|
|
36
|
-
"api-docs"
|
|
37
|
+
"dist",
|
|
38
|
+
"src",
|
|
39
|
+
"!*/__tests__"
|
|
37
40
|
],
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
}
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"openapi3-ts": "^2.0.1",
|
|
43
|
+
"tslib": "^2.3.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@loopback/build": "^8.1.0",
|
|
47
|
+
"@loopback/eslint-config": "^12.0.2",
|
|
48
|
+
"@loopback/testlab": "^4.1.0",
|
|
49
|
+
"@types/node": "^12.20.43"
|
|
50
|
+
},
|
|
51
|
+
"gitHead": "e16818ccb01edc0269ef6c45b022c5f1b67f852c"
|
|
42
52
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
|
|
2
|
+
// Node module: @loopback/openapi-spec-builder
|
|
3
|
+
// This file is licensed under the MIT License.
|
|
4
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A package to simplify creating OpenAPI specification documents in your tests
|
|
8
|
+
* using the builder pattern.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Creating a full OpenAPI spec document in automated tests is rather
|
|
12
|
+
* cumbersome, long JSON-like objects pollute the test test code and make it
|
|
13
|
+
* difficult for readers to distinguish between what's important in the test and
|
|
14
|
+
* what's just shared OpenAPI boilerplate.
|
|
15
|
+
*
|
|
16
|
+
* OpenApiSpecBuilder utilizes
|
|
17
|
+
* {@link http://www.natpryce.com/articles/000714.html | Test Data Builder pattern}
|
|
18
|
+
* to provide a TypeScript/JavaScript API allowing users to create full OpenAPI
|
|
19
|
+
* Specification 3 documents in few lines of code.
|
|
20
|
+
*
|
|
21
|
+
* @packageDocumentation
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export * from './openapi-spec-builder';
|