@scalar/schemas 0.9.0 → 0.10.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,39 @@
|
|
|
1
1
|
# @scalar/schemas
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#10074](https://github.com/scalar/scalar/pull/10074): feat(api-reference)!: the tree layout is the schema renderer
|
|
8
|
+
|
|
9
|
+
The tree layout is the schema renderer, so every visual baseline that renders a schema changes with this release and is regenerated per suite.
|
|
10
|
+
|
|
11
|
+
- [#10074](https://github.com/scalar/scalar/pull/10074): feat(api-reference): the tree schema layout
|
|
12
|
+
|
|
13
|
+
The tree layout replaces the bordered card per nesting level and the "Show Child Attributes" pill with the visual grammar of a tree: a continuous rail per depth that hangs from the parent property's text column, and a discrete disclosure control in each expandable property's own gutter. The control is a real button whose accessible name is the property name alone and whose child count rides `aria-describedby`; property descriptions stay visible instead of being swallowed into a button label. Types render as token runs — `array of Planet` instead of `array Planet[]`, with a `$ref` link as the type itself — collapsed objects show a preview of what they hold, short enums render inline in the type position or wrap as chips instead of a row per value, and a `$ref` cycle says `recursive` in its own signature line instead of offering a toggle that descends forever. Rails fade with depth, capped so the deepest ones never wash out into the page. In a narrow container — the same `max-width: 900px` query the sections already use — the indent tightens and the controls shrink, so a deep tree still fits and the outermost control clears the page edge instead of being clipped by it. Collapsed subtrees that were opened once stay reachable with find-in-page via `hidden="until-found"` where the engine supports it, against a budget shared by every tree in the reference, with Safari falling back to unmounting exactly as before.
|
|
14
|
+
|
|
15
|
+
Printing temporarily expands the whole tree and restores the reader's expansion state afterwards.
|
|
16
|
+
|
|
17
|
+
- [#10074](https://github.com/scalar/scalar/pull/10074): feat(api-reference): one disclosure grammar across every surface in the tree layout
|
|
18
|
+
|
|
19
|
+
The tree layout now reaches the surfaces the schema renderer never covered. Response headers fold into the tree as a child group named Headers, keyed into the expansion store so expand-all and deep links finally reach them — and the headers card's long-standing CSS syntax error is fixed along the way. Callbacks trade their native `details`/`summary` for the gutter control, and gain breadcrumbs, so a property inside a callback body is addressable for the first time. AsyncAPI message headers and payloads gain breadcrumbs the same way. Parameter rows keep rendering their type, required marker and description inline: a disclosure may hide child elements, never child information, and the classic layout starts passing `collapsableItems` — previously omitted, which silently made `expandAllResponses` a no-op there. Model properties in the classic layout gain anchors.
|
|
20
|
+
|
|
21
|
+
Group titles — Body, Responses, Query Parameters, Callbacks — become real headings through the document outline (`operationSection`, level 4), never hardcoded tags.
|
|
22
|
+
|
|
23
|
+
One flagged feature ships with this: `schemaKeyboardNav` (default off) adds APG-tree arrow-key navigation over the gutter toggles.
|
|
24
|
+
|
|
25
|
+
- [#10102](https://github.com/scalar/scalar/pull/10102): Allow response hooks to return a replacement Response before the client processes its body, status, and headers. Add the onResponseReceived configuration callback for API References. Existing hooks can still read responses and return nothing.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#10126](https://github.com/scalar/scalar/pull/10126): refactor(api-reference): remove the legacy schema layout and the `schemaLayout` option
|
|
30
|
+
|
|
31
|
+
The legacy schema layout — a bordered card per nesting level behind a "Show Child Attributes" pill — is deleted, together with the `schemaLayout` configuration option that selected it. The tree layout is the only schema renderer.
|
|
32
|
+
|
|
33
|
+
The `schemaLayout` option never shipped in a release, so there is no `schemaLayout` value to remove from your configuration. Five translation keys the deleted markup owned are removed from `ApiReferenceTranslations`, and therefore from the `ApiReferenceTranslationKey` union: `schema.childAttributes`, `schema.hideChildAttributes`, `schema.showChildAttributes`, `operation.hideHeaders` and `operation.showHeaders`. They labelled the "Show Child Attributes" pill and the headers disclosure toggle, neither of which renders any more. If you override any of them in `localization.translations`, delete those entries — TypeScript will otherwise report an unknown-property error on the object literal.
|
|
34
|
+
|
|
35
|
+
The class names the tree already carried (`.schema-card`, `.property`, `.property--level-N` and their family) are unchanged, so `customCss` keeps working.
|
|
36
|
+
|
|
3
37
|
## 0.9.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
|
@@ -124,6 +124,10 @@ export declare const apiReferenceConfigurationSchema: import("@scalar/validation
|
|
|
124
124
|
requestBuilder: unknown;
|
|
125
125
|
envVariables: Record<string, string>;
|
|
126
126
|
}) => Promise<void> | void>>;
|
|
127
|
+
onResponseReceived: import("@scalar/validation").OptionalSchema<import("@scalar/validation").FunctionSchema<(input: {
|
|
128
|
+
response: Response;
|
|
129
|
+
request: Request;
|
|
130
|
+
}) => Response | void | Promise<Response | void>>>;
|
|
127
131
|
onShowMore: import("@scalar/validation").OptionalSchema<import("@scalar/validation").FunctionSchema<(tagId: string) => Promise<void> | void>>;
|
|
128
132
|
onSidebarClick: import("@scalar/validation").OptionalSchema<import("@scalar/validation").FunctionSchema<(href: string) => Promise<void> | void>>;
|
|
129
133
|
pathRouting: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ObjectSchema<{
|
|
@@ -170,6 +174,7 @@ export declare const apiReferenceConfigurationSchema: import("@scalar/validation
|
|
|
170
174
|
tagsSorter: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [LiteralSchema<"alpha">, import("@scalar/validation").FunctionSchema<(a: any, b: any) => number>]>>;
|
|
171
175
|
operationsSorter: import("@scalar/validation").OptionalSchema<import("@scalar/validation").UnionSchema<readonly [LiteralSchema<"alpha">, LiteralSchema<"method">, import("@scalar/validation").FunctionSchema<(a: any, b: any) => number>]>>;
|
|
172
176
|
orderSchemaPropertiesBy: import("@scalar/validation").UnionSchema<readonly [LiteralSchema<"alpha">, LiteralSchema<"preserve">]>;
|
|
177
|
+
schemaKeyboardNav: import("@scalar/validation").BooleanSchema;
|
|
173
178
|
orderRequiredPropertiesFirst: import("@scalar/validation").BooleanSchema;
|
|
174
179
|
}>]>;
|
|
175
180
|
export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unknown) => {
|
|
@@ -230,6 +235,7 @@ export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unkno
|
|
|
230
235
|
expandAllResponses: boolean;
|
|
231
236
|
expandAllSchemaProperties: boolean;
|
|
232
237
|
orderSchemaPropertiesBy: "alpha" | "preserve";
|
|
238
|
+
schemaKeyboardNav: boolean;
|
|
233
239
|
orderRequiredPropertiesFirst: boolean;
|
|
234
240
|
} & {
|
|
235
241
|
proxy?: string | undefined;
|
|
@@ -307,6 +313,10 @@ export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unkno
|
|
|
307
313
|
requestBuilder: unknown;
|
|
308
314
|
envVariables: Record<string, string>;
|
|
309
315
|
}) => Promise<void> | void) | undefined;
|
|
316
|
+
onResponseReceived?: ((input: {
|
|
317
|
+
response: Response;
|
|
318
|
+
request: Request;
|
|
319
|
+
}) => Response | void | Promise<Response | void>) | undefined;
|
|
310
320
|
onShowMore?: ((tagId: string) => Promise<void> | void) | undefined;
|
|
311
321
|
onSidebarClick?: ((href: string) => Promise<void> | void) | undefined;
|
|
312
322
|
pathRouting?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-reference-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EACL,KAAK,aAAa,EAanB,MAAM,oBAAoB,CAAA;AAO3B,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA2GF,aAAa,CAAC,QAAQ,CAAC;mBACvB,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;;;oHAYnC,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;oHASlB;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;
|
|
1
|
+
{"version":3,"file":"api-reference-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EACL,KAAK,aAAa,EAanB,MAAM,oBAAoB,CAAA;AAO3B,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA2GF,aAAa,CAAC,QAAQ,CAAC;mBACvB,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;;;oHAYnC,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;oHASlB;QACN,OAAO,EAAE,OAAO,CAAA;QAChB,cAAc,EAAE,OAAO,CAAA;QACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACrC,KAAK,OAA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AAM,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;CA4FvG,CAAA"}
|
|
@@ -122,6 +122,9 @@ export const apiReferenceConfigurationSchema = intersection([
|
|
|
122
122
|
onRequestBuilt: optional(fn(), {
|
|
123
123
|
typeComment: 'Fired right before the outbound request is sent; callback receives the exact fetch Request that goes over the wire. Experimental API.',
|
|
124
124
|
}),
|
|
125
|
+
onResponseReceived: optional(fn(), {
|
|
126
|
+
typeComment: 'Fired before response processing. Return a Response to replace it, or nothing to keep it.',
|
|
127
|
+
}),
|
|
125
128
|
onShowMore: optional(fn(), {
|
|
126
129
|
typeComment: 'onShowMore is fired when the user clicks the "Show more" button on the references',
|
|
127
130
|
}),
|
|
@@ -189,7 +192,7 @@ export const apiReferenceConfigurationSchema = intersection([
|
|
|
189
192
|
}),
|
|
190
193
|
expandAllSchemaProperties: boolean({
|
|
191
194
|
default: false,
|
|
192
|
-
typeComment: 'Whether to expand all nested schema properties by default.
|
|
195
|
+
typeComment: 'Whether to expand all nested schema properties by default. Each row keeps its own disclosure control, so nested sections can still be collapsed manually. Warning: this can cause performance issues on big documents',
|
|
193
196
|
}),
|
|
194
197
|
tagsSorter: optional(union([literal('alpha'), fn()]), {
|
|
195
198
|
typeComment: 'Function to sort tags',
|
|
@@ -200,6 +203,10 @@ export const apiReferenceConfigurationSchema = intersection([
|
|
|
200
203
|
orderSchemaPropertiesBy: union([literal('alpha'), literal('preserve')], {
|
|
201
204
|
typeComment: 'Order the schema properties by',
|
|
202
205
|
}),
|
|
206
|
+
schemaKeyboardNav: boolean({
|
|
207
|
+
default: false,
|
|
208
|
+
typeComment: 'Arrow-key navigation over the schema disclosure toggles (APG tree bindings). Off until screen-reader interaction questions are settled',
|
|
209
|
+
}),
|
|
203
210
|
orderRequiredPropertiesFirst: boolean({
|
|
204
211
|
default: true,
|
|
205
212
|
typeComment: 'Sort the schema properties by required ones first',
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"schemas",
|
|
15
15
|
"scalar"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.10.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.
|
|
44
|
+
"@scalar/helpers": "0.12.0",
|
|
45
45
|
"@scalar/validation": "0.6.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"vitest": "4.1.10",
|
|
49
|
-
"@scalar/types": "0.
|
|
49
|
+
"@scalar/types": "0.20.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|