@skmtc/core 0.35.3 → 0.36.1
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/esm/_dnt.polyfills.d.ts +6 -6
- package/esm/context/ParseContext.d.ts +22 -29
- package/esm/context/ParseContext.js +179 -82
- package/esm/context/tryParseAt.js +3 -3
- package/esm/gql/document/GqlDocument.js +22 -6
- package/esm/gql/document/parseGqlDocument.js +3 -1
- package/esm/oas/components/Components.d.ts +10 -0
- package/esm/oas/components/Components.js +64 -0
- package/esm/oas/document/Document.d.ts +7 -7
- package/esm/oas/document/Document.js +6 -4
- package/esm/parse/pathParameters.d.ts +13 -0
- package/esm/parse/pathParameters.js +2 -2
- package/esm/parse/v3-0/server/toServerV3.js +11 -1
- package/esm/parse/v3-1/server/toServerV3.js +11 -1
- package/esm/parse/v3-2/server/toServerV3.js +11 -1
- package/package.json +1 -1
- package/script/_dnt.polyfills.d.ts +6 -6
- package/script/context/ParseContext.d.ts +22 -29
- package/script/context/ParseContext.js +179 -82
- package/script/context/tryParseAt.js +3 -3
- package/script/gql/document/GqlDocument.js +22 -6
- package/script/gql/document/parseGqlDocument.js +3 -1
- package/script/oas/components/Components.d.ts +10 -0
- package/script/oas/components/Components.js +64 -0
- package/script/oas/document/Document.d.ts +7 -7
- package/script/oas/document/Document.js +6 -4
- package/script/parse/pathParameters.d.ts +13 -0
- package/script/parse/pathParameters.js +6 -4
- package/script/parse/v3-0/server/toServerV3.js +11 -1
- package/script/parse/v3-1/server/toServerV3.js +11 -1
- package/script/parse/v3-2/server/toServerV3.js +11 -1
|
@@ -38,10 +38,10 @@ const tryParseAt = ({ stackTrail, key, context, type, parent, refKey, fn }) => {
|
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
|
40
40
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
41
|
-
if (refKey !== undefined) {
|
|
42
|
-
context.registerRefError(error, refKey);
|
|
43
|
-
}
|
|
44
41
|
stackTrail.trace(key, childStack => {
|
|
42
|
+
if (refKey !== undefined) {
|
|
43
|
+
context.registerRefError(error, refKey, childStack.toString());
|
|
44
|
+
}
|
|
45
45
|
context.logIssueNoKey({
|
|
46
46
|
level: 'error',
|
|
47
47
|
stackTrail: childStack,
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _GqlDocument_fields;
|
|
13
|
+
var _GqlDocument_fields, _GqlDocument_parseTimeMembers;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.GqlDocument = void 0;
|
|
16
16
|
const Object_js_1 = require("../../oas/object/Object.js");
|
|
@@ -55,6 +55,15 @@ class GqlDocument {
|
|
|
55
55
|
});
|
|
56
56
|
/** @internal Private fields storage — set after parsing. */
|
|
57
57
|
_GqlDocument_fields.set(this, void 0);
|
|
58
|
+
/** Members of each union as they were before `removeItem` first removed one. */
|
|
59
|
+
_GqlDocument_parseTimeMembers.set(this, new WeakMap()
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new GqlDocument instance.
|
|
62
|
+
*
|
|
63
|
+
* The document is typically created without fields and populated later
|
|
64
|
+
* during parsing. See the class-level docstring for why.
|
|
65
|
+
*/
|
|
66
|
+
);
|
|
58
67
|
__classPrivateFieldSet(this, _GqlDocument_fields, fields, "f");
|
|
59
68
|
}
|
|
60
69
|
/**
|
|
@@ -133,7 +142,8 @@ class GqlDocument {
|
|
|
133
142
|
// Case 1: root-field operation removal.
|
|
134
143
|
const isRootType = first === rootTypes.query || first === rootTypes.mutation || first === rootTypes.subscription;
|
|
135
144
|
if (isRootType) {
|
|
136
|
-
|
|
145
|
+
// Query and Mutation can share a field name: match the root type too.
|
|
146
|
+
const index = operations.findIndex(op => op.fieldName === second && rootTypes[op.rootKind] === first);
|
|
137
147
|
if (index === -1)
|
|
138
148
|
return undefined;
|
|
139
149
|
const [removed] = operations.splice(index, 1);
|
|
@@ -143,10 +153,16 @@ class GqlDocument {
|
|
|
143
153
|
if (second === 'members' && typeof third === 'string') {
|
|
144
154
|
const parent = registry.schemas[first];
|
|
145
155
|
if (parent instanceof Union_js_1.OasUnion) {
|
|
146
|
-
|
|
147
|
-
|
|
156
|
+
// The index is the member's position at parse time. Look the member up
|
|
157
|
+
// in the list as it was before the first removal, so an earlier
|
|
158
|
+
// removal does not shift it.
|
|
159
|
+
const parseTimeMembers = __classPrivateFieldGet(this, _GqlDocument_parseTimeMembers, "f").get(parent) ?? [...parent.members];
|
|
160
|
+
__classPrivateFieldGet(this, _GqlDocument_parseTimeMembers, "f").set(parent, parseTimeMembers);
|
|
161
|
+
const member = parseTimeMembers[Number.parseInt(third, 10)];
|
|
162
|
+
const index = member === undefined ? -1 : parent.members.indexOf(member);
|
|
163
|
+
if (index === -1)
|
|
148
164
|
return undefined;
|
|
149
|
-
const [removed] = parent.members.splice(
|
|
165
|
+
const [removed] = parent.members.splice(index, 1);
|
|
150
166
|
return removed;
|
|
151
167
|
}
|
|
152
168
|
return undefined;
|
|
@@ -171,4 +187,4 @@ class GqlDocument {
|
|
|
171
187
|
}
|
|
172
188
|
}
|
|
173
189
|
exports.GqlDocument = GqlDocument;
|
|
174
|
-
_GqlDocument_fields = new WeakMap();
|
|
190
|
+
_GqlDocument_fields = new WeakMap(), _GqlDocument_parseTimeMembers = new WeakMap();
|
|
@@ -140,9 +140,11 @@ const addNamedType = ({ name, type, stackTrail, context, synthesizeInterfaceUnio
|
|
|
140
140
|
// `refKey: name` (the type's own name, not `refName`) preserves the
|
|
141
141
|
// prior behavior where an interface-union failure marks the base
|
|
142
142
|
// type as errored so dependents of either form get pruned together.
|
|
143
|
+
// `key: refName` traces the synthesized interface union under its own
|
|
144
|
+
// registered name, so its member trails name the union.
|
|
143
145
|
const value = (0, tryParseAt_js_1.tryParseAt)({
|
|
144
146
|
stackTrail,
|
|
145
|
-
key:
|
|
147
|
+
key: refName,
|
|
146
148
|
context,
|
|
147
149
|
type: 'INVALID_TYPE_DEFINITION',
|
|
148
150
|
parent: type,
|
|
@@ -36,6 +36,8 @@ export type ComponentsFields = {
|
|
|
36
36
|
/** Custom extension fields (x-* properties) */
|
|
37
37
|
extensionFields?: Record<string, unknown>;
|
|
38
38
|
};
|
|
39
|
+
/** One entry of any {@link ComponentsFields} bucket. */
|
|
40
|
+
export type ComponentsEntry = OasSchema | OasRef<'schema'> | OasResponse | OasRef<'response'> | OasParameter | OasRef<'parameter'> | OasExample | OasRef<'example'> | OasRequestBody | OasRef<'requestBody'> | OasHeader | OasRef<'header'> | OasSecurityScheme | OasRef<'securityScheme'> | OasLink | OasRef<'link'>;
|
|
39
41
|
/**
|
|
40
42
|
* Represents the OpenAPI Components Object in the SKMTC OAS processing system.
|
|
41
43
|
*
|
|
@@ -285,6 +287,14 @@ export declare class OasComponents {
|
|
|
285
287
|
* ```
|
|
286
288
|
*/
|
|
287
289
|
removeSchema(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
290
|
+
/**
|
|
291
|
+
* Removes the entry `refName` from the `bucket` record (`schemas`,
|
|
292
|
+
* `requestBodies`, `headers`, …) and returns it.
|
|
293
|
+
*
|
|
294
|
+
* Returns `undefined` when the bucket has no such entry, and for a bucket
|
|
295
|
+
* outside {@link componentsKeys}.
|
|
296
|
+
*/
|
|
297
|
+
removeEntry(bucket: string, refName: RefName): ComponentsEntry | undefined;
|
|
288
298
|
/** Record holding re-usable {@link OasResponse} objects or Refs */
|
|
289
299
|
get responses(): Record<RefName, OasResponse | OasRef<'response'>> | undefined;
|
|
290
300
|
/** Record holding re-usable {@link OasParameter} objects or Refs */
|
|
@@ -27,6 +27,16 @@ exports.componentsKeys = [
|
|
|
27
27
|
'securitySchemes',
|
|
28
28
|
'links'
|
|
29
29
|
];
|
|
30
|
+
/** Copy of `record` without `name`, and the value it held. */
|
|
31
|
+
const withoutEntry = (record, name) => {
|
|
32
|
+
if (!record || !Object.hasOwn(record, name)) {
|
|
33
|
+
return { removed: undefined, rest: record };
|
|
34
|
+
}
|
|
35
|
+
const rest = { ...record };
|
|
36
|
+
const removed = rest[name];
|
|
37
|
+
delete rest[name];
|
|
38
|
+
return { removed, rest };
|
|
39
|
+
};
|
|
30
40
|
/**
|
|
31
41
|
* Represents the OpenAPI Components Object in the SKMTC OAS processing system.
|
|
32
42
|
*
|
|
@@ -292,6 +302,60 @@ class OasComponents {
|
|
|
292
302
|
__classPrivateFieldGet(this, _OasComponents_fields, "f").schemas = rest;
|
|
293
303
|
return removed;
|
|
294
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Removes the entry `refName` from the `bucket` record (`schemas`,
|
|
307
|
+
* `requestBodies`, `headers`, …) and returns it.
|
|
308
|
+
*
|
|
309
|
+
* Returns `undefined` when the bucket has no such entry, and for a bucket
|
|
310
|
+
* outside {@link componentsKeys}.
|
|
311
|
+
*/
|
|
312
|
+
removeEntry(bucket, refName) {
|
|
313
|
+
const fields = __classPrivateFieldGet(this, _OasComponents_fields, "f");
|
|
314
|
+
switch (bucket) {
|
|
315
|
+
case 'schemas': {
|
|
316
|
+
const { removed, rest } = withoutEntry(fields.schemas, refName);
|
|
317
|
+
fields.schemas = rest;
|
|
318
|
+
return removed;
|
|
319
|
+
}
|
|
320
|
+
case 'responses': {
|
|
321
|
+
const { removed, rest } = withoutEntry(fields.responses, refName);
|
|
322
|
+
fields.responses = rest;
|
|
323
|
+
return removed;
|
|
324
|
+
}
|
|
325
|
+
case 'parameters': {
|
|
326
|
+
const { removed, rest } = withoutEntry(fields.parameters, refName);
|
|
327
|
+
fields.parameters = rest;
|
|
328
|
+
return removed;
|
|
329
|
+
}
|
|
330
|
+
case 'examples': {
|
|
331
|
+
const { removed, rest } = withoutEntry(fields.examples, refName);
|
|
332
|
+
fields.examples = rest;
|
|
333
|
+
return removed;
|
|
334
|
+
}
|
|
335
|
+
case 'requestBodies': {
|
|
336
|
+
const { removed, rest } = withoutEntry(fields.requestBodies, refName);
|
|
337
|
+
fields.requestBodies = rest;
|
|
338
|
+
return removed;
|
|
339
|
+
}
|
|
340
|
+
case 'headers': {
|
|
341
|
+
const { removed, rest } = withoutEntry(fields.headers, refName);
|
|
342
|
+
fields.headers = rest;
|
|
343
|
+
return removed;
|
|
344
|
+
}
|
|
345
|
+
case 'securitySchemes': {
|
|
346
|
+
const { removed, rest } = withoutEntry(fields.securitySchemes, refName);
|
|
347
|
+
fields.securitySchemes = rest;
|
|
348
|
+
return removed;
|
|
349
|
+
}
|
|
350
|
+
case 'links': {
|
|
351
|
+
const { removed, rest } = withoutEntry(fields.links, refName);
|
|
352
|
+
fields.links = rest;
|
|
353
|
+
return removed;
|
|
354
|
+
}
|
|
355
|
+
default:
|
|
356
|
+
return undefined;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
295
359
|
/** Record holding re-usable {@link OasResponse} objects or Refs */
|
|
296
360
|
get responses() {
|
|
297
361
|
return __classPrivateFieldGet(this, _OasComponents_fields, "f").responses;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import "../../_dnt.polyfills.js";
|
|
2
2
|
import type { OasTag } from '../tag/Tag.js';
|
|
3
|
-
import type { OasComponents } from '../components/Components.js';
|
|
3
|
+
import type { ComponentsEntry, OasComponents } from '../components/Components.js';
|
|
4
4
|
import type { OasOperation } from '../operation/Operation.js';
|
|
5
5
|
import type { OasWebhook } from '../webhook/Webhook.js';
|
|
6
6
|
import type { OasInfo } from '../info/Info.js';
|
|
7
7
|
import type { OasServer } from '../server/Server.js';
|
|
8
8
|
import type { OasSecurityRequirement } from '../securityRequirement/SecurityRequirement.js';
|
|
9
9
|
import type { StackTrail } from '../../context/StackTrail.js';
|
|
10
|
-
import type { OasSchema } from '../schema/Schema.js';
|
|
11
|
-
import type { OasRef } from '../ref/Ref.js';
|
|
12
10
|
import type { OasExternalDocs } from '../externalDocs/ExternalDocs.js';
|
|
13
11
|
/**
|
|
14
12
|
* Fields that define the structure of an OpenAPI v3 document.
|
|
@@ -179,10 +177,12 @@ export declare class OasDocument {
|
|
|
179
177
|
* Removes an item from the document based on a stack trail path.
|
|
180
178
|
*
|
|
181
179
|
* This method is used internally during document processing to remove
|
|
182
|
-
* specific operations or
|
|
183
|
-
* the path to the item within the document structure.
|
|
180
|
+
* specific operations, webhooks or components. The stack trail indicates
|
|
181
|
+
* the path to the item within the document structure. A
|
|
182
|
+
* `components:<bucket>:<name>` trail removes the entry from that bucket
|
|
183
|
+
* (`components:requestBodies:X` removes request body `X`, not schema `X`).
|
|
184
184
|
*
|
|
185
|
-
* @param stackTrail -
|
|
185
|
+
* @param stackTrail - Document-relative path to the item to remove
|
|
186
186
|
* @returns The removed item, or undefined if not found
|
|
187
187
|
*
|
|
188
188
|
* @internal This method is primarily used by the processing pipeline
|
|
@@ -196,7 +196,7 @@ export declare class OasDocument {
|
|
|
196
196
|
* const removedSchema = document.removeItem(new StackTrail(['components', 'schemas', 'User']));
|
|
197
197
|
* ```
|
|
198
198
|
*/
|
|
199
|
-
removeItem(stackTrail: StackTrail): OasOperation | OasWebhook |
|
|
199
|
+
removeItem(stackTrail: StackTrail): OasOperation | OasWebhook | ComponentsEntry | undefined;
|
|
200
200
|
/**
|
|
201
201
|
* Sets the document fields after parsing.
|
|
202
202
|
*
|
|
@@ -148,10 +148,12 @@ class OasDocument {
|
|
|
148
148
|
* Removes an item from the document based on a stack trail path.
|
|
149
149
|
*
|
|
150
150
|
* This method is used internally during document processing to remove
|
|
151
|
-
* specific operations or
|
|
152
|
-
* the path to the item within the document structure.
|
|
151
|
+
* specific operations, webhooks or components. The stack trail indicates
|
|
152
|
+
* the path to the item within the document structure. A
|
|
153
|
+
* `components:<bucket>:<name>` trail removes the entry from that bucket
|
|
154
|
+
* (`components:requestBodies:X` removes request body `X`, not schema `X`).
|
|
153
155
|
*
|
|
154
|
-
* @param stackTrail -
|
|
156
|
+
* @param stackTrail - Document-relative path to the item to remove
|
|
155
157
|
* @returns The removed item, or undefined if not found
|
|
156
158
|
*
|
|
157
159
|
* @internal This method is primarily used by the processing pipeline
|
|
@@ -192,7 +194,7 @@ class OasDocument {
|
|
|
192
194
|
if (typeof third !== 'string') {
|
|
193
195
|
throw new Error(`RefName cannot be a number: ${third}`);
|
|
194
196
|
}
|
|
195
|
-
return __classPrivateFieldGet(this, _OasDocument_fields, "f")
|
|
197
|
+
return __classPrivateFieldGet(this, _OasDocument_fields, "f")?.components?.removeEntry(second, third);
|
|
196
198
|
}
|
|
197
199
|
default:
|
|
198
200
|
throw new Error(`Unexpected stack trail: ${stackTrail}`);
|
|
@@ -35,6 +35,7 @@ export type ToPathParameterListArgs<Entry, Parameter> = {
|
|
|
35
35
|
index: number;
|
|
36
36
|
}) => Parameter[];
|
|
37
37
|
};
|
|
38
|
+
export declare const toNameAndIn: (parameter: unknown) => Pick<BrokenPathParameter, "name" | "in">;
|
|
38
39
|
/**
|
|
39
40
|
* Parses a path item's `parameters` without letting a throw escape. Each
|
|
40
41
|
* entry that fails logs one `INVALID_PARAMETER` error at its index and is
|
|
@@ -42,6 +43,18 @@ export type ToPathParameterListArgs<Entry, Parameter> = {
|
|
|
42
43
|
* The caller decides per operation which broken entries apply.
|
|
43
44
|
*/
|
|
44
45
|
export declare const toPathParameterList: <Entry, Parameter>({ parameters, stackTrail, context, toEntry }: ToPathParameterListArgs<Entry, Parameter>) => PathParameterList<Parameter>;
|
|
46
|
+
/**
|
|
47
|
+
* The first broken path-level parameter that applies to an operation. An
|
|
48
|
+
* entry applies unless it has a readable `name` and `in` and the
|
|
49
|
+
* operation's inline `parameters` hold the same pair, which overrides it.
|
|
50
|
+
* A `$ref` operation parameter cannot be resolved during parse, so it
|
|
51
|
+
* overrides nothing.
|
|
52
|
+
*/
|
|
53
|
+
export declare const toApplyingBrokenParameter: ({ broken, operation }: {
|
|
54
|
+
broken: BrokenPathParameter[];
|
|
55
|
+
/** The raw operation object. */
|
|
56
|
+
operation: unknown;
|
|
57
|
+
}) => BrokenPathParameter | undefined;
|
|
45
58
|
/**
|
|
46
59
|
* True when a broken path-level parameter applies to the operation. Logs
|
|
47
60
|
* one `INVALID_OPERATION` error at the operation that names the first
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDroppedByPathParameter = exports.toPathParameterList = exports.toParameterEntries = void 0;
|
|
3
|
+
exports.isDroppedByPathParameter = exports.toApplyingBrokenParameter = exports.toPathParameterList = exports.toNameAndIn = exports.toParameterEntries = void 0;
|
|
4
4
|
const emptyParameter_js_1 = require("./emptyParameter.js");
|
|
5
5
|
const documentTrail_js_1 = require("../context/documentTrail.js");
|
|
6
6
|
/**
|
|
@@ -40,6 +40,7 @@ const toNameAndIn = (parameter) => {
|
|
|
40
40
|
}
|
|
41
41
|
return {};
|
|
42
42
|
};
|
|
43
|
+
exports.toNameAndIn = toNameAndIn;
|
|
43
44
|
/**
|
|
44
45
|
* Parses a path item's `parameters` without letting a throw escape. Each
|
|
45
46
|
* entry that fails logs one `INVALID_PARAMETER` error at its index and is
|
|
@@ -85,7 +86,7 @@ const toPathParameterList = ({ parameters, stackTrail, context, toEntry }) => {
|
|
|
85
86
|
broken: [
|
|
86
87
|
{
|
|
87
88
|
...stackTrail.trace(`${index}`, st => logBroken(st, parameter, error)),
|
|
88
|
-
...toNameAndIn(parameter)
|
|
89
|
+
...(0, exports.toNameAndIn)(parameter)
|
|
89
90
|
}
|
|
90
91
|
]
|
|
91
92
|
};
|
|
@@ -115,20 +116,21 @@ const toApplyingBrokenParameter = ({ broken, operation }) => {
|
|
|
115
116
|
? operation.parameters
|
|
116
117
|
: [];
|
|
117
118
|
const overrides = new Set(operationParameters.flatMap((parameter) => {
|
|
118
|
-
const { name, in: parameterIn } = toNameAndIn(parameter);
|
|
119
|
+
const { name, in: parameterIn } = (0, exports.toNameAndIn)(parameter);
|
|
119
120
|
return name === undefined || parameterIn === undefined ? [] : [`${parameterIn}:${name}`];
|
|
120
121
|
}));
|
|
121
122
|
return broken.find(entry => entry.name === undefined ||
|
|
122
123
|
entry.in === undefined ||
|
|
123
124
|
!overrides.has(`${entry.in}:${entry.name}`));
|
|
124
125
|
};
|
|
126
|
+
exports.toApplyingBrokenParameter = toApplyingBrokenParameter;
|
|
125
127
|
/**
|
|
126
128
|
* True when a broken path-level parameter applies to the operation. Logs
|
|
127
129
|
* one `INVALID_OPERATION` error at the operation that names the first
|
|
128
130
|
* such entry.
|
|
129
131
|
*/
|
|
130
132
|
const isDroppedByPathParameter = ({ brokenParameters, operation, stackTrail, context }) => {
|
|
131
|
-
const broken = toApplyingBrokenParameter({ broken: brokenParameters, operation });
|
|
133
|
+
const broken = (0, exports.toApplyingBrokenParameter)({ broken: brokenParameters, operation });
|
|
132
134
|
if (!broken) {
|
|
133
135
|
return false;
|
|
134
136
|
}
|
|
@@ -6,6 +6,16 @@ const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toS
|
|
|
6
6
|
const toServerVariableV3_js_1 = require("../serverVariable/toServerVariableV3.js");
|
|
7
7
|
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
8
8
|
const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
9
|
+
if (!Array.isArray(servers)) {
|
|
10
|
+
context.logIssueNoKey({
|
|
11
|
+
level: 'error',
|
|
12
|
+
stackTrail,
|
|
13
|
+
parent: servers,
|
|
14
|
+
message: '"servers" must be an array; left out',
|
|
15
|
+
type: 'INVALID_OPERATION'
|
|
16
|
+
});
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
9
19
|
return servers.flatMap((server, index) => {
|
|
10
20
|
const parsed = (0, tryParseAt_js_1.tryParseAt)({
|
|
11
21
|
stackTrail,
|
|
@@ -25,7 +35,7 @@ const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
|
25
35
|
};
|
|
26
36
|
exports.toServersV3 = toServersV3;
|
|
27
37
|
const toOptionalServersV3 = ({ servers, stackTrail, context }) => {
|
|
28
|
-
if (
|
|
38
|
+
if (servers === undefined || servers === null) {
|
|
29
39
|
return undefined;
|
|
30
40
|
}
|
|
31
41
|
return (0, exports.toServersV3)({ servers, stackTrail, context });
|
|
@@ -6,6 +6,16 @@ const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toS
|
|
|
6
6
|
const toServerVariableV3_js_1 = require("../serverVariable/toServerVariableV3.js");
|
|
7
7
|
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
8
8
|
const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
9
|
+
if (!Array.isArray(servers)) {
|
|
10
|
+
context.logIssueNoKey({
|
|
11
|
+
level: 'error',
|
|
12
|
+
stackTrail,
|
|
13
|
+
parent: servers,
|
|
14
|
+
message: '"servers" must be an array; left out',
|
|
15
|
+
type: 'INVALID_OPERATION'
|
|
16
|
+
});
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
9
19
|
return servers.flatMap((server, index) => {
|
|
10
20
|
const parsed = (0, tryParseAt_js_1.tryParseAt)({
|
|
11
21
|
stackTrail,
|
|
@@ -25,7 +35,7 @@ const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
|
25
35
|
};
|
|
26
36
|
exports.toServersV3 = toServersV3;
|
|
27
37
|
const toOptionalServersV3 = ({ servers, stackTrail, context }) => {
|
|
28
|
-
if (
|
|
38
|
+
if (servers === undefined || servers === null) {
|
|
29
39
|
return undefined;
|
|
30
40
|
}
|
|
31
41
|
return (0, exports.toServersV3)({ servers, stackTrail, context });
|
|
@@ -6,6 +6,16 @@ const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toS
|
|
|
6
6
|
const toServerVariableV3_js_1 = require("../serverVariable/toServerVariableV3.js");
|
|
7
7
|
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
8
8
|
const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
9
|
+
if (!Array.isArray(servers)) {
|
|
10
|
+
context.logIssueNoKey({
|
|
11
|
+
level: 'error',
|
|
12
|
+
stackTrail,
|
|
13
|
+
parent: servers,
|
|
14
|
+
message: '"servers" must be an array; left out',
|
|
15
|
+
type: 'INVALID_OPERATION'
|
|
16
|
+
});
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
9
19
|
return servers.flatMap((server, index) => {
|
|
10
20
|
const parsed = (0, tryParseAt_js_1.tryParseAt)({
|
|
11
21
|
stackTrail,
|
|
@@ -25,7 +35,7 @@ const toServersV3 = ({ servers, stackTrail, context }) => {
|
|
|
25
35
|
};
|
|
26
36
|
exports.toServersV3 = toServersV3;
|
|
27
37
|
const toOptionalServersV3 = ({ servers, stackTrail, context }) => {
|
|
28
|
-
if (
|
|
38
|
+
if (servers === undefined || servers === null) {
|
|
29
39
|
return undefined;
|
|
30
40
|
}
|
|
31
41
|
return (0, exports.toServersV3)({ servers, stackTrail, context });
|