swagger-client 3.24.5 → 3.25.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/dist/swagger-client.browser.js +5576 -16671
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +26 -31
- package/es/execute/oas3/build-request.js +8 -13
- package/es/execute/oas3/parameter-builders.js +20 -24
- package/es/execute/oas3/style-serializer.js +23 -28
- package/es/execute/swagger2/build-request.js +6 -7
- package/es/execute/swagger2/parameter-builders.js +24 -29
- package/es/helpers/each-operation.js +0 -2
- package/es/helpers/get-operation-raw.js +5 -6
- package/es/helpers/id-from-path-method/index.js +3 -4
- package/es/helpers/op-id.js +3 -5
- package/es/http/index.js +12 -28
- package/es/index.js +2 -4
- package/es/interfaces.js +33 -42
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +5 -9
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
- package/es/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
- package/es/resolver/strategies/generic/index.js +3 -4
- package/es/resolver/strategies/generic/normalize.js +0 -2
- package/es/resolver/strategies/openapi-2/index.js +6 -8
- package/es/resolver/strategies/openapi-3-0/index.js +6 -8
- package/es/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
- package/es/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
- package/es/resolver/utils/index.js +1 -2
- package/es/specmap/helpers.js +5 -6
- package/es/specmap/index.js +2 -10
- package/es/specmap/lib/create-error.js +1 -4
- package/es/subtree-resolver/index.js +2 -4
- package/lib/execute/index.js +26 -35
- package/lib/execute/oas3/build-request.js +8 -13
- package/lib/execute/oas3/parameter-builders.js +20 -24
- package/lib/execute/oas3/style-serializer.js +23 -27
- package/lib/execute/swagger2/build-request.js +6 -7
- package/lib/execute/swagger2/parameter-builders.js +24 -29
- package/lib/helpers/each-operation.js +0 -2
- package/lib/helpers/get-operation-raw.js +5 -6
- package/lib/helpers/id-from-path-method/index.js +3 -4
- package/lib/helpers/op-id.js +3 -7
- package/lib/http/index.js +12 -42
- package/lib/index.js +2 -8
- package/lib/interfaces.js +33 -50
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +5 -9
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
- package/lib/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
- package/lib/resolver/strategies/generic/index.js +3 -4
- package/lib/resolver/strategies/generic/normalize.js +0 -2
- package/lib/resolver/strategies/openapi-2/index.js +6 -8
- package/lib/resolver/strategies/openapi-3-0/index.js +6 -8
- package/lib/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
- package/lib/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
- package/lib/resolver/utils/index.js +1 -4
- package/lib/specmap/helpers.js +5 -6
- package/lib/specmap/index.js +2 -10
- package/lib/specmap/lib/create-error.js +1 -4
- package/lib/subtree-resolver/index.js +2 -8
- package/package.json +14 -12
package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js
CHANGED
|
@@ -17,15 +17,14 @@ const OpenApi3_1SwaggerClientDereferenceStrategy = OpenApi3_1DereferenceStrategy
|
|
|
17
17
|
mode: 'non-strict',
|
|
18
18
|
ancestors: null
|
|
19
19
|
},
|
|
20
|
-
init(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
|
+
init({
|
|
21
|
+
useCircularStructures = this.useCircularStructures,
|
|
22
|
+
allowMetaPatches = this.allowMetaPatches,
|
|
23
|
+
parameterMacro = this.parameterMacro,
|
|
24
|
+
modelPropertyMacro = this.modelPropertyMacro,
|
|
25
|
+
mode = this.mode,
|
|
26
|
+
ancestors = []
|
|
27
|
+
} = {}) {
|
|
29
28
|
this.name = 'openapi-3-1-swagger-client';
|
|
30
29
|
this.useCircularStructures = useCircularStructures;
|
|
31
30
|
this.allowMetaPatches = allowMetaPatches;
|
|
@@ -3,10 +3,9 @@ import { isSchemaElement, SchemaElement } from '@swagger-api/apidom-ns-openapi-3
|
|
|
3
3
|
import compose from '../utils/compose.js';
|
|
4
4
|
import toPath from '../utils/to-path.js';
|
|
5
5
|
const AllOfVisitor = compose({
|
|
6
|
-
init(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
6
|
+
init({
|
|
7
|
+
options
|
|
8
|
+
}) {
|
|
10
9
|
this.options = options;
|
|
11
10
|
},
|
|
12
11
|
props: {
|
|
@@ -30,12 +30,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
|
|
|
30
30
|
allowMetaPatches: false,
|
|
31
31
|
basePath: null
|
|
32
32
|
},
|
|
33
|
-
init(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} = _ref;
|
|
33
|
+
init({
|
|
34
|
+
allowMetaPatches = this.allowMetaPatches,
|
|
35
|
+
useCircularStructures = this.useCircularStructures,
|
|
36
|
+
basePath = this.basePath
|
|
37
|
+
}) {
|
|
39
38
|
this.allowMetaPatches = allowMetaPatches;
|
|
40
39
|
this.useCircularStructures = useCircularStructures;
|
|
41
40
|
this.basePath = basePath;
|
|
@@ -178,7 +177,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
|
|
|
178
177
|
} else if (Array.isArray(parent)) {
|
|
179
178
|
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
180
179
|
}
|
|
181
|
-
|
|
182
180
|
return false;
|
|
183
181
|
}
|
|
184
182
|
|
|
@@ -323,7 +321,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
|
|
|
323
321
|
} else if (Array.isArray(parent)) {
|
|
324
322
|
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
325
323
|
}
|
|
326
|
-
|
|
327
324
|
return false;
|
|
328
325
|
}
|
|
329
326
|
|
|
@@ -522,7 +519,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
|
|
|
522
519
|
} else if (Array.isArray(parent)) {
|
|
523
520
|
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
524
521
|
}
|
|
525
|
-
|
|
526
522
|
return false;
|
|
527
523
|
}
|
|
528
524
|
|
|
@@ -2,11 +2,10 @@ import { toValue } from '@swagger-api/apidom-core';
|
|
|
2
2
|
import compose from '../utils/compose.js';
|
|
3
3
|
import toPath from '../utils/to-path.js';
|
|
4
4
|
const ParameterMacroVisitor = compose({
|
|
5
|
-
init(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
5
|
+
init({
|
|
6
|
+
parameterMacro,
|
|
7
|
+
options
|
|
8
|
+
}) {
|
|
10
9
|
this.parameterMacro = parameterMacro;
|
|
11
10
|
this.options = options;
|
|
12
11
|
},
|
|
@@ -2,11 +2,10 @@ import { isObjectElement, toValue } from '@swagger-api/apidom-core';
|
|
|
2
2
|
import compose from '../utils/compose.js';
|
|
3
3
|
import toPath from '../utils/to-path.js';
|
|
4
4
|
const ModelPropertyMacroVisitor = compose({
|
|
5
|
-
init(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
5
|
+
init({
|
|
6
|
+
modelPropertyMacro,
|
|
7
|
+
options
|
|
8
|
+
}) {
|
|
10
9
|
this.modelPropertyMacro = modelPropertyMacro;
|
|
11
10
|
this.options = options;
|
|
12
11
|
},
|
|
@@ -8,10 +8,9 @@ const HttpResolverSwaggerClient = HttpResolver.compose({
|
|
|
8
8
|
swaggerHTTPClient: Http,
|
|
9
9
|
swaggerHTTPClientConfig: {}
|
|
10
10
|
},
|
|
11
|
-
init(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
|
+
init({
|
|
12
|
+
swaggerHTTPClient = this.swaggerHTTPClient
|
|
13
|
+
} = {}) {
|
|
15
14
|
this.swaggerHTTPClient = swaggerHTTPClient;
|
|
16
15
|
},
|
|
17
16
|
methods: {
|
|
@@ -17,7 +17,6 @@ export default function normalize(parsedSpec) {
|
|
|
17
17
|
if (path == null || !['object', 'function'].includes(typeof path)) {
|
|
18
18
|
continue; // eslint-disable-line no-continue
|
|
19
19
|
}
|
|
20
|
-
|
|
21
20
|
const pathParameters = path.parameters;
|
|
22
21
|
|
|
23
22
|
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
@@ -26,7 +25,6 @@ export default function normalize(parsedSpec) {
|
|
|
26
25
|
if (operation == null || !['object', 'function'].includes(typeof operation)) {
|
|
27
26
|
continue; // eslint-disable-line no-continue
|
|
28
27
|
}
|
|
29
|
-
|
|
30
28
|
const oid = opId(operation, pathName, method);
|
|
31
29
|
if (oid) {
|
|
32
30
|
if (map[oid]) {
|
|
@@ -4,16 +4,14 @@ import { isOpenAPI2 } from '../../../helpers/openapi-predicates.js';
|
|
|
4
4
|
export { clearCache } from '../generic/index.js';
|
|
5
5
|
const openApi2Strategy = {
|
|
6
6
|
name: 'openapi-2',
|
|
7
|
-
match(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = _ref;
|
|
7
|
+
match({
|
|
8
|
+
spec
|
|
9
|
+
}) {
|
|
11
10
|
return isOpenAPI2(spec);
|
|
12
11
|
},
|
|
13
|
-
normalize(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = _ref2;
|
|
12
|
+
normalize({
|
|
13
|
+
spec
|
|
14
|
+
}) {
|
|
17
15
|
const {
|
|
18
16
|
spec: normalized
|
|
19
17
|
} = normalize({
|
|
@@ -4,16 +4,14 @@ import { isOpenAPI30 } from '../../../helpers/openapi-predicates.js';
|
|
|
4
4
|
export { clearCache } from '../generic/index.js';
|
|
5
5
|
const openApi30Strategy = {
|
|
6
6
|
name: 'openapi-3-0',
|
|
7
|
-
match(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = _ref;
|
|
7
|
+
match({
|
|
8
|
+
spec
|
|
9
|
+
}) {
|
|
11
10
|
return isOpenAPI30(spec);
|
|
12
11
|
},
|
|
13
|
-
normalize(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = _ref2;
|
|
12
|
+
normalize({
|
|
13
|
+
spec
|
|
14
|
+
}) {
|
|
17
15
|
const {
|
|
18
16
|
spec: normalized
|
|
19
17
|
} = normalize({
|
|
@@ -3,16 +3,14 @@ import normalize, { pojoAdapter } from './normalize.js';
|
|
|
3
3
|
import { isOpenAPI31 } from '../../../helpers/openapi-predicates.js';
|
|
4
4
|
const openApi31ApiDOMStrategy = {
|
|
5
5
|
name: 'openapi-3-1-apidom',
|
|
6
|
-
match(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
6
|
+
match({
|
|
7
|
+
spec
|
|
8
|
+
}) {
|
|
10
9
|
return isOpenAPI31(spec);
|
|
11
10
|
},
|
|
12
|
-
normalize(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = _ref2;
|
|
11
|
+
normalize({
|
|
12
|
+
spec
|
|
13
|
+
}) {
|
|
16
14
|
return pojoAdapter(normalize)(spec);
|
|
17
15
|
},
|
|
18
16
|
async resolve(options) {
|
|
@@ -30,7 +30,7 @@ const normalize = element => {
|
|
|
30
30
|
*/
|
|
31
31
|
export const pojoAdapter = normalizeFn => spec => {
|
|
32
32
|
if (spec !== null && spec !== void 0 && spec.$$normalized) return spec;
|
|
33
|
-
if (pojoAdapter.cache.has(spec)) return spec;
|
|
33
|
+
if (pojoAdapter.cache.has(spec)) return pojoAdapter.cache.get(spec);
|
|
34
34
|
const openApiElement = OpenApi3_1Element.refract(spec);
|
|
35
35
|
const normalized = normalizeFn(openApiElement);
|
|
36
36
|
const value = toValue(normalized);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line import/prefer-default-export
|
|
4
|
-
export function makeFetchJSON(http) {
|
|
5
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4
|
+
export function makeFetchJSON(http, opts = {}) {
|
|
6
5
|
const {
|
|
7
6
|
requestInterceptor,
|
|
8
7
|
responseInterceptor
|
package/es/specmap/helpers.js
CHANGED
|
@@ -33,12 +33,11 @@ export function isFreelyNamed(parentPath) {
|
|
|
33
33
|
freelyNamedKeyParents.indexOf(parentKey) > -1 && nonFreelyNamedKeyGrandparents.indexOf(grandparentKey) === -1 || freelyNamedPaths.indexOf(parentStr) > -1 || freelyNamedAncestors.some(el => parentStr.indexOf(el) > -1)
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
export function generateAbsoluteRefPatches(obj, basePath
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
36
|
+
export function generateAbsoluteRefPatches(obj, basePath, {
|
|
37
|
+
specmap,
|
|
38
|
+
getBaseUrlForNodePath = path => specmap.getContext([...basePath, ...path]).baseDoc,
|
|
39
|
+
targetKeys = ['$ref', '$$ref']
|
|
40
|
+
} = {}) {
|
|
42
41
|
const patches = [];
|
|
43
42
|
traverse(obj).forEach(function callback() {
|
|
44
43
|
if (targetKeys.includes(this.key) && typeof this.node === 'string') {
|
package/es/specmap/index.js
CHANGED
|
@@ -48,24 +48,16 @@ class SpecMap {
|
|
|
48
48
|
this.patches.push(lib.context([], this.context));
|
|
49
49
|
this.updatePatches(this.patches);
|
|
50
50
|
}
|
|
51
|
-
debug(level) {
|
|
51
|
+
debug(level, ...args) {
|
|
52
52
|
if (this.debugLevel === level) {
|
|
53
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
54
|
-
args[_key - 1] = arguments[_key];
|
|
55
|
-
}
|
|
56
53
|
console.log(...args); // eslint-disable-line no-console
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
|
-
|
|
60
|
-
verbose(header) {
|
|
56
|
+
verbose(header, ...args) {
|
|
61
57
|
if (this.debugLevel === 'verbose') {
|
|
62
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
63
|
-
args[_key2 - 1] = arguments[_key2];
|
|
64
|
-
}
|
|
65
58
|
console.log(`[${header}] `, ...args); // eslint-disable-line no-console
|
|
66
59
|
}
|
|
67
60
|
}
|
|
68
|
-
|
|
69
61
|
wrapPlugin(plugin, name) {
|
|
70
62
|
const {
|
|
71
63
|
pathDiscriminator
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export default function createErrorType(name, init) {
|
|
2
|
-
function E() {
|
|
2
|
+
function E(...args) {
|
|
3
3
|
if (!Error.captureStackTrace) {
|
|
4
4
|
this.stack = new Error().stack;
|
|
5
5
|
} else {
|
|
6
6
|
Error.captureStackTrace(this, this.constructor);
|
|
7
7
|
}
|
|
8
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
|
-
args[_key] = arguments[_key];
|
|
10
|
-
}
|
|
11
8
|
[this.message] = args;
|
|
12
9
|
if (init) {
|
|
13
10
|
init.apply(this, args);
|
|
@@ -24,8 +24,7 @@ import resolve from '../resolver/index.js';
|
|
|
24
24
|
import genericResolverStrategy from '../resolver/strategies/generic/index.js';
|
|
25
25
|
import openApi2ResolverStrategy from '../resolver/strategies/openapi-2/index.js';
|
|
26
26
|
import openApi30ResolverStrategy from '../resolver/strategies/openapi-3-0/index.js';
|
|
27
|
-
const resolveSubtree = async
|
|
28
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
27
|
+
const resolveSubtree = async (obj, path, options = {}) => {
|
|
29
28
|
const {
|
|
30
29
|
returnEntireTree,
|
|
31
30
|
baseDoc,
|
|
@@ -60,8 +59,7 @@ const resolveSubtree = async function (obj, path) {
|
|
|
60
59
|
}
|
|
61
60
|
return result;
|
|
62
61
|
};
|
|
63
|
-
export const makeResolveSubtree = defaultOptions => async
|
|
64
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
62
|
+
export const makeResolveSubtree = defaultOptions => async (obj, path, options = {}) => {
|
|
65
63
|
const mergedOptions = {
|
|
66
64
|
...defaultOptions,
|
|
67
65
|
...options
|
package/lib/execute/index.js
CHANGED
|
@@ -78,19 +78,18 @@ const self = exports.self = {
|
|
|
78
78
|
|
|
79
79
|
// Execute request, with the given operationId and parameters
|
|
80
80
|
// pathName/method or operationId is optional
|
|
81
|
-
function execute(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
} = _ref;
|
|
81
|
+
function execute({
|
|
82
|
+
http: userHttp,
|
|
83
|
+
fetch,
|
|
84
|
+
// This is legacy
|
|
85
|
+
spec,
|
|
86
|
+
operationId,
|
|
87
|
+
pathName,
|
|
88
|
+
method,
|
|
89
|
+
parameters,
|
|
90
|
+
securities,
|
|
91
|
+
...extras
|
|
92
|
+
}) {
|
|
94
93
|
// Provide default fetch implementation
|
|
95
94
|
const http = userHttp || fetch || _index.default; // Default to _our_ http
|
|
96
95
|
|
|
@@ -293,16 +292,15 @@ function baseUrl(obj) {
|
|
|
293
292
|
return specIsOAS3 ? oas3BaseUrl(obj) : swagger2BaseUrl(obj);
|
|
294
293
|
}
|
|
295
294
|
const isNonEmptyServerList = value => Array.isArray(value) && value.length > 0;
|
|
296
|
-
function oas3BaseUrl(
|
|
295
|
+
function oas3BaseUrl({
|
|
296
|
+
spec,
|
|
297
|
+
pathName,
|
|
298
|
+
method,
|
|
299
|
+
server,
|
|
300
|
+
contextUrl,
|
|
301
|
+
serverVariables = {}
|
|
302
|
+
}) {
|
|
297
303
|
var _spec$paths, _spec$paths2;
|
|
298
|
-
let {
|
|
299
|
-
spec,
|
|
300
|
-
pathName,
|
|
301
|
-
method,
|
|
302
|
-
server,
|
|
303
|
-
contextUrl,
|
|
304
|
-
serverVariables = {}
|
|
305
|
-
} = _ref2;
|
|
306
304
|
let servers = [];
|
|
307
305
|
let selectedServerUrl = '';
|
|
308
306
|
let selectedServerObj;
|
|
@@ -341,13 +339,7 @@ function oas3BaseUrl(_ref2) {
|
|
|
341
339
|
}
|
|
342
340
|
return buildOas3UrlWithContext(selectedServerUrl, contextUrl);
|
|
343
341
|
}
|
|
344
|
-
function buildOas3UrlWithContext(ourUrl, contextUrl) {
|
|
345
|
-
if (ourUrl === void 0) {
|
|
346
|
-
ourUrl = '';
|
|
347
|
-
}
|
|
348
|
-
if (contextUrl === void 0) {
|
|
349
|
-
contextUrl = '';
|
|
350
|
-
}
|
|
342
|
+
function buildOas3UrlWithContext(ourUrl = '', contextUrl = '') {
|
|
351
343
|
// relative server url should be resolved against contextUrl
|
|
352
344
|
const parsedUrl = ourUrl && contextUrl ? parseURIReference(_empty.url.resolve(contextUrl, ourUrl)) : parseURIReference(ourUrl);
|
|
353
345
|
const parsedContextUrl = parseURIReference(contextUrl);
|
|
@@ -377,12 +369,11 @@ function getVariableTemplateNames(str) {
|
|
|
377
369
|
}
|
|
378
370
|
|
|
379
371
|
// Compose the baseUrl ( scheme + host + basePath )
|
|
380
|
-
function swagger2BaseUrl(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
} = _ref3;
|
|
372
|
+
function swagger2BaseUrl({
|
|
373
|
+
spec,
|
|
374
|
+
scheme,
|
|
375
|
+
contextUrl = ''
|
|
376
|
+
}) {
|
|
386
377
|
const parsedContextUrl = parseURIReference(contextUrl);
|
|
387
378
|
const firstSchemeInSpec = Array.isArray(spec.schemes) ? spec.schemes[0] : null;
|
|
388
379
|
const computedScheme = scheme || firstSchemeInSpec || stripNonAlpha(parsedContextUrl.protocol) || 'http';
|
|
@@ -47,14 +47,10 @@ function buildRequest(options, req) {
|
|
|
47
47
|
req.headers['Content-Type'] = requestContentType;
|
|
48
48
|
}
|
|
49
49
|
if (!options.responseContentType && operation.responses) {
|
|
50
|
-
const mediaTypes = Object.entries(operation.responses).filter(
|
|
51
|
-
let [key, value] = _ref;
|
|
50
|
+
const mediaTypes = Object.entries(operation.responses).filter(([key, value]) => {
|
|
52
51
|
const code = parseInt(key, 10);
|
|
53
52
|
return code >= 200 && code < 300 && (0, _isPlainObject.isPlainObject)(value.content);
|
|
54
|
-
}).reduce((acc,
|
|
55
|
-
let [, value] = _ref2;
|
|
56
|
-
return acc.concat(Object.keys(value.content));
|
|
57
|
-
}, []);
|
|
53
|
+
}).reduce((acc, [, value]) => acc.concat(Object.keys(value.content)), []);
|
|
58
54
|
if (mediaTypes.length > 0) {
|
|
59
55
|
req.headers.accept = mediaTypes.join(', ');
|
|
60
56
|
}
|
|
@@ -93,14 +89,13 @@ function buildRequest(options, req) {
|
|
|
93
89
|
|
|
94
90
|
// Add security values, to operations - that declare their need on them
|
|
95
91
|
// Adapted from the Swagger2 implementation
|
|
96
|
-
function applySecurities(
|
|
92
|
+
function applySecurities({
|
|
93
|
+
request,
|
|
94
|
+
securities = {},
|
|
95
|
+
operation = {},
|
|
96
|
+
spec
|
|
97
|
+
}) {
|
|
97
98
|
var _spec$components;
|
|
98
|
-
let {
|
|
99
|
-
request,
|
|
100
|
-
securities = {},
|
|
101
|
-
operation = {},
|
|
102
|
-
spec
|
|
103
|
-
} = _ref3;
|
|
104
99
|
const result = {
|
|
105
100
|
...request
|
|
106
101
|
};
|
|
@@ -9,12 +9,11 @@ exports.path = path;
|
|
|
9
9
|
exports.query = query;
|
|
10
10
|
var _styleSerializer = _interopRequireWildcard(require("./style-serializer.js"));
|
|
11
11
|
var _contentSerializer = _interopRequireDefault(require("./content-serializer.js"));
|
|
12
|
-
function path(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} = _ref;
|
|
12
|
+
function path({
|
|
13
|
+
req,
|
|
14
|
+
value,
|
|
15
|
+
parameter
|
|
16
|
+
}) {
|
|
18
17
|
const {
|
|
19
18
|
name,
|
|
20
19
|
style,
|
|
@@ -37,12 +36,11 @@ function path(_ref) {
|
|
|
37
36
|
});
|
|
38
37
|
req.url = req.url.split(`{${name}}`).join(styledValue);
|
|
39
38
|
}
|
|
40
|
-
function query(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} = _ref2;
|
|
39
|
+
function query({
|
|
40
|
+
req,
|
|
41
|
+
value,
|
|
42
|
+
parameter
|
|
43
|
+
}) {
|
|
46
44
|
req.query = req.query || {};
|
|
47
45
|
if (parameter.content) {
|
|
48
46
|
const effectiveMediaType = Object.keys(parameter.content)[0];
|
|
@@ -83,12 +81,11 @@ function query(_ref2) {
|
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
const PARAMETER_HEADER_BLACKLIST = ['accept', 'authorization', 'content-type'];
|
|
86
|
-
function header(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} = _ref3;
|
|
84
|
+
function header({
|
|
85
|
+
req,
|
|
86
|
+
parameter,
|
|
87
|
+
value
|
|
88
|
+
}) {
|
|
92
89
|
req.headers = req.headers || {};
|
|
93
90
|
if (PARAMETER_HEADER_BLACKLIST.indexOf(parameter.name.toLowerCase()) > -1) {
|
|
94
91
|
return;
|
|
@@ -108,12 +105,11 @@ function header(_ref3) {
|
|
|
108
105
|
});
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
|
-
function cookie(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
} = _ref4;
|
|
108
|
+
function cookie({
|
|
109
|
+
req,
|
|
110
|
+
parameter,
|
|
111
|
+
value
|
|
112
|
+
}) {
|
|
117
113
|
req.headers = req.headers || {};
|
|
118
114
|
const type = typeof value;
|
|
119
115
|
if (parameter.content) {
|
|
@@ -7,10 +7,9 @@ const isRfc3986Reserved = char => ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
|
|
|
7
7
|
const isRrc3986Unreserved = char => /^[a-z0-9\-._~]+$/i.test(char);
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line default-param-last
|
|
10
|
-
function encodeDisallowedCharacters(str,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = _temp === void 0 ? {} : _temp;
|
|
10
|
+
function encodeDisallowedCharacters(str, {
|
|
11
|
+
escape
|
|
12
|
+
} = {}, parse) {
|
|
14
13
|
if (typeof str === 'number') {
|
|
15
14
|
str = str.toString();
|
|
16
15
|
}
|
|
@@ -52,14 +51,13 @@ function stylize(config) {
|
|
|
52
51
|
}
|
|
53
52
|
return encodePrimitive(config);
|
|
54
53
|
}
|
|
55
|
-
function encodeArray(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} = _ref;
|
|
54
|
+
function encodeArray({
|
|
55
|
+
key,
|
|
56
|
+
value,
|
|
57
|
+
style,
|
|
58
|
+
explode,
|
|
59
|
+
escape
|
|
60
|
+
}) {
|
|
63
61
|
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
64
62
|
escape
|
|
65
63
|
});
|
|
@@ -91,14 +89,13 @@ function encodeArray(_ref) {
|
|
|
91
89
|
}
|
|
92
90
|
return undefined;
|
|
93
91
|
}
|
|
94
|
-
function encodeObject(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} = _ref2;
|
|
92
|
+
function encodeObject({
|
|
93
|
+
key,
|
|
94
|
+
value,
|
|
95
|
+
style,
|
|
96
|
+
explode,
|
|
97
|
+
escape
|
|
98
|
+
}) {
|
|
102
99
|
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
103
100
|
escape
|
|
104
101
|
});
|
|
@@ -144,13 +141,12 @@ function encodeObject(_ref2) {
|
|
|
144
141
|
}
|
|
145
142
|
return undefined;
|
|
146
143
|
}
|
|
147
|
-
function encodePrimitive(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
} = _ref3;
|
|
144
|
+
function encodePrimitive({
|
|
145
|
+
key,
|
|
146
|
+
value,
|
|
147
|
+
style,
|
|
148
|
+
escape
|
|
149
|
+
}) {
|
|
154
150
|
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
155
151
|
escape
|
|
156
152
|
});
|
|
@@ -50,13 +50,12 @@ function buildRequest(options, req) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Add security values, to operations - that declare their need on them
|
|
53
|
-
function applySecurities(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} = _ref;
|
|
53
|
+
function applySecurities({
|
|
54
|
+
request,
|
|
55
|
+
securities = {},
|
|
56
|
+
operation = {},
|
|
57
|
+
spec
|
|
58
|
+
}) {
|
|
60
59
|
const result = {
|
|
61
60
|
...request
|
|
62
61
|
};
|