@mintlify/validation 0.1.309 → 0.1.311

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.
@@ -741,6 +741,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
741
741
  telemetry?: {
742
742
  enabled?: boolean | undefined;
743
743
  } | undefined;
744
+ cookies?: {
745
+ key?: string | undefined;
746
+ value?: string | undefined;
747
+ } | undefined;
744
748
  } | undefined;
745
749
  banner?: {
746
750
  content: string;
@@ -1011,6 +1015,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
1011
1015
  telemetry?: {
1012
1016
  enabled?: boolean | undefined;
1013
1017
  } | undefined;
1018
+ cookies?: {
1019
+ key?: string | undefined;
1020
+ value?: string | undefined;
1021
+ } | undefined;
1014
1022
  } | undefined;
1015
1023
  banner?: {
1016
1024
  content: string;
@@ -1281,6 +1289,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
1281
1289
  telemetry?: {
1282
1290
  enabled?: boolean | undefined;
1283
1291
  } | undefined;
1292
+ cookies?: {
1293
+ key?: string | undefined;
1294
+ value?: string | undefined;
1295
+ } | undefined;
1284
1296
  } | undefined;
1285
1297
  banner?: {
1286
1298
  content: string;
@@ -1551,6 +1563,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
1551
1563
  telemetry?: {
1552
1564
  enabled?: boolean | undefined;
1553
1565
  } | undefined;
1566
+ cookies?: {
1567
+ key?: string | undefined;
1568
+ value?: string | undefined;
1569
+ } | undefined;
1554
1570
  } | undefined;
1555
1571
  banner?: {
1556
1572
  content: string;
@@ -1821,6 +1837,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
1821
1837
  telemetry?: {
1822
1838
  enabled?: boolean | undefined;
1823
1839
  } | undefined;
1840
+ cookies?: {
1841
+ key?: string | undefined;
1842
+ value?: string | undefined;
1843
+ } | undefined;
1824
1844
  } | undefined;
1825
1845
  banner?: {
1826
1846
  content: string;
@@ -2094,6 +2114,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
2094
2114
  telemetry?: {
2095
2115
  enabled?: boolean | undefined;
2096
2116
  } | undefined;
2117
+ cookies?: {
2118
+ key?: string | undefined;
2119
+ value?: string | undefined;
2120
+ } | undefined;
2097
2121
  } | undefined;
2098
2122
  banner?: {
2099
2123
  content: string;
@@ -2364,6 +2388,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
2364
2388
  telemetry?: {
2365
2389
  enabled?: boolean | undefined;
2366
2390
  } | undefined;
2391
+ cookies?: {
2392
+ key?: string | undefined;
2393
+ value?: string | undefined;
2394
+ } | undefined;
2367
2395
  } | undefined;
2368
2396
  banner?: {
2369
2397
  content: string;
@@ -2634,6 +2662,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
2634
2662
  telemetry?: {
2635
2663
  enabled?: boolean | undefined;
2636
2664
  } | undefined;
2665
+ cookies?: {
2666
+ key?: string | undefined;
2667
+ value?: string | undefined;
2668
+ } | undefined;
2637
2669
  } | undefined;
2638
2670
  banner?: {
2639
2671
  content: string;
@@ -2904,6 +2936,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
2904
2936
  telemetry?: {
2905
2937
  enabled?: boolean | undefined;
2906
2938
  } | undefined;
2939
+ cookies?: {
2940
+ key?: string | undefined;
2941
+ value?: string | undefined;
2942
+ } | undefined;
2907
2943
  } | undefined;
2908
2944
  banner?: {
2909
2945
  content: string;
@@ -3174,6 +3210,10 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
3174
3210
  telemetry?: {
3175
3211
  enabled?: boolean | undefined;
3176
3212
  } | undefined;
3213
+ cookies?: {
3214
+ key?: string | undefined;
3215
+ value?: string | undefined;
3216
+ } | undefined;
3177
3217
  } | undefined;
3178
3218
  banner?: {
3179
3219
  content: string;
@@ -1,6 +1,7 @@
1
1
  import { OpenAPIV3_1 } from 'openapi-types';
2
2
  import { BaseConverter } from './BaseConverter.js';
3
3
  import type { ContentSchema, DataSchemaArray, Endpoint, ExampleSchema, HttpMethod, IncrementalDataSchemaArray, ParameterSections, ResponseSchema } from './types/endpoint.js';
4
+ import { EndpointLocation } from './types/endpoint.js';
4
5
  export declare abstract class BaseOpenApiToEndpointConverter<D extends DataSchemaArray | IncrementalDataSchemaArray> extends BaseConverter {
5
6
  readonly document: OpenAPIV3_1.Document;
6
7
  readonly path: string;
@@ -8,6 +9,7 @@ export declare abstract class BaseOpenApiToEndpointConverter<D extends DataSchem
8
9
  readonly safeParse: boolean;
9
10
  protected pathObject: OpenAPIV3_1.PathItemObject;
10
11
  protected operationObject: OpenAPIV3_1.OperationObject;
12
+ protected location: EndpointLocation;
11
13
  protected constructor(document: OpenAPIV3_1.Document, path: string, method: HttpMethod, safeParse?: boolean);
12
14
  protected convert(): Endpoint<D>;
13
15
  abstract convertParameters(): ParameterSections<D>;
@@ -6,6 +6,7 @@ import { SecurityConverter } from './SecurityConverter.js';
6
6
  import { ServersConverter } from './ServersConverter.js';
7
7
  import { InvalidSchemaError } from './errors.js';
8
8
  import { generateExampleFromSchema } from './generateExampleFromSchema.js';
9
+ import { EndpointLocation } from './types/endpoint.js';
9
10
  import { dereference } from './utils.js';
10
11
  export class BaseOpenApiToEndpointConverter extends BaseConverter {
11
12
  constructor(document, path, method, safeParse = false) {
@@ -14,18 +15,19 @@ export class BaseOpenApiToEndpointConverter extends BaseConverter {
14
15
  this.path = path;
15
16
  this.method = method;
16
17
  this.safeParse = safeParse;
17
- const paths = this.document.paths;
18
+ this.location = new EndpointLocation(document, path);
19
+ const paths = this.location.getEndpointPaths();
18
20
  if (paths === undefined) {
19
- throw new InvalidSchemaError(['#'], 'paths not defined');
21
+ throw new InvalidSchemaError(['#'], `${this.location.type} not defined`);
20
22
  }
21
- const pathObject = paths[this.path];
23
+ const pathObject = this.location.getEndpoint();
22
24
  if (pathObject === undefined) {
23
- throw new InvalidSchemaError(['#', 'paths'], `path not defined: ${this.path}`);
25
+ throw new InvalidSchemaError(['#', this.location.path], `${this.location.type} not defined: ${this.path}`);
24
26
  }
25
27
  this.pathObject = pathObject;
26
28
  const operationObject = pathObject[this.method];
27
29
  if (operationObject === undefined) {
28
- throw new InvalidSchemaError(['#', 'paths', this.path], `operation does not exist: ${this.method}`);
30
+ throw new InvalidSchemaError(['#', this.location.path, this.path], `operation does not exist: ${this.method}`);
29
31
  }
30
32
  this.operationObject = operationObject;
31
33
  }
@@ -41,7 +43,7 @@ export class BaseOpenApiToEndpointConverter extends BaseConverter {
41
43
  const description = (_e = this.operationObject.description) !== null && _e !== void 0 ? _e : this.pathObject.description;
42
44
  const body = this.convertBody();
43
45
  const deprecated = !!this.operationObject.deprecated;
44
- const codeSamples = this.convertCodeSamples(['#', 'paths', this.path, this.method], this.operationObject);
46
+ const codeSamples = this.convertCodeSamples(['#', this.location.path, this.path, this.method], this.operationObject);
45
47
  const response = this.convertResponses();
46
48
  return {
47
49
  title,
@@ -57,6 +59,7 @@ export class BaseOpenApiToEndpointConverter extends BaseConverter {
57
59
  },
58
60
  response,
59
61
  deprecated,
62
+ type: this.location.type,
60
63
  };
61
64
  }
62
65
  convertExamples(examples, example, schemaArray) {
@@ -120,7 +123,7 @@ export class BaseOpenApiToEndpointConverter extends BaseConverter {
120
123
  export class OpenApiToEndpointConverter extends BaseOpenApiToEndpointConverter {
121
124
  convertBody() {
122
125
  const requestBody = this.operationObject.requestBody;
123
- return this.convertContent(['#', 'paths', this.path, this.method, 'requestBody', 'content'], requestBody === null || requestBody === void 0 ? void 0 : requestBody.content, 'request', requestBody === null || requestBody === void 0 ? void 0 : requestBody.required, requestBody === null || requestBody === void 0 ? void 0 : requestBody.description);
126
+ return this.convertContent(['#', this.location.path, this.path, this.method, 'requestBody', 'content'], requestBody === null || requestBody === void 0 ? void 0 : requestBody.content, 'request', requestBody === null || requestBody === void 0 ? void 0 : requestBody.required, requestBody === null || requestBody === void 0 ? void 0 : requestBody.description);
124
127
  }
125
128
  convertResponses() {
126
129
  const responses = this.operationObject.responses;
@@ -128,7 +131,7 @@ export class OpenApiToEndpointConverter extends BaseOpenApiToEndpointConverter {
128
131
  return {};
129
132
  const newEntries = Object.entries(responses).map(([statusCode, response]) => [
130
133
  statusCode,
131
- this.convertContent(['#', 'paths', this.path, this.method, 'responses', statusCode, 'content'], response.content, 'response', undefined, response.description),
134
+ this.convertContent(['#', this.location.path, this.path, this.method, 'responses', statusCode, 'content'], response.content, 'response', undefined, response.description),
132
135
  ]);
133
136
  return Object.fromEntries(newEntries);
134
137
  }
@@ -153,7 +156,7 @@ export class OpenApiToEndpointConverter extends BaseOpenApiToEndpointConverter {
153
156
  convertParameters() {
154
157
  const pathParameters = this.pathObject.parameters;
155
158
  const operationParameters = this.operationObject.parameters;
156
- return ParametersConverter.convert(this.method, pathParameters, operationParameters, ['#', 'paths', this.path], this.safeParse);
159
+ return ParametersConverter.convert(this.method, pathParameters, operationParameters, ['#', this.location.path, this.path], this.safeParse);
157
160
  }
158
161
  static convert(spec, path, method, safeParse) {
159
162
  return new OpenApiToEndpointConverter(spec, path, method, safeParse).convert();
@@ -165,25 +168,28 @@ export class OpenApiToIncrementalEndpointConverter extends BaseOpenApiToEndpoint
165
168
  this.rawDocument = rawDocument;
166
169
  }
167
170
  convertParameters() {
168
- var _a, _b, _c, _d, _e;
169
- const pathParameters = (_b = (_a = this.rawDocument.paths) === null || _a === void 0 ? void 0 : _a[this.path]) === null || _b === void 0 ? void 0 : _b.parameters;
170
- const operationParameters = (_e = (_d = (_c = this.rawDocument.paths) === null || _c === void 0 ? void 0 : _c[this.path]) === null || _d === void 0 ? void 0 : _d[this.method]) === null || _e === void 0 ? void 0 : _e.parameters;
171
- return IncrementalParametersConverter.convert(this.rawDocument, this.method, pathParameters, operationParameters, ['#', 'paths', this.path], this.safeParse);
171
+ var _a;
172
+ const path = this.location.getEndpoint();
173
+ const pathParameters = path === null || path === void 0 ? void 0 : path.parameters;
174
+ const operationParameters = (_a = path === null || path === void 0 ? void 0 : path[this.method]) === null || _a === void 0 ? void 0 : _a.parameters;
175
+ return IncrementalParametersConverter.convert(this.rawDocument, this.method, pathParameters, operationParameters, ['#', this.location.path, this.path], this.safeParse);
172
176
  }
173
177
  convertBody() {
174
- var _a, _b, _c, _d;
175
- let rawRequestBody = (_c = (_b = (_a = this.rawDocument.paths) === null || _a === void 0 ? void 0 : _a[this.path]) === null || _b === void 0 ? void 0 : _b[this.method]) === null || _c === void 0 ? void 0 : _c.requestBody;
178
+ var _a, _b;
179
+ const path = this.location.getEndpoint();
180
+ let rawRequestBody = (_a = path === null || path === void 0 ? void 0 : path[this.method]) === null || _a === void 0 ? void 0 : _a.requestBody;
176
181
  if (rawRequestBody && '$ref' in rawRequestBody) {
177
- rawRequestBody = dereference('requestBodies', rawRequestBody.$ref, (_d = this.rawDocument.components) === null || _d === void 0 ? void 0 : _d.requestBodies);
182
+ rawRequestBody = dereference('requestBodies', rawRequestBody.$ref, (_b = this.rawDocument.components) === null || _b === void 0 ? void 0 : _b.requestBodies);
178
183
  }
179
184
  if (!rawRequestBody || '$ref' in rawRequestBody)
180
185
  return {};
181
186
  const requestBody = this.operationObject.requestBody;
182
- return this.convertContent(['#', 'paths', this.path, this.method, 'requestBody', 'content'], rawRequestBody.content, requestBody === null || requestBody === void 0 ? void 0 : requestBody.content, 'request', requestBody === null || requestBody === void 0 ? void 0 : requestBody.required, requestBody === null || requestBody === void 0 ? void 0 : requestBody.description);
187
+ return this.convertContent(['#', this.location.path, this.path, this.method, 'requestBody', 'content'], rawRequestBody.content, requestBody === null || requestBody === void 0 ? void 0 : requestBody.content, 'request', requestBody === null || requestBody === void 0 ? void 0 : requestBody.required, requestBody === null || requestBody === void 0 ? void 0 : requestBody.description);
183
188
  }
184
189
  convertResponses() {
185
- var _a, _b, _c;
186
- const rawResponses = (_c = (_b = (_a = this.rawDocument.paths) === null || _a === void 0 ? void 0 : _a[this.path]) === null || _b === void 0 ? void 0 : _b[this.method]) === null || _c === void 0 ? void 0 : _c.responses;
190
+ var _a;
191
+ const path = this.location.getEndpoint();
192
+ const rawResponses = (_a = path === null || path === void 0 ? void 0 : path[this.method]) === null || _a === void 0 ? void 0 : _a.responses;
187
193
  if (!rawResponses)
188
194
  return {};
189
195
  const newEntries = Object.entries(rawResponses).map(([statusCode, rawResponse]) => {
@@ -197,19 +203,27 @@ export class OpenApiToIncrementalEndpointConverter extends BaseOpenApiToEndpoint
197
203
  const response = (_b = this.operationObject.responses) === null || _b === void 0 ? void 0 : _b[statusCode];
198
204
  return [
199
205
  statusCode,
200
- this.convertContent(['#', 'paths', this.path, this.method, 'responses', statusCode, 'content'], rawResponse.content, response === null || response === void 0 ? void 0 : response.content, 'response', undefined, response === null || response === void 0 ? void 0 : response.description),
206
+ this.convertContent(['#', this.location.path, this.path, this.method, 'responses', statusCode, 'content'], rawResponse.content, response === null || response === void 0 ? void 0 : response.content, 'response', undefined, response === null || response === void 0 ? void 0 : response.description),
201
207
  ];
202
208
  });
203
209
  return Object.fromEntries(newEntries);
204
210
  }
205
211
  convertContent(debugPath, rawContent, dereferencedContent, location, required, description) {
206
212
  if (!rawContent || !dereferencedContent) {
213
+ if (description) {
214
+ return {
215
+ '_mintlify/placeholder': {
216
+ schemaArray: [{ type: 'any', description }],
217
+ examples: {},
218
+ description,
219
+ },
220
+ };
221
+ }
207
222
  return {};
208
223
  }
209
224
  const newEntries = Object.entries(rawContent).map(([contentType, mediaObject]) => {
210
225
  var _a;
211
226
  const incrementalSchemaArray = generateFirstIncrementalSchema(mediaObject.schema, (_a = this.rawDocument.components) === null || _a === void 0 ? void 0 : _a.schemas, required, location, contentType);
212
- // still need to generate schemaArray so we can generate examples
213
227
  const dereferencedMediaObject = dereferencedContent[contentType];
214
228
  const schemaArray = SchemaConverter.convert({
215
229
  schema: dereferencedMediaObject === null || dereferencedMediaObject === void 0 ? void 0 : dereferencedMediaObject.schema,
@@ -1,4 +1,5 @@
1
- import { OpenAPIV3_1 } from 'openapi-types';
1
+ import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
2
+ export type DocumentV3 = OpenAPIV3.Document | OpenAPIV3_1.Document;
2
3
  export type Endpoint<D extends DataSchemaArray | IncrementalDataSchemaArray = DataSchemaArray | IncrementalDataSchemaArray> = {
3
4
  title?: string;
4
5
  description?: string;
@@ -8,7 +9,18 @@ export type Endpoint<D extends DataSchemaArray | IncrementalDataSchemaArray = Da
8
9
  request: RequestSchema<D>;
9
10
  response: ResponseSchema<D>;
10
11
  deprecated: boolean;
11
- };
12
+ type?: EndpointType;
13
+ };
14
+ export type EndpointType = 'path' | 'webhook';
15
+ export declare class EndpointLocation {
16
+ readonly type: EndpointType;
17
+ readonly path: 'paths' | 'webhooks';
18
+ readonly endpointPath: string;
19
+ readonly document: OpenAPIV3_1.Document;
20
+ constructor(document: OpenAPIV3_1.Document, path: string);
21
+ getEndpointPaths(): OpenAPIV3_1.PathItemObject | undefined;
22
+ getEndpoint(): OpenAPIV3_1.PathItemObject | undefined;
23
+ }
12
24
  export type Server = {
13
25
  url: string;
14
26
  description?: string;
@@ -1,3 +1,19 @@
1
+ export class EndpointLocation {
2
+ constructor(document, path) {
3
+ var _a;
4
+ this.document = document;
5
+ this.endpointPath = path;
6
+ this.path = ((_a = document.webhooks) === null || _a === void 0 ? void 0 : _a[path]) ? 'webhooks' : 'paths';
7
+ this.type = this.path.slice(0, -1);
8
+ }
9
+ getEndpointPaths() {
10
+ return this.document[this.path];
11
+ }
12
+ getEndpoint() {
13
+ var _a;
14
+ return (_a = this.document[this.path]) === null || _a === void 0 ? void 0 : _a[this.endpointPath];
15
+ }
16
+ }
1
17
  // Request types
2
18
  export const httpMethods = [
3
19
  'get',