@scalar/schemas 0.3.2 → 0.4.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/api-reference/api-reference-configuration.d.ts +18 -0
  3. package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
  4. package/dist/api-reference/api-reference-configuration.js +12 -0
  5. package/dist/api-reference/html-rendering-configuration.d.ts +7 -0
  6. package/dist/api-reference/html-rendering-configuration.d.ts.map +1 -1
  7. package/dist/api-reference/html-rendering-configuration.js +8 -1
  8. package/dist/asyncapi/3.1/asyncapi-object.d.ts +1 -1
  9. package/dist/asyncapi/3.1/channel.d.ts +14 -3
  10. package/dist/asyncapi/3.1/channel.d.ts.map +1 -1
  11. package/dist/asyncapi/3.1/channel.js +4 -4
  12. package/dist/asyncapi/3.1/components.d.ts +1 -1
  13. package/dist/asyncapi/3.1/components.js +2 -2
  14. package/dist/asyncapi/3.1/schema-payload.d.ts.map +1 -1
  15. package/dist/asyncapi/3.1/schema-payload.js +6 -8
  16. package/dist/extensions/document/x-scalar-sdk-installation.d.ts +0 -1
  17. package/dist/extensions/document/x-scalar-sdk-installation.d.ts.map +1 -1
  18. package/dist/extensions/document/x-scalar-sdk-installation.js +4 -5
  19. package/dist/extensions/operation/x-code-samples.d.ts +25 -0
  20. package/dist/extensions/operation/x-code-samples.d.ts.map +1 -1
  21. package/dist/extensions/operation/x-code-samples.js +33 -2
  22. package/dist/openapi/3.1/document.d.ts +0 -1
  23. package/dist/openapi/3.1/document.d.ts.map +1 -1
  24. package/dist/openapi/3.1/info.d.ts +0 -1
  25. package/dist/openapi/3.1/info.d.ts.map +1 -1
  26. package/dist/openapi/3.1/operation.d.ts +25 -0
  27. package/dist/openapi/3.1/operation.d.ts.map +1 -1
  28. package/dist/openapi/3.1/reference.js +1 -1
  29. package/dist/openapi/3.1/schema.d.ts.map +1 -1
  30. package/dist/openapi/3.1/schema.js +49 -17
  31. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @scalar/schemas
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#9398](https://github.com/scalar/scalar/pull/9398): feat: read code samples from x-readme, x-stainless and x-scalar extensions
8
+
9
+ In addition to `x-codeSamples`, the code sample picker now reads custom samples from `x-scalar-examples`, `x-stainless-snippets`, `x-stainless-examples`, and `x-readme.code-samples`. When more than one is present on an operation, the highest-priority source is used (x-scalar-examples > x-stainless-snippets > x-stainless-examples > x-readme > x-codeSamples).
10
+
11
+ - [#9422](https://github.com/scalar/scalar/pull/9422): Add a `nonce` option for Content Security Policy support.
12
+
13
+ When you pass a `nonce`, the rendered HTML stamps it onto the inline `<script>` and the CDN `<script>` tag (and Scalar's own `<style>` tags, plus a matching `<meta property="csp-nonce">`). This lets the API Reference run under a strict `script-src` with no `unsafe-inline` and no `unsafe-eval`.
14
+
15
+ ```ts
16
+ ApiReference({
17
+ url: '/openapi.json',
18
+ // Match this value in your `script-src` CSP directive.
19
+ nonce: 'r4nd0m',
20
+ })
21
+ ```
22
+
23
+ Note: `style-src` still needs `'unsafe-inline'`. The reference renders inline `style="…"` attributes, which a CSP nonce can never authorize (nonces only apply to `<script>`, `<style>` and `<link>` elements), so a nonce-only `style-src` is not possible. The win is a fully strict `script-src`.
24
+
25
+ - [#9400](https://github.com/scalar/scalar/pull/9400): feat(api-reference): add `expandAllSchemaProperties` config option.
26
+
27
+ When enabled, nested schema properties are expanded by default while keeping the
28
+ "Show/Hide Child Attributes" button available for manual collapsing. Expansion
29
+ is cycle-safe: every finite branch is expanded fully, and self-referential
30
+ ($ref or inline) schemas stop at the point they would otherwise recurse forever.
31
+
32
+ - [#9399](https://github.com/scalar/scalar/pull/9399): Show custom SDK installation instructions from `x-scalar-sdk-installation` in the introduction card, falling back to the client selector when there are none. Each entry takes a `lang` and a Markdown `description`, so a single tab can render rich instructions with syntax-highlighted code blocks (for example Maven and Gradle for Java)
33
+
34
+ ## 0.3.3
35
+
36
+ ### Patch Changes
37
+
38
+ - [#9309](https://github.com/scalar/scalar/pull/9309): feat: add `modelsSectionLabel` configuration (`'Models' | 'Schemas' | string`) to use OpenAPI-style Schemas terminology in the sidebar, content, and search.
39
+ - [#9383](https://github.com/scalar/scalar/pull/9383): fix: preserve multi-type schema arrays when coercing schemas with validation keywords
40
+ - [#7618](https://github.com/scalar/scalar/pull/7618): feat(api-reference): add `setPageTitle` to customize the browser tab title
41
+
42
+ Pass a `setPageTitle` function to control the browser tab title. It is called whenever the section in view changes — on sidebar clicks, on scroll, and when switching documents — and receives the section title and the active OpenAPI document:
43
+
44
+ ```js
45
+ setPageTitle: ({ title, document }) => `${document.title} – ${title}`
46
+ ```
47
+
3
48
  ## 0.3.2
4
49
 
5
50
  ### Patch Changes
@@ -71,6 +71,7 @@ export declare const apiReferenceConfigurationSchema: import("@scalar/validation
71
71
  isEditable: import("@scalar/validation").BooleanSchema;
72
72
  isLoading: import("@scalar/validation").BooleanSchema;
73
73
  hideModels: import("@scalar/validation").BooleanSchema;
74
+ modelsSectionLabel: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").LiteralSchema<"Models">, import("@scalar/validation").LiteralSchema<"Schemas">, import("@scalar/validation").StringSchema]>>;
74
75
  documentDownloadType: import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").LiteralSchema<"both">, import("@scalar/validation").LiteralSchema<"yaml">, import("@scalar/validation").LiteralSchema<"json">, import("@scalar/validation").LiteralSchema<"direct">, import("@scalar/validation").LiteralSchema<"none">]>;
75
76
  hideDownloadButton: import("@scalar/validation").OptionalSchema<import("@scalar/validation").BooleanSchema>;
76
77
  hideTestRequestButton: import("@scalar/validation").BooleanSchema;
@@ -125,12 +126,20 @@ export declare const apiReferenceConfigurationSchema: import("@scalar/validation
125
126
  name: string;
126
127
  method?: string;
127
128
  }) => string>>;
129
+ setPageTitle: import("@scalar/validation").OptionalSchema<import("@scalar/validation").FunctionSchema<(input: {
130
+ title: string;
131
+ document: {
132
+ title: string;
133
+ slug: string;
134
+ };
135
+ }) => string>>;
128
136
  redirect: import("@scalar/validation").OptionalSchema<import("@scalar/validation").FunctionSchema<(input: string) => string | null | undefined>>;
129
137
  withDefaultFonts: import("@scalar/validation").BooleanSchema;
130
138
  defaultOpenFirstTag: import("@scalar/validation").BooleanSchema;
131
139
  defaultOpenAllTags: import("@scalar/validation").BooleanSchema;
132
140
  expandAllModelSections: import("@scalar/validation").BooleanSchema;
133
141
  expandAllResponses: import("@scalar/validation").BooleanSchema;
142
+ expandAllSchemaProperties: import("@scalar/validation").BooleanSchema;
134
143
  tagsSorter: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").LiteralSchema<"alpha">, import("@scalar/validation").FunctionSchema<(a: any, b: any) => number>]>>;
135
144
  operationsSorter: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").LiteralSchema<"alpha">, import("@scalar/validation").LiteralSchema<"method">, import("@scalar/validation").FunctionSchema<(a: any, b: any) => number>]>>;
136
145
  orderSchemaPropertiesBy: import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").LiteralSchema<"alpha">, import("@scalar/validation").LiteralSchema<"preserve">]>;
@@ -193,6 +202,7 @@ export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unkno
193
202
  defaultOpenAllTags: boolean;
194
203
  expandAllModelSections: boolean;
195
204
  expandAllResponses: boolean;
205
+ expandAllSchemaProperties: boolean;
196
206
  orderSchemaPropertiesBy: "alpha" | "preserve";
197
207
  orderRequiredPropertiesFirst: boolean;
198
208
  } & {
@@ -224,6 +234,7 @@ export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unkno
224
234
  }>>;
225
235
  apiClientPlugins: any[];
226
236
  })[] | undefined;
237
+ modelsSectionLabel?: string | undefined;
227
238
  hideDownloadButton?: boolean | undefined;
228
239
  darkMode?: boolean | undefined;
229
240
  forceDarkModeState?: "dark" | "light" | undefined;
@@ -273,6 +284,13 @@ export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unkno
273
284
  name: string;
274
285
  method?: string;
275
286
  }) => string) | undefined;
287
+ setPageTitle?: ((input: {
288
+ title: string;
289
+ document: {
290
+ title: string;
291
+ slug: string;
292
+ };
293
+ }) => string) | undefined;
276
294
  redirect?: ((input: string) => string | null | undefined) | undefined;
277
295
  tagsSorter?: "alpha" | ((a: any, b: any) => number) | undefined;
278
296
  operationsSorter?: "alpha" | "method" | ((a: any, b: any) => number) | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"api-reference-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-configuration.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kHAyFN,MAAM,KAAK,IAAI;oHAGb,MAAM,KAAK,IAAI;oHAGf,IAAI;6GAGX,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;qHAKhD;QACN,OAAO,EAAE,OAAO,CAAA;QAChB,cAAc,EAAE,OAAO,CAAA;QACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACrC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;gHAOE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;mHAG5B,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;;;;;;;;;yHA4BzB;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM;uHAG9B;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM;qHAG9B;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM;2HAIp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AAE,KAAK,MAAM;qCAIpD;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM;mCAKvD;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM;4BAGnD;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAK,MAAM;wBAG3E,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS;gCA+Bb,GAAG,KAAK,GAAG,KAAK,MAAM;iDAGG,GAAG,KAAK,GAAG,KAAK,MAAM;CAuFvG,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { DEFAULT_MODELS_SECTION_LABEL } from '@scalar/types/api-reference';
1
2
  import { any, array, boolean, coerce, fn, intersection, literal, object, optional, record, string, union, } from '@scalar/validation';
2
3
  import { apiReferencePluginSchema } from '../api-reference/api-reference-plugin.js';
3
4
  import { baseConfigurationSchema } from './base-configuration.js';
@@ -33,6 +34,9 @@ export const apiReferenceConfigurationSchema = intersection([
33
34
  default: false,
34
35
  typeComment: 'Whether to show models in the sidebar, search, and content.',
35
36
  }),
37
+ modelsSectionLabel: optional(union([literal('Models'), literal('Schemas'), string()]), {
38
+ typeComment: 'Label for the components.schemas section in the sidebar, content, and search. Use `Schemas` for OpenAPI terminology.',
39
+ }),
36
40
  documentDownloadType: union([literal('both'), literal('yaml'), literal('json'), literal('direct'), literal('none')], {
37
41
  typeComment: 'Sets the file type of the document to download, set to `none` to hide the download button',
38
42
  }),
@@ -133,6 +137,9 @@ export const apiReferenceConfigurationSchema = intersection([
133
137
  generateWebhookSlug: optional(fn(), {
134
138
  typeComment: 'Customize the webhook portion of the hash',
135
139
  }),
140
+ setPageTitle: optional(fn(), {
141
+ typeComment: 'Customize the browser tab title for the section currently in view',
142
+ }),
136
143
  redirect: optional(fn(), {
137
144
  typeComment: 'To handle redirects, pass a function that receives the current path/hash and passes that to history.replaceState',
138
145
  }),
@@ -156,6 +163,10 @@ export const apiReferenceConfigurationSchema = intersection([
156
163
  default: false,
157
164
  typeComment: 'Whether to expand all responses by default. Warning: this can cause performance issues on big documents',
158
165
  }),
166
+ expandAllSchemaProperties: boolean({
167
+ default: false,
168
+ typeComment: 'Whether to expand all nested schema properties by default. The Show/Hide Child Attributes toggle remains available so nested sections can still be collapsed manually. Warning: this can cause performance issues on big documents',
169
+ }),
159
170
  tagsSorter: optional(union([literal('alpha'), fn()]), {
160
171
  typeComment: 'Function to sort tags',
161
172
  }),
@@ -215,5 +226,6 @@ export const apiReferenceConfigurationWithSourceSchema = (rawInput) => {
215
226
  // @ts-expect-error - We're deleting the deprecated attribute
216
227
  delete input.showToolbar;
217
228
  }
229
+ input.modelsSectionLabel ??= DEFAULT_MODELS_SECTION_LABEL;
218
230
  return input;
219
231
  };
@@ -10,5 +10,12 @@ export declare const htmlRenderingConfigurationSchema: import("@scalar/validatio
10
10
  */
11
11
  cdn: import("@scalar/validation").StringSchema;
12
12
  pageTitle: import("@scalar/validation").StringSchema;
13
+ /**
14
+ * A Content Security Policy (CSP) nonce to apply to the generated inline `<script>` and `<style>`
15
+ * tags so the API Reference can render under a strict CSP without `unsafe-inline`.
16
+ *
17
+ * Generate a fresh value per request and match it in your `script-src` and `style-src` directives.
18
+ */
19
+ nonce: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
13
20
  }>;
14
21
  //# sourceMappingURL=html-rendering-configuration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"html-rendering-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/html-rendering-configuration.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gCAAgC;IAC3C;;;;;;;;OAQG;;;EAOH,CAAA"}
1
+ {"version":3,"file":"html-rendering-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/html-rendering-configuration.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gCAAgC;IAC3C;;;;;;;;OAQG;;;IAOH;;;;;OAKG;;EAEH,CAAA"}
@@ -1,4 +1,4 @@
1
- import { object, string } from '@scalar/validation';
1
+ import { object, optional, string } from '@scalar/validation';
2
2
  export const htmlRenderingConfigurationSchema = object({
3
3
  /**
4
4
  * The URL to the Scalar API Reference JS CDN.
@@ -15,4 +15,11 @@ export const htmlRenderingConfigurationSchema = object({
15
15
  pageTitle: string({
16
16
  default: 'Scalar API Reference',
17
17
  }),
18
+ /**
19
+ * A Content Security Policy (CSP) nonce to apply to the generated inline `<script>` and `<style>`
20
+ * tags so the API Reference can render under a strict CSP without `unsafe-inline`.
21
+ *
22
+ * Generate a fresh value per request and match it in your `script-src` and `style-src` directives.
23
+ */
24
+ nonce: optional(string()),
18
25
  });
@@ -22,7 +22,7 @@ export declare const asyncApiObjectSchema: import("@scalar/validation").Intersec
22
22
  }>;
23
23
  servers: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").Schema>>;
24
24
  defaultContentType: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
25
- channels: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").LazySchema<() => import("@scalar/validation").Schema>>>;
25
+ channels: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").Schema>>;
26
26
  operations: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").LazySchema<() => import("@scalar/validation").Schema>>>;
27
27
  components: import("@scalar/validation").OptionalSchema<import("@scalar/validation").Schema>;
28
28
  }>, import("@scalar/validation").IntersectionSchema<readonly [import("@scalar/validation").ObjectSchema<{
@@ -1,4 +1,15 @@
1
- /** Channel Object | Reference Object */
2
- export declare const asyncApiChannelObject: import("@scalar/validation").LazySchema<() => import("@scalar/validation").Schema>;
3
- export declare const asyncApiChannelsObject: import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").LazySchema<() => import("@scalar/validation").Schema>>;
1
+ /** Channel Object */
2
+ export declare const asyncApiChannelObject: import("@scalar/validation").LazySchema<() => import("@scalar/validation").ObjectSchema<{
3
+ address: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").StringSchema, import("@scalar/validation").NullableSchema]>>;
4
+ messages: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").LazySchema<() => import("@scalar/validation").Schema>>>;
5
+ title: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
6
+ summary: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
7
+ description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
8
+ servers: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").Schema>>;
9
+ parameters: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").Schema>>;
10
+ tags: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").Schema>>;
11
+ externalDocs: import("@scalar/validation").OptionalSchema<import("@scalar/validation").Schema>;
12
+ bindings: import("@scalar/validation").OptionalSchema<import("@scalar/validation").Schema>;
13
+ }>>;
14
+ export declare const asyncApiChannelsObject: import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").Schema>;
4
15
  //# sourceMappingURL=channel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/channel.ts"],"names":[],"mappings":"AAUA,wCAAwC;AACxC,eAAO,MAAM,qBAAqB,oFA4BjC,CAAA;AAED,eAAO,MAAM,sBAAsB,0KAGjC,CAAA"}
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/channel.ts"],"names":[],"mappings":"AAUA,qBAAqB;AACrB,eAAO,MAAM,qBAAqB;;;;;;;;;;;GA0BjC,CAAA;AAED,eAAO,MAAM,sBAAsB,2HAGjC,CAAA"}
@@ -6,8 +6,8 @@ import { asyncApiParametersObject } from './parameters.js';
6
6
  import { asyncApiResolvedReference, recursiveRef } from './reference.js';
7
7
  import { asyncApiServerObject } from './server.js';
8
8
  import { asyncApiTagsObject } from './tag.js';
9
- /** Channel Object | Reference Object */
10
- export const asyncApiChannelObject = lazy(() => recursiveRef(object({
9
+ /** Channel Object */
10
+ export const asyncApiChannelObject = lazy(() => object({
11
11
  address: optional(union([string(), nullable()], { typeComment: 'Channel address or null when unknown.' })),
12
12
  messages: optional(asyncApiMessagesObject),
13
13
  title: optional(string({ typeComment: 'A human-friendly title for the channel.' })),
@@ -22,8 +22,8 @@ export const asyncApiChannelObject = lazy(() => recursiveRef(object({
22
22
  tags: optional(asyncApiTagsObject),
23
23
  externalDocs: optional(asyncApiExternalDocumentationObject),
24
24
  bindings: optional(recursiveRef(asyncApiChannelBindingsObject)),
25
- }, { typeName: 'AsyncApiChannelObject' })));
26
- export const asyncApiChannelsObject = record(string(), asyncApiChannelObject, {
25
+ }, { typeName: 'AsyncApiChannelObject' }));
26
+ export const asyncApiChannelsObject = record(string(), recursiveRef(asyncApiChannelObject), {
27
27
  typeName: 'AsyncApiChannelsObject',
28
28
  typeComment: 'Map of channelId to Channel Object or Reference Object.',
29
29
  });
@@ -1,7 +1,7 @@
1
1
  export declare const asyncApiComponentsObject: import("@scalar/validation").LazySchema<() => import("@scalar/validation").ObjectSchema<{
2
2
  schemas: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").Schema>>;
3
3
  servers: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").Schema>>;
4
- channels: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").LazySchema<() => import("@scalar/validation").Schema>>>;
4
+ channels: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").Schema>>;
5
5
  operations: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").LazySchema<() => import("@scalar/validation").Schema>>>;
6
6
  messages: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").LazySchema<() => import("@scalar/validation").Schema>>>;
7
7
  securitySchemes: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").Schema>>;
@@ -1,6 +1,6 @@
1
1
  import { lazy, object, optional, record, string } from '@scalar/validation';
2
2
  import { asyncApiChannelBindingsObject, asyncApiMessageBindingsObject, asyncApiOperationBindingsObject, asyncApiServerBindingsObject, } from './bindings.js';
3
- import { asyncApiChannelObject } from './channel.js';
3
+ import { asyncApiChannelsObject } from './channel.js';
4
4
  import { asyncApiCorrelationIdObject } from './correlation-id.js';
5
5
  import { asyncApiExternalDocumentationObject } from './external-documentation.js';
6
6
  import { asyncApiMessageObject } from './message.js';
@@ -21,7 +21,7 @@ export const asyncApiComponentsObject = lazy(() => object({
21
21
  typeComment: 'Reusable Multi Format Schema, Schema Object, or Reference Object.',
22
22
  })),
23
23
  servers: optional(record(string(), asyncApiServerObject)),
24
- channels: optional(record(string(), asyncApiChannelObject)),
24
+ channels: optional(asyncApiChannelsObject),
25
25
  operations: optional(record(string(), asyncApiOperationObject)),
26
26
  messages: optional(record(string(), asyncApiMessageObject)),
27
27
  securitySchemes: optional(record(string(), asyncApiSecuritySchemeObject)),
@@ -1 +1 @@
1
- {"version":3,"file":"schema-payload.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/schema-payload.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,+BAA+B;;;EAa3C,CAAA;AAcD,uCAAuC;AACvC,eAAO,MAAM,+BAA+B,qCAAwC,CAAA;AAEpF,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,qCAIjC,CAAA"}
1
+ {"version":3,"file":"schema-payload.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/schema-payload.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,+BAA+B;;;EAa3C,CAAA;AAQD,uCAAuC;AACvC,eAAO,MAAM,+BAA+B,qCAAwC,CAAA;AAEpF,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,qCAIjC,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { literal, object, optional, string, union, unknown } from '@scalar/validation';
2
+ import { schema as schemaObject } from '../../openapi/3.1/schema.js';
2
3
  import { recursiveRef } from './reference.js';
3
4
  export const asyncApiMultiFormatSchemaObject = object({
4
5
  schemaFormat: optional(string({
@@ -8,14 +9,11 @@ export const asyncApiMultiFormatSchemaObject = object({
8
9
  typeComment: 'REQUIRED. Schema definition in the format given by schemaFormat.',
9
10
  }),
10
11
  }, { typeName: 'AsyncApiMultiFormatSchemaObject' });
11
- const asyncApiSchemaJsonShape = union([
12
- literal(true),
13
- literal(false),
14
- unknown({
15
- typeName: 'AsyncApiSchemaObject',
16
- typeComment: 'JSON Schema Draft 07 compatible schema (boolean true/false or object); see AsyncAPI Schema Object.',
17
- }),
18
- ], { typeName: 'AsyncApiSchemaJsonShape' });
12
+ // AsyncAPI's default schema format is JSON Schema, the same dialect OpenAPI 3.1 uses, so we reuse the
13
+ // OpenAPI Schema Object here instead of an opaque `unknown`. A schema may also be a boolean per JSON Schema.
14
+ const asyncApiSchemaJsonShape = union([literal(true), literal(false), schemaObject], {
15
+ typeName: 'AsyncApiSchemaJsonShape',
16
+ });
19
17
  /** Schema Object | Reference Object */
20
18
  export const asyncApiSchemaObjectOrReference = recursiveRef(asyncApiSchemaJsonShape);
21
19
  /** Multi Format Schema Object | Schema Object | Reference Object */
@@ -1,7 +1,6 @@
1
1
  export declare const XScalarSdkInstallation: import("@scalar/validation").ObjectSchema<{
2
2
  'x-scalar-sdk-installation': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
3
3
  lang: import("@scalar/validation").StringSchema;
4
- source: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
5
4
  description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
6
5
  }>>>;
7
6
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"x-scalar-sdk-installation.d.ts","sourceRoot":"","sources":["../../../src/extensions/document/x-scalar-sdk-installation.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,sBAAsB;;;;;;EAiBlC,CAAA"}
1
+ {"version":3,"file":"x-scalar-sdk-installation.d.ts","sourceRoot":"","sources":["../../../src/extensions/document/x-scalar-sdk-installation.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,sBAAsB;;;;;EAiBlC,CAAA"}
@@ -1,9 +1,8 @@
1
1
  import { array, object, optional, string } from '@scalar/validation';
2
2
  import { typeCommentWithExample } from '../type-comment.js';
3
3
  const XScalarSdkInstallationItem = object({
4
- lang: string({ typeComment: 'Programming language or platform (for example `shell`, `javascript`)' }),
5
- source: optional(string({ typeComment: 'Installation command or snippet source' })),
6
- description: optional(string({ typeComment: 'Human-readable description of this installation option' })),
4
+ lang: string({ typeComment: 'Programming language or platform (for example `TypeScript`, `Java`, `Python`)' }),
5
+ description: optional(string({ typeComment: 'Installation instructions in Markdown (supports fenced code blocks)' })),
7
6
  }, {
8
7
  typeName: 'XScalarSdkInstallationItem',
9
8
  typeComment: 'One SDK installation instruction block',
@@ -17,7 +16,7 @@ export const XScalarSdkInstallation = object({
17
16
  typeComment: typeCommentWithExample('Scalar SDK installation instructions for the API description.', {
18
17
  language: 'yaml',
19
18
  body: `x-scalar-sdk-installation:
20
- - lang: shell
21
- source: npm install @scalar/api-client`,
19
+ - lang: TypeScript
20
+ description: Install our SDK from npm with \`npm install @scalar/sdk\``,
22
21
  }),
23
22
  });
@@ -19,5 +19,30 @@ export declare const XCodeSamples: import("@scalar/validation").ObjectSchema<{
19
19
  label: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
20
20
  source: import("@scalar/validation").StringSchema;
21
21
  }>>>;
22
+ 'x-readme': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<{
23
+ 'code-samples': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
24
+ language: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
25
+ code: import("@scalar/validation").StringSchema;
26
+ name: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
27
+ install: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
28
+ correspondingExample: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
29
+ }>>>;
30
+ 'samples-languages': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>>;
31
+ }>>;
32
+ 'x-stainless-snippets': import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").StringSchema>>;
33
+ 'x-stainless-examples': import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").ObjectSchema<{
34
+ title: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
35
+ request: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").StringSchema>>;
36
+ response: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnknownSchema>;
37
+ }>, import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
38
+ title: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
39
+ request: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").StringSchema>>;
40
+ response: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnknownSchema>;
41
+ }>>]>>;
42
+ 'x-scalar-examples': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
43
+ lang: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
44
+ label: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
45
+ source: import("@scalar/validation").StringSchema;
46
+ }>>>;
22
47
  }>;
23
48
  //# sourceMappingURL=x-code-samples.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"x-code-samples.d.ts","sourceRoot":"","sources":["../../../src/extensions/operation/x-code-samples.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW;;;;EAUvB,CAAA;AAED,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;EAmBxB,CAAA"}
1
+ {"version":3,"file":"x-code-samples.d.ts","sourceRoot":"","sources":["../../../src/extensions/operation/x-code-samples.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW;;;;EAUvB,CAAA;AA0CD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BxB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { array, object, optional, string } from '@scalar/validation';
1
+ import { array, object, optional, record, string, union, unknown } from '@scalar/validation';
2
2
  import { typeCommentInlineCode, typeCommentWithExample } from '../type-comment.js';
3
3
  export const XCodeSample = object({
4
4
  lang: optional(string({ typeComment: 'Programming language for syntax highlighting' })),
@@ -8,13 +8,44 @@ export const XCodeSample = object({
8
8
  typeName: 'XCodeSample',
9
9
  typeComment: 'A single code sample for documentation or examples',
10
10
  });
11
+ const XReadmeCodeSample = object({
12
+ language: optional(string({ typeComment: 'Programming language for syntax highlighting' })),
13
+ code: string({ typeComment: 'Source code for the sample' }),
14
+ name: optional(string({ typeComment: 'Label shown in the code sample picker' })),
15
+ install: optional(string({ typeComment: 'Installation instructions for the sample' })),
16
+ correspondingExample: optional(string({ typeComment: 'Name of the response example this sample maps to' })),
17
+ }, {
18
+ typeName: 'XReadmeCodeSample',
19
+ typeComment: 'A single ReadMe custom code sample',
20
+ });
21
+ const XReadme = object({
22
+ 'code-samples': optional(array(XReadmeCodeSample, { typeComment: 'ReadMe custom code samples' })),
23
+ 'samples-languages': optional(array(string(), { typeComment: 'Languages to generate code samples for' })),
24
+ }, {
25
+ typeName: 'XReadme',
26
+ typeComment: 'ReadMe extension object. Only code-samples carries source code.',
27
+ });
28
+ const XLanguageExample = object({
29
+ title: optional(string({ typeComment: 'Label shown in the code sample picker' })),
30
+ request: optional(record(string(), string(), { typeComment: 'Source code keyed by programming language' })),
31
+ response: optional(unknown({ typeComment: 'Example response for the request' })),
32
+ }, {
33
+ typeName: 'XLanguageExample',
34
+ typeComment: 'Per-language request snippets with an optional title and response',
35
+ });
36
+ /** A single example or an array of examples, as used by x-stainless-examples and x-scalar-examples. */
37
+ const XLanguageExamples = union([XLanguageExample, array(XLanguageExample)]);
11
38
  export const XCodeSamples = object({
12
39
  'x-codeSamples': optional(array(XCodeSample, { typeComment: 'Code samples (camelCase spelling)' })),
13
40
  'x-code-samples': optional(array(XCodeSample, { typeComment: 'Code samples (kebab-case spelling)' })),
14
41
  'x-custom-examples': optional(array(XCodeSample, { typeComment: 'Custom code examples for the operation' })),
42
+ 'x-readme': optional(XReadme),
43
+ 'x-stainless-snippets': optional(record(string(), string(), { typeComment: 'Stainless snippets, source code keyed by language' })),
44
+ 'x-stainless-examples': optional(XLanguageExamples),
45
+ 'x-scalar-examples': optional(array(XCodeSample, { typeComment: 'Scalar code samples (same shape as x-codeSamples)' })),
15
46
  }, {
16
47
  typeName: 'XCodeSamples',
17
- typeComment: typeCommentWithExample(`Code samples attached to an operation. Supports ${typeCommentInlineCode('x-codeSamples')}, ${typeCommentInlineCode('x-code-samples')}, and ${typeCommentInlineCode('x-custom-examples')}.`, {
48
+ typeComment: typeCommentWithExample(`Code samples attached to an operation. Supports ${typeCommentInlineCode('x-codeSamples')}, ${typeCommentInlineCode('x-code-samples')}, ${typeCommentInlineCode('x-custom-examples')}, ${typeCommentInlineCode('x-readme')}, ${typeCommentInlineCode('x-stainless-snippets')}, ${typeCommentInlineCode('x-stainless-examples')}, and ${typeCommentInlineCode('x-scalar-examples')}.`, {
18
49
  language: 'yaml',
19
50
  body: `x-code-samples:
20
51
  - lang: curl
@@ -19,7 +19,6 @@ export declare const openApiSchema: import("@scalar/validation").IntersectionSch
19
19
  }>, import("@scalar/validation").ObjectSchema<{
20
20
  'x-scalar-sdk-installation': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
21
21
  lang: import("@scalar/validation").StringSchema;
22
- source: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
23
22
  description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
24
23
  }>>>;
25
24
  }>]>;
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/document.ts"],"names":[],"mappings":"AA2GA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAGxB,CAAA"}
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/document.ts"],"names":[],"mappings":"AA2GA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAGxB,CAAA"}
@@ -17,7 +17,6 @@ export declare const info: import("@scalar/validation").IntersectionSchema<reado
17
17
  }>, import("@scalar/validation").ObjectSchema<{
18
18
  'x-scalar-sdk-installation': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
19
19
  lang: import("@scalar/validation").StringSchema;
20
- source: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
21
20
  description: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
22
21
  }>>>;
23
22
  }>]>;
@@ -1 +1 @@
1
- {"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/info.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;IAuBhB,CAAA"}
1
+ {"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/info.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;IAuBhB,CAAA"}
@@ -48,6 +48,31 @@ export declare const operation: import("@scalar/validation").IntersectionSchema<
48
48
  label: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
49
49
  source: import("@scalar/validation").StringSchema;
50
50
  }>>>;
51
+ 'x-readme': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<{
52
+ 'code-samples': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
53
+ language: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
54
+ code: import("@scalar/validation").StringSchema;
55
+ name: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
56
+ install: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
57
+ correspondingExample: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
58
+ }>>>;
59
+ 'samples-languages': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>>;
60
+ }>>;
61
+ 'x-stainless-snippets': import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").StringSchema>>;
62
+ 'x-stainless-examples': import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").ObjectSchema<{
63
+ title: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
64
+ request: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").StringSchema>>;
65
+ response: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnknownSchema>;
66
+ }>, import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
67
+ title: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
68
+ request: import("@scalar/validation").OptionalSchema<import("@scalar/validation").RecordSchema<import("@scalar/validation").StringSchema, import("@scalar/validation").StringSchema>>;
69
+ response: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnknownSchema>;
70
+ }>>]>>;
71
+ 'x-scalar-examples': import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").ObjectSchema<{
72
+ lang: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
73
+ label: import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
74
+ source: import("@scalar/validation").StringSchema;
75
+ }>>>;
51
76
  }>, import("@scalar/validation").ObjectSchema<{
52
77
  'x-scalar-stability': import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").LiteralSchema<"deprecated">, import("@scalar/validation").LiteralSchema<"experimental">, import("@scalar/validation").LiteralSchema<"stable">]>>;
53
78
  }>, import("@scalar/validation").ObjectSchema<{
@@ -1 +1 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/operation.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiDrB,CAAA"}
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/operation.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiDrB,CAAA"}
@@ -18,7 +18,7 @@ const reference = object({
18
18
  * Use for `components.schemas` and schema composition (`allOf`, `properties`, `items`, and similar)
19
19
  * where references follow JSON Schema / OpenAPI schema rules only.
20
20
  */
21
- export const normalRef = (inner) => union([inner, reference]);
21
+ export const normalRef = (inner) => union([reference, inner]);
22
22
  const e = (value) => {
23
23
  if (isObject(value) && '$ref' in value) {
24
24
  return e(value['$ref-value']);
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAaZ,MAAM,oBAAoB,CAAA;AAqI3B,eAAO,MAAM,MAAM,EAAE,MAOpB,CAAA"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAaZ,MAAM,oBAAoB,CAAA;AA0K3B,eAAO,MAAM,MAAM,EAAE,MAOpB,CAAA"}
@@ -43,24 +43,33 @@ const coreSchemaProperties = object({
43
43
  anyOf: optional(array(normalRef(lazy(() => schema)), { typeName: 'SchemaObjectAnyOf' })),
44
44
  not: optional(normalRef(lazy(() => schema))),
45
45
  });
46
- const numericSchema = object({
47
- type: union([literal('number'), literal('integer')]),
48
- format: optional(string({ typeComment: 'Different subtypes.' })),
46
+ const numericValidationKeywords = object({
49
47
  multipleOf: optional(number({ typeComment: 'Number must be a multiple of this value.' })),
50
48
  maximum: optional(number({ typeComment: 'Maximum value (inclusive).' })),
51
49
  exclusiveMaximum: optional(number({ typeComment: 'Maximum value (exclusive).' })),
52
50
  minimum: optional(number({ typeComment: 'Minimum value (inclusive).' })),
53
51
  exclusiveMinimum: optional(number({ typeComment: 'Minimum value (exclusive).' })),
54
- }, { typeName: 'NumberSchemaObject' });
55
- const stringSchema = object({
56
- type: literal('string'),
57
- format: optional(string({ typeComment: 'Different subtypes.' })),
52
+ });
53
+ const numericSchema = intersection([
54
+ object({
55
+ type: union([literal('number'), literal('integer')]),
56
+ format: optional(string({ typeComment: 'Different subtypes.' })),
57
+ }),
58
+ numericValidationKeywords,
59
+ ], { typeName: 'NumberSchemaObject' });
60
+ const stringValidationKeywords = object({
58
61
  maxLength: optional(number({ typeComment: 'Maximum string length.' })),
59
62
  minLength: optional(number({ typeComment: 'Minimum string length.' })),
60
63
  pattern: optional(string({ typeComment: 'Regular expression pattern.' })),
61
- }, { typeName: 'StringSchemaObject' });
62
- const objectSchema = object({
63
- type: literal('object'),
64
+ });
65
+ const stringSchema = intersection([
66
+ object({
67
+ type: literal('string'),
68
+ format: optional(string({ typeComment: 'Different subtypes.' })),
69
+ }),
70
+ stringValidationKeywords,
71
+ ], { typeName: 'StringSchemaObject' });
72
+ const objectValidationKeywords = object({
64
73
  maxProperties: optional(number({ typeComment: 'Maximum number of properties.' })),
65
74
  minProperties: optional(number({ typeComment: 'Minimum number of properties.' })),
66
75
  properties: optional(record(string(), normalRef(lazy(() => schema)), { typeName: 'SchemaObjectProperties' })),
@@ -70,15 +79,26 @@ const objectSchema = object({
70
79
  })),
71
80
  patternProperties: optional(record(string(), normalRef(lazy(() => schema)), { typeName: 'SchemaObjectPatternProperties' })),
72
81
  propertyNames: optional(normalRef(lazy(() => schema))),
73
- }, { typeName: 'ObjectSchemaObject' });
74
- const arraySchema = object({
75
- type: literal('array'),
82
+ });
83
+ const objectSchema = intersection([
84
+ object({
85
+ type: literal('object'),
86
+ }),
87
+ objectValidationKeywords,
88
+ ], { typeName: 'ObjectSchemaObject' });
89
+ const arrayValidationKeywords = object({
76
90
  maxItems: optional(number({ typeComment: 'Maximum number of items in array.' })),
77
91
  minItems: optional(number({ typeComment: 'Minimum number of items in array.' })),
78
92
  uniqueItems: optional(boolean({ typeComment: 'Whether array items must be unique.' })),
79
93
  items: optional(normalRef(lazy(() => schema))),
80
94
  prefixItems: optional(array(normalRef(lazy(() => schema)), { typeComment: 'Schema for tuple validation.' })),
81
- }, { typeName: 'ArraySchemaObject' });
95
+ });
96
+ const arraySchema = intersection([
97
+ object({
98
+ type: literal('array'),
99
+ }),
100
+ arrayValidationKeywords,
101
+ ], { typeName: 'ArraySchemaObject' });
82
102
  const schemaTypeMulti = union([
83
103
  literal('null'),
84
104
  literal('boolean'),
@@ -89,12 +109,24 @@ const schemaTypeMulti = union([
89
109
  literal('array'),
90
110
  ], { typeName: 'SchemaObjectMultiTypeKeywords' });
91
111
  const otherTypeSchema = object({
92
- type: union([literal('null'), literal('boolean'), array(schemaTypeMulti)], {
112
+ type: union([literal('null'), literal('boolean')], {
93
113
  typeName: 'SchemaObjectOtherTypeKeyword',
94
114
  }),
95
- }, { typeName: 'MultiTypeSchemaObject' });
115
+ });
116
+ const multiTypeSchema = intersection([
117
+ object({
118
+ type: array(schemaTypeMulti, {
119
+ typeName: 'SchemaObjectMultiTypeKeywordArray',
120
+ }),
121
+ format: optional(string({ typeComment: 'Different subtypes.' })),
122
+ }),
123
+ numericValidationKeywords,
124
+ stringValidationKeywords,
125
+ arrayValidationKeywords,
126
+ objectValidationKeywords,
127
+ ], { typeName: 'MultiTypeSchemaObject' });
96
128
  export const schema = intersection([
97
129
  coreSchemaProperties,
98
130
  ...schemaExtensionObjects,
99
- union([otherTypeSchema, numericSchema, stringSchema, objectSchema, arraySchema, object({})]),
131
+ union([otherTypeSchema, numericSchema, stringSchema, objectSchema, arraySchema, multiTypeSchema, object({})]),
100
132
  ], { typeName: 'SchemaObject' });
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "schemas",
15
15
  "scalar"
16
16
  ],
17
- "version": "0.3.2",
17
+ "version": "0.4.0",
18
18
  "engines": {
19
19
  "node": ">=22"
20
20
  },
@@ -41,12 +41,12 @@
41
41
  "CHANGELOG.md"
42
42
  ],
43
43
  "dependencies": {
44
- "@scalar/helpers": "0.8.0",
45
- "@scalar/validation": "0.6.0"
44
+ "@scalar/validation": "0.6.0",
45
+ "@scalar/helpers": "0.8.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "vitest": "4.1.0",
49
- "@scalar/types": "0.12.2"
49
+ "@scalar/types": "0.13.0"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",