@scalar/oas-utils 0.2.106 → 0.2.108

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/entities/cookie/cookie.d.ts +2 -2
  3. package/dist/entities/cookie/cookie.js +1 -1
  4. package/dist/entities/environment/environment.d.ts +2 -2
  5. package/dist/entities/environment/environment.js +1 -1
  6. package/dist/entities/shared/utility.d.ts +13 -1
  7. package/dist/entities/shared/utility.d.ts.map +1 -1
  8. package/dist/entities/shared/utility.js +4 -1
  9. package/dist/entities/spec/collection.d.ts +199 -155
  10. package/dist/entities/spec/collection.d.ts.map +1 -1
  11. package/dist/entities/spec/collection.js +15 -17
  12. package/dist/entities/spec/index.js +1 -1
  13. package/dist/entities/spec/operation.d.ts +34 -28
  14. package/dist/entities/spec/operation.d.ts.map +1 -1
  15. package/dist/entities/spec/parameters.d.ts +4 -4
  16. package/dist/entities/spec/request-examples.d.ts +5 -5
  17. package/dist/entities/spec/request-examples.d.ts.map +1 -1
  18. package/dist/entities/spec/request-examples.js +37 -71
  19. package/dist/entities/spec/requests.d.ts +54 -42
  20. package/dist/entities/spec/requests.d.ts.map +1 -1
  21. package/dist/entities/spec/requests.js +6 -18
  22. package/dist/entities/spec/security.d.ts +22 -22
  23. package/dist/entities/spec/security.d.ts.map +1 -1
  24. package/dist/entities/spec/security.js +7 -22
  25. package/dist/entities/spec/server.d.ts +2 -2
  26. package/dist/entities/spec/server.d.ts.map +1 -1
  27. package/dist/entities/spec/server.js +3 -5
  28. package/dist/entities/spec/spec-objects.d.ts +150 -78
  29. package/dist/entities/spec/spec-objects.d.ts.map +1 -1
  30. package/dist/entities/spec/spec-objects.js +68 -45
  31. package/dist/entities/spec/x-scalar-secrets.d.ts +4 -4
  32. package/dist/entities/spec/x-scalar-secrets.d.ts.map +1 -1
  33. package/dist/entities/workspace/workspace.d.ts +7 -7
  34. package/dist/entities/workspace/workspace.d.ts.map +1 -1
  35. package/dist/entities/workspace/workspace.js +5 -5
  36. package/dist/helpers/fetchSpecFromUrl.d.ts.map +1 -1
  37. package/dist/helpers/fetchSpecFromUrl.js +1 -1
  38. package/dist/helpers/fetchWithProxyFallback.d.ts.map +1 -1
  39. package/dist/helpers/findVariables.d.ts.map +1 -1
  40. package/dist/helpers/findVariables.js +1 -1
  41. package/dist/helpers/httpMethods.d.ts.map +1 -1
  42. package/dist/helpers/is-defined.d.ts.map +1 -1
  43. package/dist/helpers/iterateTitle.d.ts.map +1 -1
  44. package/dist/helpers/json2xml.d.ts.map +1 -1
  45. package/dist/helpers/json2xml.js +3 -7
  46. package/dist/helpers/makeUrlAbsolute.d.ts.map +1 -1
  47. package/dist/helpers/makeUrlAbsolute.js +1 -4
  48. package/dist/helpers/merge-urls.d.ts.map +1 -1
  49. package/dist/helpers/normalizeMimeTypeObject.d.ts +1 -0
  50. package/dist/helpers/normalizeMimeTypeObject.d.ts.map +1 -1
  51. package/dist/helpers/object.d.ts.map +1 -1
  52. package/dist/helpers/parse.d.ts.map +1 -1
  53. package/dist/helpers/prettyPrintJson.d.ts.map +1 -1
  54. package/dist/helpers/replaceVariables.d.ts.map +1 -1
  55. package/dist/helpers/replaceVariables.js +1 -3
  56. package/dist/helpers/ssrState.d.ts.map +1 -1
  57. package/dist/helpers/ssrState.js +1 -3
  58. package/dist/migrations/local-storage.d.ts.map +1 -1
  59. package/dist/migrations/migrator.d.ts +1 -1
  60. package/dist/migrations/migrator.d.ts.map +1 -1
  61. package/dist/migrations/semver.d.ts.map +1 -1
  62. package/dist/migrations/semver.js +1 -3
  63. package/dist/migrations/v-0.0.0/types.generated.d.ts.map +1 -1
  64. package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
  65. package/dist/migrations/v-2.1.0/migration.js +1 -4
  66. package/dist/migrations/v-2.1.0/types.generated.d.ts.map +1 -1
  67. package/dist/migrations/v-2.2.0/migration.d.ts.map +1 -1
  68. package/dist/migrations/v-2.2.0/migration.js +2 -4
  69. package/dist/migrations/v-2.2.0/types.generated.d.ts.map +1 -1
  70. package/dist/migrations/v-2.3.0/migration.d.ts.map +1 -1
  71. package/dist/migrations/v-2.3.0/migration.js +3 -8
  72. package/dist/migrations/v-2.3.0/types.generated.d.ts.map +1 -1
  73. package/dist/migrations/v-2.4.0/migration.d.ts.map +1 -1
  74. package/dist/migrations/v-2.4.0/types.generated.d.ts.map +1 -1
  75. package/dist/migrations/v-2.5.0/migration.d.ts +1 -1
  76. package/dist/migrations/v-2.5.0/migration.d.ts.map +1 -1
  77. package/dist/migrations/v-2.5.0/migration.js +70 -3
  78. package/dist/migrations/v-2.5.0/types.generated.d.ts +17 -17
  79. package/dist/migrations/v-2.5.0/types.generated.d.ts.map +1 -1
  80. package/dist/spec-getters/getExampleFromSchema.d.ts.map +1 -1
  81. package/dist/spec-getters/getExampleFromSchema.js +8 -22
  82. package/dist/spec-getters/getParametersFromOperation.d.ts.map +1 -1
  83. package/dist/spec-getters/getParametersFromOperation.js +1 -4
  84. package/dist/spec-getters/getRequestBodyFromOperation.d.ts.map +1 -1
  85. package/dist/spec-getters/getRequestBodyFromOperation.js +4 -9
  86. package/dist/spec-getters/getServerVariableExamples.js +3 -1
  87. package/dist/transforms/import-spec.d.ts +2 -1
  88. package/dist/transforms/import-spec.d.ts.map +1 -1
  89. package/dist/transforms/import-spec.js +13 -35
  90. package/dist/transforms/index.d.ts +0 -1
  91. package/dist/transforms/index.d.ts.map +1 -1
  92. package/dist/transforms/index.js +0 -1
  93. package/package.json +7 -7
  94. package/dist/transforms/export-spec.d.ts +0 -17
  95. package/dist/transforms/export-spec.d.ts.map +0 -1
  96. package/dist/transforms/export-spec.js +0 -73
@@ -1,108 +1,148 @@
1
1
  import { z } from 'zod';
2
2
  /**
3
+ * Removes undefined values from an object.
4
+ *
5
+ * Can be used as a transform function for any Zod schema.
6
+ */
7
+ export declare const omitUndefinedValues: <T extends object>(data: T) => T;
8
+ /**
9
+ * License Object
10
+ *
3
11
  * License information for the exposed API.
4
12
  *
5
- * @see https://spec.openapis.org/oas/latest.html#license-object
13
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#license-object
6
14
  */
7
- export declare const oasLicenseSchema: z.ZodObject<{
15
+ export declare const oasLicenseSchema: z.ZodEffects<z.ZodObject<{
8
16
  /** REQUIRED. The license name used for the API. */
9
- name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
17
+ name: z.ZodCatch<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
10
18
  /** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */
11
- identifier: z.ZodOptional<z.ZodString>;
19
+ identifier: z.ZodCatch<z.ZodOptional<z.ZodString>>;
12
20
  /**
13
- * A URL to the license used for the API. This MUST be in the form of a URL. The url field
14
- * is mutually exclusive of the identifier field.
21
+ * A URI for the license used for the API. This MUST be in the form of a URI. The url field is mutually exclusive of the identifier field.
15
22
  */
16
- url: z.ZodOptional<z.ZodString>;
23
+ url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
17
24
  }, "strip", z.ZodTypeAny, {
18
- name: string;
25
+ name?: string | null | undefined;
19
26
  identifier?: string | undefined;
20
27
  url?: string | undefined;
21
28
  }, {
22
- name?: string | undefined;
29
+ name?: unknown;
30
+ identifier?: unknown;
31
+ url?: unknown;
32
+ }>, {
33
+ name?: string | null | undefined;
23
34
  identifier?: string | undefined;
24
35
  url?: string | undefined;
36
+ }, {
37
+ name?: unknown;
38
+ identifier?: unknown;
39
+ url?: unknown;
25
40
  }>;
26
41
  /**
27
- * Contact
42
+ * Contact Object
43
+ *
28
44
  * Contact information for the exposed API.
29
45
  *
30
- * @see https://spec.openapis.org/oas/latest.html#contact-object
46
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#contact-object
31
47
  */
32
- export declare const oasContactSchema: z.ZodObject<{
48
+ export declare const oasContactSchema: z.ZodEffects<z.ZodObject<{
33
49
  /** The identifying name of the contact person/organization. */
34
50
  name: z.ZodOptional<z.ZodString>;
35
51
  /** The URL pointing to the contact information. This MUST be in the form of a URL. */
36
- url: z.ZodOptional<z.ZodString>;
52
+ url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
37
53
  /** The email address of the contact person/organization. This MUST be in the form of an email address. */
38
- email: z.ZodOptional<z.ZodString>;
54
+ email: z.ZodCatch<z.ZodOptional<z.ZodString>>;
39
55
  }, "strip", z.ZodTypeAny, {
40
56
  name?: string | undefined;
41
57
  url?: string | undefined;
42
58
  email?: string | undefined;
43
59
  }, {
60
+ name?: string | undefined;
61
+ url?: unknown;
62
+ email?: unknown;
63
+ }>, {
44
64
  name?: string | undefined;
45
65
  url?: string | undefined;
46
66
  email?: string | undefined;
67
+ }, {
68
+ name?: string | undefined;
69
+ url?: unknown;
70
+ email?: unknown;
47
71
  }>;
48
72
  /**
49
- * Info
73
+ * Info Object
74
+ *
50
75
  * The object provides metadata about the API. The metadata MAY be used by the clients if needed,
51
76
  * and MAY be presented in editing or documentation generation tools for convenience.
52
77
  *
53
- * @see https://spec.openapis.org/oas/latest.html#info-object
78
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#info-object
54
79
  */
55
- export declare const oasInfoSchema: z.ZodObject<{
80
+ export declare const oasInfoSchema: z.ZodEffects<z.ZodObject<{
56
81
  /** REQUIRED. The title of the API. */
57
- title: z.ZodDefault<z.ZodOptional<z.ZodString>>;
82
+ title: z.ZodCatch<z.ZodString>;
58
83
  /** A short summary of the API. */
59
- summary: z.ZodOptional<z.ZodString>;
84
+ summary: z.ZodCatch<z.ZodOptional<z.ZodString>>;
60
85
  /** A description of the API. CommonMark syntax MAY be used for rich text representation. */
61
- description: z.ZodOptional<z.ZodString>;
86
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
62
87
  /** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
63
- termsOfService: z.ZodOptional<z.ZodString>;
88
+ termsOfService: z.ZodCatch<z.ZodOptional<z.ZodString>>;
64
89
  /** The contact information for the exposed API. */
65
- contact: z.ZodOptional<z.ZodObject<{
90
+ contact: z.ZodCatch<z.ZodOptional<z.ZodEffects<z.ZodObject<{
66
91
  /** The identifying name of the contact person/organization. */
67
92
  name: z.ZodOptional<z.ZodString>;
68
93
  /** The URL pointing to the contact information. This MUST be in the form of a URL. */
69
- url: z.ZodOptional<z.ZodString>;
94
+ url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
70
95
  /** The email address of the contact person/organization. This MUST be in the form of an email address. */
71
- email: z.ZodOptional<z.ZodString>;
96
+ email: z.ZodCatch<z.ZodOptional<z.ZodString>>;
72
97
  }, "strip", z.ZodTypeAny, {
73
98
  name?: string | undefined;
74
99
  url?: string | undefined;
75
100
  email?: string | undefined;
76
101
  }, {
102
+ name?: string | undefined;
103
+ url?: unknown;
104
+ email?: unknown;
105
+ }>, {
77
106
  name?: string | undefined;
78
107
  url?: string | undefined;
79
108
  email?: string | undefined;
80
- }>>;
109
+ }, {
110
+ name?: string | undefined;
111
+ url?: unknown;
112
+ email?: unknown;
113
+ }>>>;
81
114
  /** The license information for the exposed API. */
82
- license: z.ZodOptional<z.ZodObject<{
115
+ license: z.ZodCatch<z.ZodOptional<z.ZodEffects<z.ZodObject<{
83
116
  /** REQUIRED. The license name used for the API. */
84
- name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
117
+ name: z.ZodCatch<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
85
118
  /** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */
86
- identifier: z.ZodOptional<z.ZodString>;
119
+ identifier: z.ZodCatch<z.ZodOptional<z.ZodString>>;
87
120
  /**
88
- * A URL to the license used for the API. This MUST be in the form of a URL. The url field
89
- * is mutually exclusive of the identifier field.
121
+ * A URI for the license used for the API. This MUST be in the form of a URI. The url field is mutually exclusive of the identifier field.
90
122
  */
91
- url: z.ZodOptional<z.ZodString>;
123
+ url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
92
124
  }, "strip", z.ZodTypeAny, {
93
- name: string;
125
+ name?: string | null | undefined;
94
126
  identifier?: string | undefined;
95
127
  url?: string | undefined;
96
128
  }, {
97
- name?: string | undefined;
129
+ name?: unknown;
130
+ identifier?: unknown;
131
+ url?: unknown;
132
+ }>, {
133
+ name?: string | null | undefined;
98
134
  identifier?: string | undefined;
99
135
  url?: string | undefined;
100
- }>>;
136
+ }, {
137
+ name?: unknown;
138
+ identifier?: unknown;
139
+ url?: unknown;
140
+ }>>>;
101
141
  /**
102
- * REQUIRED. The version of the OpenAPI document (which is distinct from the OpenAPI
103
- * Specification version or the API implementation version).
142
+ * REQUIRED. The version of the OpenAPI Document (which is distinct from the OpenAPI Specification version or the
143
+ * version of the API being described or the version of the OpenAPI Description).
104
144
  */
105
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
145
+ version: z.ZodCatch<z.ZodString>;
106
146
  }, "strip", z.ZodTypeAny, {
107
147
  title: string;
108
148
  version: string;
@@ -115,13 +155,22 @@ export declare const oasInfoSchema: z.ZodObject<{
115
155
  email?: string | undefined;
116
156
  } | undefined;
117
157
  license?: {
118
- name: string;
158
+ name?: string | null | undefined;
119
159
  identifier?: string | undefined;
120
160
  url?: string | undefined;
121
161
  } | undefined;
122
162
  }, {
163
+ description?: unknown;
164
+ title?: unknown;
165
+ summary?: unknown;
166
+ termsOfService?: unknown;
167
+ contact?: unknown;
168
+ license?: unknown;
169
+ version?: unknown;
170
+ }>, {
171
+ title: string;
172
+ version: string;
123
173
  description?: string | undefined;
124
- title?: string | undefined;
125
174
  summary?: string | undefined;
126
175
  termsOfService?: string | undefined;
127
176
  contact?: {
@@ -130,29 +179,43 @@ export declare const oasInfoSchema: z.ZodObject<{
130
179
  email?: string | undefined;
131
180
  } | undefined;
132
181
  license?: {
133
- name?: string | undefined;
182
+ name?: string | null | undefined;
134
183
  identifier?: string | undefined;
135
184
  url?: string | undefined;
136
185
  } | undefined;
137
- version?: string | undefined;
186
+ }, {
187
+ description?: unknown;
188
+ title?: unknown;
189
+ summary?: unknown;
190
+ termsOfService?: unknown;
191
+ contact?: unknown;
192
+ license?: unknown;
193
+ version?: unknown;
138
194
  }>;
139
195
  /**
140
- * External Documentation
196
+ * External Documentation Object
197
+ *
141
198
  * Allows referencing an external resource for extended documentation.
142
199
  *
143
- * @see https://spec.openapis.org/oas/latest.html#external-documentation-object
200
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#external-documentation-object
144
201
  */
145
- export declare const oasExternalDocumentationSchema: z.ZodObject<{
202
+ export declare const oasExternalDocumentationSchema: z.ZodEffects<z.ZodObject<{
146
203
  /** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
147
- description: z.ZodOptional<z.ZodString>;
204
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
148
205
  /** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
149
- url: z.ZodDefault<z.ZodString>;
206
+ url: z.ZodString;
150
207
  }, "strip", z.ZodTypeAny, {
151
208
  url: string;
152
209
  description?: string | undefined;
153
210
  }, {
211
+ url: string;
212
+ description?: unknown;
213
+ }>, {
214
+ url: string;
154
215
  description?: string | undefined;
155
- url?: string | undefined;
216
+ }, {
217
+ url: string;
218
+ description?: unknown;
156
219
  }>;
157
220
  export type ExternalDocumentation = z.infer<typeof oasExternalDocumentationSchema>;
158
221
  export declare const xScalarNestedSchema: z.ZodArray<z.ZodObject<{
@@ -163,35 +226,40 @@ export declare const xScalarNestedSchema: z.ZodArray<z.ZodObject<{
163
226
  tagName: string;
164
227
  }>, "many">;
165
228
  /**
166
- * Tag
167
- * Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag
168
- * Object per tag defined in the Operation Object instances.
229
+ * Tag Object
230
+ *
231
+ * Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag
232
+ * defined in the Operation Object instances.
169
233
  *
170
- * @see https://spec.openapis.org/oas/latest.html#tag-object
234
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#tag-object
171
235
  */
172
236
  export declare const oasTagSchema: z.ZodObject<{
173
237
  /**
174
- * @deprecated
175
- *
176
- * Needs to be remove as it is not a spec property
238
+ * @deprecated Needs to be remove as it is not a spec property
177
239
  */
178
240
  type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"tag">>>;
179
241
  /** REQUIRED. The name of the tag. */
180
242
  name: z.ZodString;
181
243
  /** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
182
- description: z.ZodOptional<z.ZodString>;
244
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
183
245
  /** Additional external documentation for this tag. */
184
- externalDocs: z.ZodOptional<z.ZodObject<{
246
+ externalDocs: z.ZodOptional<z.ZodEffects<z.ZodObject<{
185
247
  /** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
186
- description: z.ZodOptional<z.ZodString>;
248
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
187
249
  /** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
188
- url: z.ZodDefault<z.ZodString>;
250
+ url: z.ZodString;
189
251
  }, "strip", z.ZodTypeAny, {
190
252
  url: string;
191
253
  description?: string | undefined;
192
254
  }, {
255
+ url: string;
256
+ description?: unknown;
257
+ }>, {
258
+ url: string;
193
259
  description?: string | undefined;
194
- url?: string | undefined;
260
+ }, {
261
+ url: string;
262
+ description?: unknown;
195
263
  }>>;
196
264
  'x-scalar-children': z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
197
265
  tagName: z.ZodString;
@@ -219,10 +287,10 @@ export declare const oasTagSchema: z.ZodObject<{
219
287
  }, {
220
288
  name: string;
221
289
  type?: "tag" | undefined;
222
- description?: string | undefined;
290
+ description?: unknown;
223
291
  externalDocs?: {
224
- description?: string | undefined;
225
- url?: string | undefined;
292
+ url: string;
293
+ description?: unknown;
226
294
  } | undefined;
227
295
  'x-scalar-children'?: {
228
296
  tagName: string;
@@ -232,27 +300,31 @@ export declare const oasTagSchema: z.ZodObject<{
232
300
  }>;
233
301
  export declare const tagSchema: z.ZodObject<z.objectUtil.extendShape<{
234
302
  /**
235
- * @deprecated
236
- *
237
- * Needs to be remove as it is not a spec property
303
+ * @deprecated Needs to be remove as it is not a spec property
238
304
  */
239
305
  type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"tag">>>;
240
306
  /** REQUIRED. The name of the tag. */
241
307
  name: z.ZodString;
242
308
  /** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
243
- description: z.ZodOptional<z.ZodString>;
309
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
244
310
  /** Additional external documentation for this tag. */
245
- externalDocs: z.ZodOptional<z.ZodObject<{
311
+ externalDocs: z.ZodOptional<z.ZodEffects<z.ZodObject<{
246
312
  /** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
247
- description: z.ZodOptional<z.ZodString>;
313
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
248
314
  /** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
249
- url: z.ZodDefault<z.ZodString>;
315
+ url: z.ZodString;
250
316
  }, "strip", z.ZodTypeAny, {
251
317
  url: string;
252
318
  description?: string | undefined;
253
319
  }, {
320
+ url: string;
321
+ description?: unknown;
322
+ }>, {
323
+ url: string;
254
324
  description?: string | undefined;
255
- url?: string | undefined;
325
+ }, {
326
+ url: string;
327
+ description?: unknown;
256
328
  }>>;
257
329
  'x-scalar-children': z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
258
330
  tagName: z.ZodString;
@@ -265,13 +337,13 @@ export declare const tagSchema: z.ZodObject<z.objectUtil.extendShape<{
265
337
  'x-internal': z.ZodOptional<z.ZodBoolean>;
266
338
  'x-scalar-ignore': z.ZodOptional<z.ZodBoolean>;
267
339
  }, {
268
- uid: z.ZodDefault<z.ZodOptional<z.ZodString>>;
269
- children: z.ZodDefault<z.ZodArray<z.ZodDefault<z.ZodOptional<z.ZodString>>, "many">>;
340
+ uid: z.ZodBranded<z.ZodDefault<z.ZodOptional<z.ZodString>>, "tag">;
341
+ children: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodBranded<z.ZodString, "operation">, z.ZodBranded<z.ZodString, "tag">]>, "many">>;
270
342
  }>, "strip", z.ZodTypeAny, {
271
343
  type: "tag";
272
- uid: string;
344
+ uid: string & z.BRAND<"tag">;
273
345
  name: string;
274
- children: string[];
346
+ children: ((string & z.BRAND<"tag">) | (string & z.BRAND<"operation">))[];
275
347
  description?: string | undefined;
276
348
  externalDocs?: {
277
349
  url: string;
@@ -286,17 +358,17 @@ export declare const tagSchema: z.ZodObject<z.objectUtil.extendShape<{
286
358
  name: string;
287
359
  type?: "tag" | undefined;
288
360
  uid?: string | undefined;
289
- description?: string | undefined;
361
+ description?: unknown;
290
362
  externalDocs?: {
291
- description?: string | undefined;
292
- url?: string | undefined;
363
+ url: string;
364
+ description?: unknown;
293
365
  } | undefined;
294
366
  'x-scalar-children'?: {
295
367
  tagName: string;
296
368
  }[] | undefined;
297
369
  'x-internal'?: boolean | undefined;
298
370
  'x-scalar-ignore'?: boolean | undefined;
299
- children?: (string | undefined)[] | undefined;
371
+ children?: string[] | undefined;
300
372
  }>;
301
373
  export type Tag = z.infer<typeof tagSchema>;
302
374
  export type TagPayload = z.input<typeof tagSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"spec-objects.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/spec-objects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IAC3B,mDAAmD;;IAEnD,2GAA2G;;IAE3G;;;OAGG;;;;;;;;;;EAEH,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;IAC3B,+DAA+D;;IAE/D,sFAAsF;;IAEtF,0GAA0G;;;;;;;;;;EAE1G,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACx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;;IAEH,qCAAqC;;IAErC,6FAA6F;;IAE7F,sDAAsD;;QAjCpD,6GAA6G;;QAE7G,yFAAyF;;;;;;;;;;;;;;;;;;;;;;IAkC3F,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWvB,CAAA;AAEF,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAC3C,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA"}
@@ -1,97 +1,117 @@
1
- import { z } from 'zod';
2
1
  import { nanoidSchema } from '../shared/utility.js';
2
+ import { z } from 'zod';
3
3
 
4
4
  /**
5
+ * Removes undefined values from an object.
6
+ *
7
+ * Can be used as a transform function for any Zod schema.
8
+ */
9
+ const omitUndefinedValues = (data) => {
10
+ return Object.fromEntries(Object.entries(data).filter(([_, value]) => value !== undefined));
11
+ };
12
+ /**
13
+ * License Object
14
+ *
5
15
  * License information for the exposed API.
6
16
  *
7
- * @see https://spec.openapis.org/oas/latest.html#license-object
17
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#license-object
8
18
  */
9
- const oasLicenseSchema = z.object({
19
+ const oasLicenseSchema = z
20
+ .object({
10
21
  /** REQUIRED. The license name used for the API. */
11
- name: z.string().optional().default('name'),
22
+ name: z.string().optional().nullable().catch(null),
12
23
  /** An SPDX license expression for the API. The identifier field is mutually exclusive of the url field. */
13
- identifier: z.string().optional(),
24
+ identifier: z.string().optional().catch(undefined),
14
25
  /**
15
- * A URL to the license used for the API. This MUST be in the form of a URL. The url field
16
- * is mutually exclusive of the identifier field.
26
+ * A URI for the license used for the API. This MUST be in the form of a URI. The url field is mutually exclusive of the identifier field.
17
27
  */
18
- url: z.string().optional(),
19
- });
28
+ url: z.string().url().optional().catch(undefined),
29
+ })
30
+ .transform(omitUndefinedValues);
20
31
  /**
21
- * Contact
32
+ * Contact Object
33
+ *
22
34
  * Contact information for the exposed API.
23
35
  *
24
- * @see https://spec.openapis.org/oas/latest.html#contact-object
36
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#contact-object
25
37
  */
26
- const oasContactSchema = z.object({
38
+ const oasContactSchema = z
39
+ .object({
27
40
  /** The identifying name of the contact person/organization. */
28
41
  name: z.string().optional(),
29
42
  /** The URL pointing to the contact information. This MUST be in the form of a URL. */
30
- url: z.string().optional(),
43
+ url: z.string().url().optional().catch(undefined),
31
44
  /** The email address of the contact person/organization. This MUST be in the form of an email address. */
32
- email: z.string().email().optional(),
33
- });
45
+ email: z.string().optional().catch(undefined),
46
+ })
47
+ .transform(omitUndefinedValues);
34
48
  /**
35
- * Info
49
+ * Info Object
50
+ *
36
51
  * The object provides metadata about the API. The metadata MAY be used by the clients if needed,
37
52
  * and MAY be presented in editing or documentation generation tools for convenience.
38
53
  *
39
- * @see https://spec.openapis.org/oas/latest.html#info-object
54
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#info-object
40
55
  */
41
- const oasInfoSchema = z.object({
56
+ const oasInfoSchema = z
57
+ .object({
42
58
  /** REQUIRED. The title of the API. */
43
- title: z.string().optional().default('API'),
59
+ title: z.string().catch('API'),
44
60
  /** A short summary of the API. */
45
- summary: z.string().optional(),
61
+ summary: z.string().optional().catch(undefined),
46
62
  /** A description of the API. CommonMark syntax MAY be used for rich text representation. */
47
- description: z.string().optional(),
63
+ description: z.string().optional().catch(undefined),
48
64
  /** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
49
- termsOfService: z.string().optional(),
65
+ termsOfService: z.string().url().optional().catch(undefined),
50
66
  /** The contact information for the exposed API. */
51
- contact: oasContactSchema.optional(),
67
+ contact: oasContactSchema.optional().catch(undefined),
52
68
  /** The license information for the exposed API. */
53
- license: oasLicenseSchema.optional(),
69
+ license: oasLicenseSchema.optional().catch(undefined),
54
70
  /**
55
- * REQUIRED. The version of the OpenAPI document (which is distinct from the OpenAPI
56
- * Specification version or the API implementation version).
71
+ * REQUIRED. The version of the OpenAPI Document (which is distinct from the OpenAPI Specification version or the
72
+ * version of the API being described or the version of the OpenAPI Description).
57
73
  */
58
- version: z.string().optional().default('1.0'),
59
- });
74
+ version: z.string().catch('1.0'),
75
+ })
76
+ .transform(omitUndefinedValues);
60
77
  /**
61
- * External Documentation
78
+ * External Documentation Object
79
+ *
62
80
  * Allows referencing an external resource for extended documentation.
63
81
  *
64
- * @see https://spec.openapis.org/oas/latest.html#external-documentation-object
82
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#external-documentation-object
65
83
  */
66
- const oasExternalDocumentationSchema = z.object({
84
+ const oasExternalDocumentationSchema = z
85
+ .object({
67
86
  /** A description of the target documentation. CommonMark syntax MAY be used for rich text representation. */
68
- description: z.string().optional(),
87
+ description: z.string().optional().catch(undefined),
69
88
  /** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
70
- url: z.string().default(''),
71
- });
89
+ url: z.string(),
90
+ })
91
+ .transform(omitUndefinedValues);
72
92
  const xScalarNestedSchema = z
73
93
  .object({
74
94
  tagName: z.string(),
75
95
  })
76
96
  .array();
77
97
  /**
78
- * Tag
79
- * Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag
80
- * Object per tag defined in the Operation Object instances.
98
+ * Tag Object
99
+ *
100
+ * Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag
101
+ * defined in the Operation Object instances.
81
102
  *
82
- * @see https://spec.openapis.org/oas/latest.html#tag-object
103
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#tag-object
83
104
  */
84
105
  const oasTagSchema = z.object({
106
+ // TODO: Remove
85
107
  /**
86
- * @deprecated
87
- *
88
- * Needs to be remove as it is not a spec property
108
+ * @deprecated Needs to be remove as it is not a spec property
89
109
  */
90
110
  'type': z.literal('tag').optional().default('tag'),
91
111
  /** REQUIRED. The name of the tag. */
92
112
  'name': z.string(),
93
113
  /** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
94
- 'description': z.string().optional(),
114
+ 'description': z.string().optional().catch(undefined),
95
115
  /** Additional external documentation for this tag. */
96
116
  'externalDocs': oasExternalDocumentationSchema.optional(),
97
117
  'x-scalar-children': xScalarNestedSchema.default([]).optional(),
@@ -100,8 +120,11 @@ const oasTagSchema = z.object({
100
120
  'x-scalar-ignore': z.boolean().optional(),
101
121
  });
102
122
  const tagSchema = oasTagSchema.extend({
103
- uid: nanoidSchema,
104
- children: nanoidSchema.array().default([]),
123
+ uid: nanoidSchema.brand(),
124
+ children: z
125
+ .union([z.string().brand(), z.string().brand()])
126
+ .array()
127
+ .default([]),
105
128
  });
106
129
 
107
- export { oasContactSchema, oasExternalDocumentationSchema, oasInfoSchema, oasLicenseSchema, oasTagSchema, tagSchema, xScalarNestedSchema };
130
+ export { oasContactSchema, oasExternalDocumentationSchema, oasInfoSchema, oasLicenseSchema, oasTagSchema, omitUndefinedValues, tagSchema, xScalarNestedSchema };
@@ -3,21 +3,21 @@ export declare const xScalarSecretVarSchema: z.ZodObject<{
3
3
  description: z.ZodOptional<z.ZodString>;
4
4
  example: z.ZodOptional<z.ZodString>;
5
5
  }, "strip", z.ZodTypeAny, {
6
- description?: string | undefined;
7
6
  example?: string | undefined;
8
- }, {
9
7
  description?: string | undefined;
8
+ }, {
10
9
  example?: string | undefined;
10
+ description?: string | undefined;
11
11
  }>;
12
12
  export declare const xScalarSecretsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
13
13
  description: z.ZodOptional<z.ZodString>;
14
14
  example: z.ZodOptional<z.ZodString>;
15
15
  }, "strip", z.ZodTypeAny, {
16
- description?: string | undefined;
17
16
  example?: string | undefined;
18
- }, {
19
17
  description?: string | undefined;
18
+ }, {
20
19
  example?: string | undefined;
20
+ description?: string | undefined;
21
21
  }>>;
22
22
  export type XScalarSecrets = z.infer<typeof xScalarSecretsSchema>;
23
23
  //# sourceMappingURL=x-scalar-secrets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"x-scalar-secrets.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/x-scalar-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAA;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;GAA+C,CAAA;AAEhF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
1
+ {"version":3,"file":"x-scalar-secrets.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/x-scalar-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAA;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;GAA+C,CAAA;AAChF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}