@scalar/schemas 0.3.3 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
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
+
3
34
  ## 0.3.3
4
35
 
5
36
  ### Patch Changes
@@ -139,6 +139,7 @@ export declare const apiReferenceConfigurationSchema: import("@scalar/validation
139
139
  defaultOpenAllTags: import("@scalar/validation").BooleanSchema;
140
140
  expandAllModelSections: import("@scalar/validation").BooleanSchema;
141
141
  expandAllResponses: import("@scalar/validation").BooleanSchema;
142
+ expandAllSchemaProperties: import("@scalar/validation").BooleanSchema;
142
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>]>>;
143
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>]>>;
144
145
  orderSchemaPropertiesBy: import("@scalar/validation").UnionSchema<readonly [import("@scalar/validation").LiteralSchema<"alpha">, import("@scalar/validation").LiteralSchema<"preserve">]>;
@@ -201,6 +202,7 @@ export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unkno
201
202
  defaultOpenAllTags: boolean;
202
203
  expandAllModelSections: boolean;
203
204
  expandAllResponses: boolean;
205
+ expandAllSchemaProperties: boolean;
204
206
  orderSchemaPropertiesBy: "alpha" | "preserve";
205
207
  orderRequiredPropertiesFirst: boolean;
206
208
  } & {
@@ -1 +1 @@
1
- {"version":3,"file":"api-reference-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-configuration.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AQ,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"}
@@ -163,6 +163,10 @@ export const apiReferenceConfigurationSchema = intersection([
163
163
  default: false,
164
164
  typeComment: 'Whether to expand all responses by default. Warning: this can cause performance issues on big documents',
165
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
+ }),
166
170
  tagsSorter: optional(union([literal('alpha'), fn()]), {
167
171
  typeComment: 'Function to sort tags',
168
172
  }),
@@ -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
  });
@@ -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"}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "schemas",
15
15
  "scalar"
16
16
  ],
17
- "version": "0.3.3",
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.1",
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.3"
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",