@mintlify/validation 0.1.59 → 0.1.60
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.ts +5 -6
- package/dist/index.js +17 -41
- package/dist/mint-config/common.js +1 -4
- package/dist/mint-config/flattenUnionErrorMessages.js +1 -5
- package/dist/mint-config/hexadecimalPattern.js +1 -4
- package/dist/mint-config/schemas/analytics.d.ts +0 -104
- package/dist/mint-config/schemas/analytics.js +28 -31
- package/dist/mint-config/schemas/anchorColors.d.ts +0 -1
- package/dist/mint-config/schemas/anchorColors.js +13 -16
- package/dist/mint-config/schemas/anchors.d.ts +7 -56
- package/dist/mint-config/schemas/anchors.js +17 -20
- package/dist/mint-config/schemas/apiReference.d.ts +0 -2
- package/dist/mint-config/schemas/apiReference.js +18 -21
- package/dist/mint-config/schemas/basics.d.ts +0 -11
- package/dist/mint-config/schemas/basics.js +37 -50
- package/dist/mint-config/schemas/colors.d.ts +0 -1
- package/dist/mint-config/schemas/colors.js +18 -21
- package/dist/mint-config/schemas/config.d.ts +13 -14
- package/dist/mint-config/schemas/config.js +38 -41
- package/dist/mint-config/schemas/favicon.js +2 -5
- package/dist/mint-config/schemas/integrations.d.ts +0 -6
- package/dist/mint-config/schemas/integrations.js +4 -7
- package/dist/mint-config/schemas/navigation.d.ts +15 -2
- package/dist/mint-config/schemas/navigation.js +22 -22
- package/dist/mint-config/schemas/tabs.d.ts +0 -13
- package/dist/mint-config/schemas/tabs.js +7 -10
- package/dist/mint-config/schemas/versions.d.ts +0 -13
- package/dist/mint-config/schemas/versions.js +7 -10
- package/dist/mint-config/validateAnchorsWarnings.d.ts +3 -4
- package/dist/mint-config/validateAnchorsWarnings.js +5 -9
- package/dist/mint-config/validateVersionsInNavigation.d.ts +4 -5
- package/dist/mint-config/validateVersionsInNavigation.js +6 -11
- package/dist/openapi/convertOpenApi.d.ts +1 -1
- package/dist/openapi/convertOpenApi.js +23 -31
- package/dist/openapi/convertParameters.d.ts +1 -1
- package/dist/openapi/convertParameters.js +11 -15
- package/dist/openapi/convertSchema.d.ts +1 -1
- package/dist/openapi/convertSchema.js +61 -72
- package/dist/openapi/convertSecurity.d.ts +1 -1
- package/dist/openapi/convertSecurity.js +8 -13
- package/dist/openapi/convertServers.d.ts +1 -1
- package/dist/openapi/convertServers.js +1 -5
- package/dist/openapi/types/endpoint.js +1 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +17 -10
- package/dist/mint-config/types/enums.d.ts +0 -4
- package/dist/mint-config/types/enums.js +0 -4
- package/dist/mint-config/types/index.d.ts +0 -12
- package/dist/mint-config/types/index.js +0 -2
- package/dist/mint-config/types/navigation.d.ts +0 -13
- package/dist/mint-config/types/navigation.js +0 -2
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
declare const tabSchema: z.ZodObject<{
|
|
3
|
-
name: z.ZodString;
|
|
4
|
-
url: z.ZodString;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
name: string;
|
|
7
|
-
url: string;
|
|
8
|
-
}, {
|
|
9
|
-
name: string;
|
|
10
|
-
url: string;
|
|
11
|
-
}>;
|
|
12
|
-
export type TabType = z.infer<typeof tabSchema>;
|
|
13
2
|
export declare const tabsSchema: z.ZodArray<z.ZodObject<{
|
|
14
3
|
name: z.ZodString;
|
|
15
4
|
url: z.ZodString;
|
|
@@ -27,5 +16,3 @@ export declare const primaryTabSchema: z.ZodObject<{
|
|
|
27
16
|
}, {
|
|
28
17
|
name: string;
|
|
29
18
|
}>;
|
|
30
|
-
export type PrimaryTabType = z.infer<typeof primaryTabSchema>;
|
|
31
|
-
export {};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var zod_1 = require("zod");
|
|
5
|
-
var tabSchema = zod_1.z.object({
|
|
6
|
-
name: zod_1.z
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
var tabSchema = z.object({
|
|
3
|
+
name: z
|
|
7
4
|
.string({
|
|
8
5
|
required_error: 'Every tab must have a name.',
|
|
9
6
|
invalid_type_error: 'Tab name must be a string.',
|
|
10
7
|
})
|
|
11
8
|
.trim()
|
|
12
9
|
.min(1, 'Tab name is empty.'),
|
|
13
|
-
url:
|
|
10
|
+
url: z
|
|
14
11
|
.string({
|
|
15
12
|
required_error: 'Every tab must have a url',
|
|
16
13
|
invalid_type_error: 'Tab url must be a string.',
|
|
@@ -18,10 +15,10 @@ var tabSchema = zod_1.z.object({
|
|
|
18
15
|
.trim()
|
|
19
16
|
.min(1, 'Tab URL is missing.'),
|
|
20
17
|
});
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
export var tabsSchema = tabSchema.array();
|
|
19
|
+
export var primaryTabSchema = z
|
|
23
20
|
.object({
|
|
24
|
-
name:
|
|
21
|
+
name: z.string({
|
|
25
22
|
required_error: 'primaryTab.name is missing, set it or delete the entire primaryTab property.',
|
|
26
23
|
invalid_type_error: 'primaryTab.name must be a string',
|
|
27
24
|
}),
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
declare const versionSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
3
|
-
name: z.ZodString;
|
|
4
|
-
url: z.ZodString;
|
|
5
|
-
}, "strict", z.ZodTypeAny, {
|
|
6
|
-
name: string;
|
|
7
|
-
url: string;
|
|
8
|
-
}, {
|
|
9
|
-
name: string;
|
|
10
|
-
url: string;
|
|
11
|
-
}>]>;
|
|
12
2
|
export declare const versionsSchema: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
13
3
|
name: z.ZodString;
|
|
14
4
|
url: z.ZodString;
|
|
@@ -19,6 +9,3 @@ export declare const versionsSchema: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodOb
|
|
|
19
9
|
name: string;
|
|
20
10
|
url: string;
|
|
21
11
|
}>]>, "many">;
|
|
22
|
-
export type VersionType = z.infer<typeof versionSchema>;
|
|
23
|
-
export type VersionsType = z.infer<typeof versionsSchema>;
|
|
24
|
-
export {};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var versionSchema = zod_1.z.union([
|
|
6
|
-
zod_1.z.string({ invalid_type_error: 'Versions must be an array of strings.' }),
|
|
7
|
-
zod_1.z
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
var versionSchema = z.union([
|
|
3
|
+
z.string({ invalid_type_error: 'Versions must be an array of strings.' }),
|
|
4
|
+
z
|
|
8
5
|
.object({
|
|
9
|
-
name:
|
|
10
|
-
url:
|
|
6
|
+
name: z.string().min(1, 'Name cannot be an empty string.'),
|
|
7
|
+
url: z.string().min(1, 'URL cannot be an empty string.'),
|
|
11
8
|
})
|
|
12
9
|
.strict('Object must contain name and url properties'),
|
|
13
10
|
]);
|
|
14
|
-
|
|
11
|
+
export var versionsSchema = z
|
|
15
12
|
.array(versionSchema)
|
|
16
13
|
.min(1, 'Versions array cannot be empty. Either delete the property or add strings to the array.');
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function validateAnchorsWarnings(anchors: AnchorsType | undefined, navigation: MintNavigation | undefined): MintValidationResults;
|
|
1
|
+
import { Anchor, Navigation } from '@mintlify/models';
|
|
2
|
+
import { MintValidationResults } from './common.js';
|
|
3
|
+
export declare function validateAnchorsWarnings(anchors: Anchor[] | undefined, navigation: Navigation | undefined): MintValidationResults;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var navigation_1 = require("./schemas/navigation");
|
|
6
|
-
function validateAnchorsWarnings(anchors, navigation) {
|
|
7
|
-
var results = new common_1.MintValidationResults();
|
|
1
|
+
import { MintValidationResults } from './common.js';
|
|
2
|
+
import { navigationSchema } from './schemas/navigation.js';
|
|
3
|
+
export function validateAnchorsWarnings(anchors, navigation) {
|
|
4
|
+
var results = new MintValidationResults();
|
|
8
5
|
if (anchors &&
|
|
9
6
|
Array.isArray(anchors) &&
|
|
10
7
|
navigation &&
|
|
11
|
-
|
|
8
|
+
navigationSchema.safeParse(navigation).success) {
|
|
12
9
|
anchors.forEach(function (anchor) {
|
|
13
10
|
if (!anchor.url.startsWith('mailto:') &&
|
|
14
11
|
!anchor.url.startsWith('http') &&
|
|
@@ -23,7 +20,6 @@ function validateAnchorsWarnings(anchors, navigation) {
|
|
|
23
20
|
}
|
|
24
21
|
return results;
|
|
25
22
|
}
|
|
26
|
-
exports.validateAnchorsWarnings = validateAnchorsWarnings;
|
|
27
23
|
function pageStartsWith(navEntry, prefix) {
|
|
28
24
|
if (typeof navEntry === 'string') {
|
|
29
25
|
return navEntry.startsWith(prefix);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function validateVersionsInNavigation(navigation: MintNavigationGroup[] | undefined, versions?: VersionsType | undefined): MintValidationResults;
|
|
1
|
+
import { VersionType, NavigationEntry, NavigationGroup } from '@mintlify/models';
|
|
2
|
+
import { MintValidationResults } from './common.js';
|
|
3
|
+
export declare function flattenNavigationVersions(nav: NavigationEntry[], versions?: string[]): string[];
|
|
4
|
+
export declare function validateVersionsInNavigation(navigation: NavigationGroup[] | undefined, versions?: VersionType[] | undefined): MintValidationResults;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var common_1 = require("./common");
|
|
5
|
-
var navigation_1 = require("./schemas/navigation");
|
|
6
|
-
function flattenNavigationVersions(nav, versions) {
|
|
1
|
+
import { MintValidationResults } from './common.js';
|
|
2
|
+
import { navigationSchema } from './schemas/navigation.js';
|
|
3
|
+
export function flattenNavigationVersions(nav, versions) {
|
|
7
4
|
if (versions === void 0) { versions = []; }
|
|
8
5
|
nav.forEach(function (val) {
|
|
9
6
|
if (val == null || typeof val === 'string') {
|
|
@@ -19,11 +16,10 @@ function flattenNavigationVersions(nav, versions) {
|
|
|
19
16
|
});
|
|
20
17
|
return versions;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
function validateVersionsInNavigation(navigation, versions) {
|
|
19
|
+
export function validateVersionsInNavigation(navigation, versions) {
|
|
24
20
|
if (versions === void 0) { versions = []; }
|
|
25
|
-
var results = new
|
|
26
|
-
if (navigation == null ||
|
|
21
|
+
var results = new MintValidationResults();
|
|
22
|
+
if (navigation == null || !navigationSchema.safeParse(navigation).success) {
|
|
27
23
|
return results;
|
|
28
24
|
}
|
|
29
25
|
var versionsFromNavigation = flattenNavigationVersions(navigation);
|
|
@@ -41,7 +37,6 @@ function validateVersionsInNavigation(navigation, versions) {
|
|
|
41
37
|
});
|
|
42
38
|
return results;
|
|
43
39
|
}
|
|
44
|
-
exports.validateVersionsInNavigation = validateVersionsInNavigation;
|
|
45
40
|
function warnVersionNesting(navigation, currentVersion) {
|
|
46
41
|
if (typeof navigation === 'string') {
|
|
47
42
|
return [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
-
import type { BodySchema, DataSchemaArray, Endpoint, HttpMethod, ResponseSchema } from './types/endpoint';
|
|
2
|
+
import type { BodySchema, DataSchemaArray, Endpoint, HttpMethod, ResponseSchema } from './types/endpoint.js';
|
|
3
3
|
export declare const generateMessage: (path: string[], messages?: string[]) => string;
|
|
4
4
|
export declare class InvalidSchemaError extends Error {
|
|
5
5
|
constructor(path: string[], ...messages: string[]);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __extends = (this && this.__extends) || (function () {
|
|
3
2
|
var extendStatics = function (d, b) {
|
|
4
3
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -23,20 +22,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
23
22
|
}
|
|
24
23
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
var convertServers_1 = require("./convertServers");
|
|
32
|
-
var generateMessage = function (path, messages) {
|
|
25
|
+
import { convertParameters } from './convertParameters.js';
|
|
26
|
+
import { convertSchema } from './convertSchema.js';
|
|
27
|
+
import { convertSecurity } from './convertSecurity.js';
|
|
28
|
+
import { convertServers } from './convertServers.js';
|
|
29
|
+
export var generateMessage = function (path, messages) {
|
|
33
30
|
if (messages === void 0) { messages = []; }
|
|
34
31
|
var pathString = path
|
|
35
32
|
.map(function (component) { return component.replace('\\', '\\\\').replace('/', '\\/'); })
|
|
36
33
|
.join('/');
|
|
37
34
|
return __spreadArray([pathString], messages, true).join('\n');
|
|
38
35
|
};
|
|
39
|
-
exports.generateMessage = generateMessage;
|
|
40
36
|
var InvalidSchemaError = /** @class */ (function (_super) {
|
|
41
37
|
__extends(InvalidSchemaError, _super);
|
|
42
38
|
function InvalidSchemaError(path) {
|
|
@@ -44,14 +40,14 @@ var InvalidSchemaError = /** @class */ (function (_super) {
|
|
|
44
40
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
45
41
|
messages[_i - 1] = arguments[_i];
|
|
46
42
|
}
|
|
47
|
-
var _this = _super.call(this,
|
|
43
|
+
var _this = _super.call(this, generateMessage(path, messages)) || this;
|
|
48
44
|
_this.name = 'InvalidSchemaError';
|
|
49
45
|
Object.setPrototypeOf(_this, InvalidSchemaError.prototype);
|
|
50
46
|
return _this;
|
|
51
47
|
}
|
|
52
48
|
return InvalidSchemaError;
|
|
53
49
|
}(Error));
|
|
54
|
-
|
|
50
|
+
export { InvalidSchemaError };
|
|
55
51
|
var ImpossibleSchemaError = /** @class */ (function (_super) {
|
|
56
52
|
__extends(ImpossibleSchemaError, _super);
|
|
57
53
|
function ImpossibleSchemaError(path) {
|
|
@@ -59,14 +55,14 @@ var ImpossibleSchemaError = /** @class */ (function (_super) {
|
|
|
59
55
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
60
56
|
messages[_i - 1] = arguments[_i];
|
|
61
57
|
}
|
|
62
|
-
var _this = _super.call(this,
|
|
58
|
+
var _this = _super.call(this, generateMessage(path, messages)) || this;
|
|
63
59
|
_this.name = 'ImpossibleSchemaError';
|
|
64
60
|
Object.setPrototypeOf(_this, ImpossibleSchemaError.prototype);
|
|
65
61
|
return _this;
|
|
66
62
|
}
|
|
67
63
|
return ImpossibleSchemaError;
|
|
68
64
|
}(Error));
|
|
69
|
-
|
|
65
|
+
export { ImpossibleSchemaError };
|
|
70
66
|
var ConversionError = /** @class */ (function (_super) {
|
|
71
67
|
__extends(ConversionError, _super);
|
|
72
68
|
function ConversionError(path) {
|
|
@@ -74,15 +70,15 @@ var ConversionError = /** @class */ (function (_super) {
|
|
|
74
70
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
75
71
|
messages[_i - 1] = arguments[_i];
|
|
76
72
|
}
|
|
77
|
-
var _this = _super.call(this,
|
|
73
|
+
var _this = _super.call(this, generateMessage(path, messages)) || this;
|
|
78
74
|
_this.name = 'ConversionError';
|
|
79
75
|
Object.setPrototypeOf(_this, ConversionError.prototype);
|
|
80
76
|
return _this;
|
|
81
77
|
}
|
|
82
78
|
return ConversionError;
|
|
83
79
|
}(Error));
|
|
84
|
-
|
|
85
|
-
var convertBody = function (path, body) {
|
|
80
|
+
export { ConversionError };
|
|
81
|
+
export var convertBody = function (path, body) {
|
|
86
82
|
if (body === undefined) {
|
|
87
83
|
return {};
|
|
88
84
|
}
|
|
@@ -90,24 +86,22 @@ var convertBody = function (path, body) {
|
|
|
90
86
|
var contentType = _a[0], mediaObject = _a[1];
|
|
91
87
|
return [
|
|
92
88
|
contentType,
|
|
93
|
-
|
|
89
|
+
convertSchema(__spreadArray(__spreadArray([], path, true), [contentType, 'schema'], false), mediaObject.schema, body.required),
|
|
94
90
|
];
|
|
95
91
|
});
|
|
96
92
|
return Object.fromEntries(newEntries);
|
|
97
93
|
};
|
|
98
|
-
|
|
99
|
-
var convertResponses = function (path, responses) {
|
|
94
|
+
export var convertResponses = function (path, responses) {
|
|
100
95
|
var newEntries = Object.entries(responses).map(function (_a) {
|
|
101
96
|
var statusCode = _a[0], response = _a[1];
|
|
102
97
|
return [
|
|
103
98
|
statusCode,
|
|
104
|
-
|
|
99
|
+
convertResponse(__spreadArray(__spreadArray([], path, true), [statusCode], false), response),
|
|
105
100
|
];
|
|
106
101
|
});
|
|
107
102
|
return Object.fromEntries(newEntries);
|
|
108
103
|
};
|
|
109
|
-
|
|
110
|
-
var convertResponse = function (path, response) {
|
|
104
|
+
export var convertResponse = function (path, response) {
|
|
111
105
|
if (response.content === undefined) {
|
|
112
106
|
return {};
|
|
113
107
|
}
|
|
@@ -115,13 +109,12 @@ var convertResponse = function (path, response) {
|
|
|
115
109
|
var contentType = _a[0], mediaType = _a[1];
|
|
116
110
|
return [
|
|
117
111
|
contentType,
|
|
118
|
-
|
|
112
|
+
convertSchema(__spreadArray(__spreadArray([], path, true), ['content', contentType, 'schema'], false), mediaType.schema),
|
|
119
113
|
];
|
|
120
114
|
});
|
|
121
115
|
return Object.fromEntries(newEntries);
|
|
122
116
|
};
|
|
123
|
-
|
|
124
|
-
var convertOpenAPIV3_1ToEndpoint = function (spec, path, method) {
|
|
117
|
+
export var convertOpenAPIV3_1ToEndpoint = function (spec, path, method) {
|
|
125
118
|
var _a, _b, _c, _d, _e;
|
|
126
119
|
var paths = spec.paths;
|
|
127
120
|
if (paths === undefined) {
|
|
@@ -137,26 +130,26 @@ var convertOpenAPIV3_1ToEndpoint = function (spec, path, method) {
|
|
|
137
130
|
}
|
|
138
131
|
var securityRequirements = (_a = operationObject.security) !== null && _a !== void 0 ? _a : spec.security;
|
|
139
132
|
var securitySchemes = (_b = spec.components) === null || _b === void 0 ? void 0 : _b.securitySchemes;
|
|
140
|
-
var security =
|
|
133
|
+
var security = convertSecurity({
|
|
141
134
|
securityRequirements: securityRequirements,
|
|
142
135
|
securitySchemes: securitySchemes,
|
|
143
136
|
});
|
|
144
137
|
var pathParameters = pathObject.parameters;
|
|
145
138
|
var operationParameters = operationObject.parameters;
|
|
146
|
-
var parameters =
|
|
139
|
+
var parameters = convertParameters({
|
|
147
140
|
path: ['#', 'paths', path],
|
|
148
141
|
method: method,
|
|
149
142
|
pathParameters: pathParameters,
|
|
150
143
|
operationParameters: operationParameters,
|
|
151
144
|
});
|
|
152
|
-
var servers =
|
|
145
|
+
var servers = convertServers({
|
|
153
146
|
servers: (_d = (_c = operationObject.servers) !== null && _c !== void 0 ? _c : pathObject.servers) !== null && _d !== void 0 ? _d : spec.servers,
|
|
154
147
|
});
|
|
155
148
|
var description = (_e = operationObject.description) !== null && _e !== void 0 ? _e : pathObject === null || pathObject === void 0 ? void 0 : pathObject.description;
|
|
156
149
|
var requestBody = operationObject.requestBody;
|
|
157
|
-
var body =
|
|
150
|
+
var body = convertBody(['#', 'paths', path, method, 'requestBody'], requestBody);
|
|
158
151
|
var deprecated = !!operationObject.deprecated;
|
|
159
|
-
var response =
|
|
152
|
+
var response = convertResponses(['#', 'paths', path, method, 'responses'], operationObject.responses);
|
|
160
153
|
return {
|
|
161
154
|
description: description,
|
|
162
155
|
path: path,
|
|
@@ -171,4 +164,3 @@ var convertOpenAPIV3_1ToEndpoint = function (spec, path, method) {
|
|
|
171
164
|
deprecated: deprecated,
|
|
172
165
|
};
|
|
173
166
|
};
|
|
174
|
-
exports.convertOpenAPIV3_1ToEndpoint = convertOpenAPIV3_1ToEndpoint;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
2
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
3
|
if (ar || !(i in from)) {
|
|
@@ -8,11 +7,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
8
7
|
}
|
|
9
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
var convertSchema_1 = require("./convertSchema");
|
|
15
|
-
var convertParameters = function (_a) {
|
|
10
|
+
import { InvalidSchemaError } from './convertOpenApi.js';
|
|
11
|
+
import { convertSchema, copyKeyIfDefined } from './convertSchema.js';
|
|
12
|
+
export var convertParameters = function (_a) {
|
|
16
13
|
var path = _a.path, method = _a.method, pathParameters = _a.pathParameters, operationParameters = _a.operationParameters;
|
|
17
14
|
var parameterSections = {
|
|
18
15
|
path: {},
|
|
@@ -36,29 +33,28 @@ var convertParameters = function (_a) {
|
|
|
36
33
|
});
|
|
37
34
|
return parameterSections;
|
|
38
35
|
};
|
|
39
|
-
exports.convertParameters = convertParameters;
|
|
40
36
|
var addParameter = function (_a) {
|
|
41
37
|
var path = _a.path, parameter = _a.parameter, parameterSections = _a.parameterSections;
|
|
42
38
|
if (!['path', 'header', 'query', 'cookie'].includes(parameter.in)) {
|
|
43
|
-
throw new
|
|
39
|
+
throw new InvalidSchemaError(path, "invalid parameter location: '".concat(parameter.in, "'"));
|
|
44
40
|
}
|
|
45
41
|
var location = parameter.in;
|
|
46
42
|
if (location === 'path') {
|
|
47
43
|
var newParameter = {
|
|
48
44
|
required: true,
|
|
49
|
-
schema:
|
|
45
|
+
schema: convertSchema(__spreadArray(__spreadArray([], path, true), ['schema'], false), parameter.schema, true),
|
|
50
46
|
};
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
copyKeyIfDefined('description', parameter, newParameter);
|
|
48
|
+
copyKeyIfDefined('deprecated', parameter, newParameter);
|
|
53
49
|
parameterSections.path[parameter.name] = newParameter;
|
|
54
50
|
}
|
|
55
51
|
else {
|
|
56
52
|
var newParameter = {
|
|
57
|
-
schema:
|
|
53
|
+
schema: convertSchema(__spreadArray(__spreadArray([], path, true), ['schema'], false), parameter.schema, true),
|
|
58
54
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
copyKeyIfDefined('description', parameter, newParameter);
|
|
56
|
+
copyKeyIfDefined('deprecated', parameter, newParameter);
|
|
57
|
+
copyKeyIfDefined('required', parameter, newParameter);
|
|
62
58
|
parameterSections[location][parameter.name] = newParameter;
|
|
63
59
|
}
|
|
64
60
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
-
import { DataSchemaArray } from './types/endpoint';
|
|
2
|
+
import { DataSchemaArray } from './types/endpoint.js';
|
|
3
3
|
export declare const convertSchema: (path: string[], schema: OpenAPIV3_1.SchemaObject | undefined, required?: boolean) => DataSchemaArray;
|
|
4
4
|
export declare const combineTopLevelSchemas: (path: string[], schema1: OpenAPIV3_1.SchemaObject, schema2: OpenAPIV3_1.SchemaObject) => OpenAPIV3_1.SchemaObject;
|
|
5
5
|
export declare const addKeyIfDefined: <D, K extends keyof D>(key: K, value: D[K], destination: D) => void;
|