docusaurus-plugin-generate-schema-docs 1.1.1 → 1.3.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/README.md +60 -2
- package/__tests__/ExampleDataLayer.test.js +92 -0
- package/__tests__/__fixtures__/static/schemas/add-to-cart-event.json +44 -0
- package/__tests__/__fixtures__/static/schemas/choice-event.json +72 -0
- package/__tests__/__fixtures__/static/schemas/components/dataLayer.json +56 -0
- package/__tests__/__fixtures__/static/schemas/components/product.json +125 -0
- package/__tests__/__fixtures__/static/schemas/nested/child-event.json +10 -0
- package/__tests__/__fixtures__/static/schemas/nested/grandchild-a.json +9 -0
- package/__tests__/__fixtures__/static/schemas/nested/grandchild-b.json +9 -0
- package/__tests__/__fixtures__/static/schemas/nested/parent-event.json +7 -0
- package/__tests__/__fixtures__/static/schemas/root-any-of-event.json +34 -0
- package/__tests__/__fixtures__/static/schemas/root-choice-event.json +36 -0
- package/__tests__/__fixtures__/validateSchemas/circular-schema.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/components/referenced.json +10 -0
- package/__tests__/__fixtures__/validateSchemas/invalid-example-schema.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/main-schema-with-missing-ref.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/main-schema-with-ref.json +8 -0
- package/__tests__/__fixtures__/validateSchemas/no-example-schema.json +12 -0
- package/__tests__/__fixtures__/validateSchemas/schema-A.json +7 -0
- package/__tests__/__fixtures__/validateSchemas/schema-B.json +7 -0
- package/__tests__/__fixtures__/validateSchemas/valid-schema.json +8 -0
- package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/add-to-cart-event.json +44 -0
- package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/components/dataLayer.json +56 -0
- package/__tests__/__fixtures_versioned__/static/schemas/1.1.1/components/product.json +125 -0
- package/__tests__/__fixtures_versioned__/static/schemas/next/add-to-cart-event.json +44 -0
- package/__tests__/__fixtures_versioned__/static/schemas/next/components/dataLayer.json +56 -0
- package/__tests__/__fixtures_versioned__/static/schemas/next/components/product.json +125 -0
- package/__tests__/__fixtures_versioned__/versions.json +1 -0
- package/__tests__/__snapshots__/ExampleDataLayer.test.js.snap +117 -0
- package/__tests__/__snapshots__/generateEventDocs.nested.test.js.snap +92 -0
- package/__tests__/__snapshots__/generateEventDocs.test.js.snap +151 -0
- package/__tests__/__snapshots__/generateEventDocs.versioned.test.js.snap +53 -0
- package/__tests__/components/FoldableRows.test.js +330 -0
- package/__tests__/components/PropertiesTable.test.js +41 -0
- package/__tests__/components/PropertyRow.test.js +487 -0
- package/__tests__/components/SchemaJsonViewer.test.js +36 -0
- package/__tests__/components/SchemaRows.test.js +110 -0
- package/__tests__/components/SchemaViewer.test.js +44 -0
- package/__tests__/components/TableHeader.test.js +20 -0
- package/__tests__/generateEventDocs.nested.test.js +80 -0
- package/__tests__/generateEventDocs.test.js +90 -0
- package/__tests__/generateEventDocs.versioned.test.js +69 -0
- package/__tests__/helpers/buildExampleFromSchema.test.js +188 -0
- package/__tests__/helpers/file-system.test.js +44 -0
- package/__tests__/helpers/getConstraints.test.js +58 -0
- package/__tests__/helpers/loadSchema.test.js +20 -0
- package/__tests__/helpers/path-helpers.test.js +34 -0
- package/__tests__/helpers/processSchema.test.js +56 -0
- package/__tests__/helpers/schema-processing.test.js +82 -0
- package/__tests__/helpers/schemaToExamples.test.js +56 -0
- package/__tests__/helpers/schemaToTableData.filtering.test.js +65 -0
- package/__tests__/helpers/schemaToTableData.hierarchicalLines.test.js +539 -0
- package/__tests__/helpers/schemaToTableData.test.js +222 -0
- package/__tests__/helpers/update-schema-ids.test.js +107 -0
- package/__tests__/update-schema-ids.test.js +39 -0
- package/__tests__/validateSchemas.test.js +137 -0
- package/components/ExampleDataLayer.js +60 -27
- package/components/FoldableRows.js +164 -0
- package/components/PropertiesTable.js +12 -14
- package/components/PropertyRow.js +183 -0
- package/components/SchemaJsonViewer.js +8 -7
- package/components/SchemaRows.css +250 -0
- package/components/SchemaRows.js +24 -69
- package/components/SchemaViewer.js +21 -13
- package/components/TableHeader.js +15 -0
- package/generateEventDocs.js +141 -60
- package/helpers/buildExampleFromSchema.js +59 -73
- package/helpers/choice-index-template.js +22 -0
- package/helpers/file-system.js +32 -0
- package/helpers/getConstraints.js +52 -0
- package/helpers/loadSchema.js +11 -0
- package/helpers/path-helpers.js +22 -0
- package/helpers/processSchema.js +32 -0
- package/helpers/schema-doc-template.js +36 -0
- package/helpers/schema-processing.js +75 -0
- package/helpers/schemaToExamples.js +99 -0
- package/helpers/schemaToTableData.js +311 -0
- package/helpers/update-schema-ids.js +47 -0
- package/index.js +146 -47
- package/package.json +6 -3
- package/validateSchemas.js +56 -70
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import SchemaRows from './SchemaRows';
|
|
3
|
+
import Heading from '@theme/Heading';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates inline styles for continuing hierarchical lines through a row.
|
|
8
|
+
* @param {number[]} continuingLevels - Array of ancestor levels that need lines
|
|
9
|
+
* @param {number} level - Current level of the choice
|
|
10
|
+
* @returns {object} Style object with background gradients
|
|
11
|
+
*/
|
|
12
|
+
const getContinuingLinesStyle = (continuingLevels = [], level = 0) => {
|
|
13
|
+
const getLevelPosition = (lvl) => lvl * 1.25 + 0.5;
|
|
14
|
+
|
|
15
|
+
const allGradients = [];
|
|
16
|
+
const allSizes = [];
|
|
17
|
+
const allPositions = [];
|
|
18
|
+
|
|
19
|
+
// Draw continuing lines for all ancestor levels
|
|
20
|
+
continuingLevels.forEach((lvl) => {
|
|
21
|
+
const pos = getLevelPosition(lvl);
|
|
22
|
+
allGradients.push(
|
|
23
|
+
'linear-gradient(var(--ifm-table-border-color), var(--ifm-table-border-color))',
|
|
24
|
+
);
|
|
25
|
+
allSizes.push('1px 100%');
|
|
26
|
+
allPositions.push(`${pos}rem top`);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Also draw the line for the immediate parent level (level - 1) if level > 0
|
|
30
|
+
// This connects the choice rows to their parent property
|
|
31
|
+
if (level > 0) {
|
|
32
|
+
const parentPos = getLevelPosition(level - 1);
|
|
33
|
+
// Check if this position is not already in continuing levels
|
|
34
|
+
if (!continuingLevels.includes(level - 1)) {
|
|
35
|
+
allGradients.push(
|
|
36
|
+
'linear-gradient(var(--ifm-table-border-color), var(--ifm-table-border-color))',
|
|
37
|
+
);
|
|
38
|
+
allSizes.push('1px 100%');
|
|
39
|
+
allPositions.push(`${parentPos}rem top`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Calculate indentation based on level
|
|
44
|
+
const paddingLeft = `${level * 1.25 + 0.5}rem`;
|
|
45
|
+
|
|
46
|
+
if (allGradients.length === 0) {
|
|
47
|
+
return { paddingLeft };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
paddingLeft,
|
|
52
|
+
backgroundImage: allGradients.join(', '),
|
|
53
|
+
backgroundSize: allSizes.join(', '),
|
|
54
|
+
backgroundPosition: allPositions.join(', '),
|
|
55
|
+
backgroundRepeat: 'no-repeat',
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// A clickable row that acts as a header/summary for a foldable choice
|
|
60
|
+
const ChoiceRow = ({
|
|
61
|
+
title,
|
|
62
|
+
description,
|
|
63
|
+
onToggle,
|
|
64
|
+
isActive,
|
|
65
|
+
isRadio,
|
|
66
|
+
name,
|
|
67
|
+
continuingLinesStyle,
|
|
68
|
+
}) => (
|
|
69
|
+
<tr className="choice-row">
|
|
70
|
+
<td colSpan={5} style={continuingLinesStyle}>
|
|
71
|
+
<label className="choice-row-header">
|
|
72
|
+
<input
|
|
73
|
+
type={isRadio ? 'radio' : 'checkbox'}
|
|
74
|
+
name={name}
|
|
75
|
+
checked={isActive}
|
|
76
|
+
onChange={onToggle}
|
|
77
|
+
/>
|
|
78
|
+
<span
|
|
79
|
+
className={clsx('choice-row-toggle', isRadio ? 'radio' : 'checkbox')}
|
|
80
|
+
/>
|
|
81
|
+
<strong>{title}</strong>
|
|
82
|
+
</label>
|
|
83
|
+
{description && <p className="choice-row-description">{description}</p>}
|
|
84
|
+
</td>
|
|
85
|
+
</tr>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Renders 'oneOf' and 'anyOf' choices as a set of foldable `<tr>` elements
|
|
90
|
+
* that integrate directly into the main table body.
|
|
91
|
+
*/
|
|
92
|
+
export default function FoldableRows({ row }) {
|
|
93
|
+
const {
|
|
94
|
+
choiceType,
|
|
95
|
+
options,
|
|
96
|
+
description,
|
|
97
|
+
name,
|
|
98
|
+
required,
|
|
99
|
+
level = 0,
|
|
100
|
+
continuingLevels = [],
|
|
101
|
+
} = row;
|
|
102
|
+
const [openOneOf, setOpenOneOf] = useState(0); // For oneOf, track the single open index
|
|
103
|
+
const [openAnyOf, setOpenAnyOf] = useState({}); // For anyOf, track each option's state
|
|
104
|
+
|
|
105
|
+
const handleAnyOfToggle = (index) => {
|
|
106
|
+
setOpenAnyOf((prev) => ({ ...prev, [index]: !prev[index] }));
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const selectTitle = `Select ${
|
|
110
|
+
choiceType === 'oneOf' ? 'one' : 'any'
|
|
111
|
+
} of the following options:`;
|
|
112
|
+
const header = name ? (
|
|
113
|
+
<>
|
|
114
|
+
<strong>{name}</strong>
|
|
115
|
+
{required && <span className="required-badge">required</span>}
|
|
116
|
+
{' - '}
|
|
117
|
+
{selectTitle}
|
|
118
|
+
</>
|
|
119
|
+
) : (
|
|
120
|
+
selectTitle
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// Calculate continuing lines style for choice rows
|
|
124
|
+
const continuingLinesStyle = getContinuingLinesStyle(continuingLevels, level);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<>
|
|
128
|
+
{/* A header row for the entire choice block */}
|
|
129
|
+
<tr>
|
|
130
|
+
<td colSpan={5} style={continuingLinesStyle}>
|
|
131
|
+
<Heading as="h4" className="choice-row-header-headline">
|
|
132
|
+
{header}
|
|
133
|
+
</Heading>
|
|
134
|
+
<p className="choice-row-header-description">{description}</p>
|
|
135
|
+
</td>
|
|
136
|
+
</tr>
|
|
137
|
+
|
|
138
|
+
{/* Render the options */}
|
|
139
|
+
{options.map((option, index) => {
|
|
140
|
+
const isActive =
|
|
141
|
+
choiceType === 'oneOf' ? openOneOf === index : !!openAnyOf[index];
|
|
142
|
+
return (
|
|
143
|
+
<React.Fragment key={option.title}>
|
|
144
|
+
<ChoiceRow
|
|
145
|
+
title={option.title}
|
|
146
|
+
description={option.description}
|
|
147
|
+
onToggle={() =>
|
|
148
|
+
choiceType === 'oneOf'
|
|
149
|
+
? setOpenOneOf(index)
|
|
150
|
+
: handleAnyOfToggle(index)
|
|
151
|
+
}
|
|
152
|
+
isActive={isActive}
|
|
153
|
+
isRadio={choiceType === 'oneOf'}
|
|
154
|
+
name={choiceType === 'oneOf' ? row.title : option.title}
|
|
155
|
+
continuingLinesStyle={continuingLinesStyle}
|
|
156
|
+
/>
|
|
157
|
+
{/* If the option is active, render its rows directly into the table body */}
|
|
158
|
+
{isActive && <SchemaRows tableData={option.rows} />}
|
|
159
|
+
</React.Fragment>
|
|
160
|
+
);
|
|
161
|
+
})}
|
|
162
|
+
</>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import SchemaRows from './SchemaRows';
|
|
3
|
+
import TableHeader from './TableHeader';
|
|
4
|
+
import { schemaToTableData } from '../helpers/schemaToTableData';
|
|
2
5
|
|
|
3
6
|
export default function PropertiesTable({ schema }) {
|
|
7
|
+
const tableData = schemaToTableData(schema);
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<th with="15%">Examples</th>
|
|
12
|
-
<th>Description</th>
|
|
13
|
-
</tr>
|
|
14
|
-
</thead>
|
|
15
|
-
<tbody>
|
|
16
|
-
<SchemaRows properties={schema.properties} requiredList={schema.required} />
|
|
17
|
-
</tbody>
|
|
9
|
+
return (
|
|
10
|
+
<table>
|
|
11
|
+
<TableHeader />
|
|
12
|
+
<tbody>
|
|
13
|
+
<SchemaRows tableData={tableData} />
|
|
14
|
+
</tbody>
|
|
18
15
|
</table>
|
|
19
|
-
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Formats an example value into a string for display in a CodeBlock.
|
|
7
|
+
* - Objects are stringified with indentation.
|
|
8
|
+
* - Arrays are joined by newlines.
|
|
9
|
+
* @param {any} example The example to format.
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
const formatExample = (example) => {
|
|
13
|
+
if (typeof example === 'undefined' || example === null) return '';
|
|
14
|
+
if (Array.isArray(example)) {
|
|
15
|
+
return example
|
|
16
|
+
.map((ex) =>
|
|
17
|
+
typeof ex === 'object' ? JSON.stringify(ex, null, 2) : String(ex),
|
|
18
|
+
)
|
|
19
|
+
.join('\n');
|
|
20
|
+
}
|
|
21
|
+
if (typeof example === 'object') {
|
|
22
|
+
return JSON.stringify(example, null, 2);
|
|
23
|
+
}
|
|
24
|
+
return String(example);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the container symbol for a property based on its container type.
|
|
29
|
+
* @param {string|null} containerType - 'object', 'array', or null
|
|
30
|
+
* @returns {string} The symbol to display
|
|
31
|
+
*/
|
|
32
|
+
const getContainerSymbol = (containerType) => {
|
|
33
|
+
if (containerType === 'object') return '{}';
|
|
34
|
+
if (containerType === 'array') return '[]';
|
|
35
|
+
return '';
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Renders a single property row in the schema table.
|
|
40
|
+
* All data is passed in via the `row` prop, which comes from `tableData`.
|
|
41
|
+
* This component handles multi-row constraints using `rowSpan`.
|
|
42
|
+
*/
|
|
43
|
+
export default function PropertyRow({ row, isLastInGroup }) {
|
|
44
|
+
const {
|
|
45
|
+
name,
|
|
46
|
+
level,
|
|
47
|
+
required,
|
|
48
|
+
propertyType,
|
|
49
|
+
description,
|
|
50
|
+
example,
|
|
51
|
+
constraints,
|
|
52
|
+
hasChildren,
|
|
53
|
+
containerType,
|
|
54
|
+
continuingLevels = [],
|
|
55
|
+
} = row;
|
|
56
|
+
|
|
57
|
+
const indentStyle = {
|
|
58
|
+
paddingLeft: `${level * 1.25 + 0.5}rem`,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const hasConstraints = constraints && constraints.length > 0;
|
|
62
|
+
// Set rowspan to 1 if there are no constraints.
|
|
63
|
+
const rowSpan = hasConstraints ? constraints.length : 1;
|
|
64
|
+
// Gracefully handle case with no constraints
|
|
65
|
+
const [firstConstraint, ...remainingConstraints] = hasConstraints
|
|
66
|
+
? constraints
|
|
67
|
+
: [null];
|
|
68
|
+
const formattedExample = formatExample(example);
|
|
69
|
+
|
|
70
|
+
// Generate background gradients for:
|
|
71
|
+
// 1. Parent-to-child line (from 50% down) - for elements with children
|
|
72
|
+
// 2. Continuing ancestor lines (full height) - for ancestors that have more siblings below
|
|
73
|
+
//
|
|
74
|
+
// Position mapping: level N's line is at position (N * 1.25 + 0.5)rem
|
|
75
|
+
// This matches the CSS: level-1 at 0.5rem, level-2 at 1.75rem, etc.
|
|
76
|
+
const getLevelPosition = (lvl) => lvl * 1.25 + 0.5;
|
|
77
|
+
|
|
78
|
+
const allGradients = [];
|
|
79
|
+
const allSizes = [];
|
|
80
|
+
const allPositions = [];
|
|
81
|
+
|
|
82
|
+
// Parent-to-child line: draws from 50% (below symbol) to bottom of cell
|
|
83
|
+
// Position is at the child's level, which is (level * 20 + 8)px
|
|
84
|
+
if (hasChildren) {
|
|
85
|
+
const childLevelPos = level * 1.25 + 0.5;
|
|
86
|
+
allGradients.push(
|
|
87
|
+
'linear-gradient(to bottom, transparent calc(50% + 1em), var(--ifm-table-border-color) calc(50% + 1em))',
|
|
88
|
+
);
|
|
89
|
+
allSizes.push('1px 100%');
|
|
90
|
+
allPositions.push(`${childLevelPos}rem top`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Continuing ancestor lines: full-height vertical lines for ancestors with more siblings
|
|
94
|
+
// Filter to only include levels less than (level - 1) since ::before handles immediate parent
|
|
95
|
+
continuingLevels
|
|
96
|
+
.filter((lvl) => lvl < level - 1)
|
|
97
|
+
.forEach((lvl) => {
|
|
98
|
+
const pos = getLevelPosition(lvl);
|
|
99
|
+
allGradients.push(
|
|
100
|
+
'linear-gradient(var(--ifm-table-border-color), var(--ifm-table-border-color))',
|
|
101
|
+
);
|
|
102
|
+
allSizes.push('1px 100%');
|
|
103
|
+
allPositions.push(`${pos}rem top`);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const continuingLinesStyle =
|
|
107
|
+
allGradients.length > 0
|
|
108
|
+
? {
|
|
109
|
+
backgroundImage: allGradients.join(', '),
|
|
110
|
+
backgroundSize: allSizes.join(', '),
|
|
111
|
+
backgroundPosition: allPositions.join(', '),
|
|
112
|
+
backgroundRepeat: 'no-repeat',
|
|
113
|
+
}
|
|
114
|
+
: {};
|
|
115
|
+
|
|
116
|
+
const containerSymbol = getContainerSymbol(containerType);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
<tr className={clsx(required && 'required-row')}>
|
|
121
|
+
<td
|
|
122
|
+
rowSpan={rowSpan}
|
|
123
|
+
style={{ ...indentStyle, ...continuingLinesStyle }}
|
|
124
|
+
className={clsx(
|
|
125
|
+
level > 0 && `level-${level}`,
|
|
126
|
+
isLastInGroup && 'is-last',
|
|
127
|
+
hasChildren && 'has-children',
|
|
128
|
+
containerType && `container-${containerType}`,
|
|
129
|
+
)}
|
|
130
|
+
>
|
|
131
|
+
<span className="property-name">
|
|
132
|
+
{containerSymbol && (
|
|
133
|
+
<span className="container-symbol">{containerSymbol}</span>
|
|
134
|
+
)}
|
|
135
|
+
<strong>{name}</strong>
|
|
136
|
+
</span>
|
|
137
|
+
</td>
|
|
138
|
+
<td rowSpan={rowSpan}>
|
|
139
|
+
<code>{propertyType}</code>
|
|
140
|
+
</td>
|
|
141
|
+
|
|
142
|
+
{/* The first constraint cell */}
|
|
143
|
+
<td>
|
|
144
|
+
{firstConstraint && (
|
|
145
|
+
<code
|
|
146
|
+
className={clsx(
|
|
147
|
+
'constraint-code',
|
|
148
|
+
firstConstraint === 'required' && 'required',
|
|
149
|
+
)}
|
|
150
|
+
>
|
|
151
|
+
{firstConstraint}
|
|
152
|
+
</code>
|
|
153
|
+
)}
|
|
154
|
+
</td>
|
|
155
|
+
|
|
156
|
+
<td rowSpan={rowSpan}>
|
|
157
|
+
{formattedExample && (
|
|
158
|
+
<CodeBlock language="json" className="schema-examples">
|
|
159
|
+
{formattedExample}
|
|
160
|
+
</CodeBlock>
|
|
161
|
+
)}
|
|
162
|
+
</td>
|
|
163
|
+
<td rowSpan={rowSpan}>{description || ''}</td>
|
|
164
|
+
</tr>
|
|
165
|
+
|
|
166
|
+
{/* Render subsequent constraints in their own rows */}
|
|
167
|
+
{remainingConstraints.map((constraint) => (
|
|
168
|
+
<tr className={clsx(required && 'required-row')} key={constraint}>
|
|
169
|
+
<td>
|
|
170
|
+
<code
|
|
171
|
+
className={clsx(
|
|
172
|
+
'constraint-code',
|
|
173
|
+
constraint === 'required' && 'required',
|
|
174
|
+
)}
|
|
175
|
+
>
|
|
176
|
+
{constraint}
|
|
177
|
+
</code>
|
|
178
|
+
</td>
|
|
179
|
+
</tr>
|
|
180
|
+
))}
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import CodeBlock from '@theme/CodeBlock';
|
|
2
3
|
|
|
3
4
|
export default function SchemaJsonViewer({ schema }) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
5
|
+
return (
|
|
6
|
+
<details className="schema-json-viewer">
|
|
7
|
+
<summary>View Raw JSON Schema</summary>
|
|
8
|
+
<CodeBlock language="json">{JSON.stringify(schema, null, 2)}</CodeBlock>
|
|
9
|
+
</details>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
.required-row {
|
|
2
|
+
background-color: rgba(var(--ifm-color-danger-rgb), 0.05);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.constraint-code {
|
|
6
|
+
white-space: pre-wrap;
|
|
7
|
+
margin-right: 4px;
|
|
8
|
+
display: inline-block;
|
|
9
|
+
margin-bottom: 4px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.constraint-code.required {
|
|
13
|
+
font-weight: bold;
|
|
14
|
+
color: var(--ifm-color-danger-dark);
|
|
15
|
+
background-color: var(--ifm-color-danger-lightest);
|
|
16
|
+
padding: 2px 4px;
|
|
17
|
+
border-radius: 4px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.nested-table-container {
|
|
21
|
+
padding-left: 1.25rem;
|
|
22
|
+
border-left: 0.25rem solid var(--ifm-table-border-color);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.schema-json-viewer {
|
|
26
|
+
margin-bottom: 1em;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* --- Property Name and Container Symbol Styles --- */
|
|
30
|
+
|
|
31
|
+
.property-name {
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
align-items: baseline;
|
|
34
|
+
gap: 4px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.container-symbol {
|
|
38
|
+
font-family: var(--ifm-font-family-monospace);
|
|
39
|
+
font-size: 0.9em;
|
|
40
|
+
color: var(--ifm-color-emphasis-600);
|
|
41
|
+
font-weight: bold;
|
|
42
|
+
margin-left: -0.55em;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* --- Organigram Connector Line Styles --- */
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* Strategy:
|
|
49
|
+
* - ::before = vertical line from parent (top to bottom, or top to 50% for last items)
|
|
50
|
+
* - ::after = horizontal connector (from vertical line to property name)
|
|
51
|
+
* - background-image = parent-to-child lines (from 50% down) + continuing ancestor lines
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/* Base positioning */
|
|
55
|
+
td[class*='level-'],
|
|
56
|
+
td.has-children {
|
|
57
|
+
position: relative;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
* VERTICAL LINE (::before)
|
|
62
|
+
* Connects this row to its parent and siblings.
|
|
63
|
+
* Runs from top to bottom (or to 50% for last items in group).
|
|
64
|
+
*/
|
|
65
|
+
td[class*='level-']::before {
|
|
66
|
+
content: '';
|
|
67
|
+
position: absolute;
|
|
68
|
+
top: 0;
|
|
69
|
+
bottom: 0;
|
|
70
|
+
width: 0;
|
|
71
|
+
border-left: 1px solid var(--ifm-table-border-color);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Last items: stop vertical line at middle */
|
|
75
|
+
td.is-last[class*='level-']::before {
|
|
76
|
+
bottom: 50%;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
* HORIZONTAL CONNECTOR (::after)
|
|
81
|
+
* Connects vertical line to the property name.
|
|
82
|
+
*/
|
|
83
|
+
td[class*='level-']::after {
|
|
84
|
+
content: '';
|
|
85
|
+
position: absolute;
|
|
86
|
+
top: 50%;
|
|
87
|
+
height: 0;
|
|
88
|
+
width: 0.75rem;
|
|
89
|
+
border-bottom: 1px solid var(--ifm-table-border-color);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* --- Level-based positioning --- */
|
|
93
|
+
|
|
94
|
+
td.level-1::before,
|
|
95
|
+
td.level-1::after {
|
|
96
|
+
left: 0.5rem;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
td.level-2::before,
|
|
100
|
+
td.level-2::after {
|
|
101
|
+
left: 1.75rem;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
td.level-3::before,
|
|
105
|
+
td.level-3::after {
|
|
106
|
+
left: 3rem;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
td.level-4::before,
|
|
110
|
+
td.level-4::after {
|
|
111
|
+
left: 4.25rem;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
td.level-5::before,
|
|
115
|
+
td.level-5::after {
|
|
116
|
+
left: 5.5rem;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
td.level-6::before,
|
|
120
|
+
td.level-6::after {
|
|
121
|
+
left: 6.75rem;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
* Note: Parent-to-child lines and continuing ancestor lines are now
|
|
126
|
+
* handled via inline styles in PropertyRow.js using background gradients.
|
|
127
|
+
* This allows dynamic combination of multiple line levels.
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
/* --- Choice Row Styles --- */
|
|
131
|
+
|
|
132
|
+
.choice-row {
|
|
133
|
+
background-color: var(--ifm-table-stripe-background);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.choice-row:hover {
|
|
137
|
+
background-color: var(--ifm-hover-overlay);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.choice-row-header {
|
|
141
|
+
position: relative;
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
cursor: pointer;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.choice-row-header input {
|
|
148
|
+
position: absolute;
|
|
149
|
+
opacity: 0;
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: 100%;
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.choice-row-description {
|
|
156
|
+
margin-left: 28px;
|
|
157
|
+
font-size: 0.9em;
|
|
158
|
+
color: var(--ifm-color-secondary-darkest);
|
|
159
|
+
}
|
|
160
|
+
.choice-row-header-description {
|
|
161
|
+
font-size: 0.9em;
|
|
162
|
+
color: var(--ifm-color-secondary-darkest);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.choice-row-header-headline {
|
|
166
|
+
margin-bottom: 0px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.choice-row-toggle {
|
|
170
|
+
display: inline-block;
|
|
171
|
+
width: 1rem;
|
|
172
|
+
height: 1rem;
|
|
173
|
+
margin-right: 0.75rem;
|
|
174
|
+
border: 1px solid var(--ifm-color-emphasis-400);
|
|
175
|
+
flex-shrink: 0;
|
|
176
|
+
position: relative;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.choice-row-toggle.radio {
|
|
180
|
+
border-radius: 50%;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.choice-row-toggle.checkbox {
|
|
184
|
+
border-radius: 0.25rem;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.choice-row-toggle.checkbox::after {
|
|
188
|
+
content: '';
|
|
189
|
+
position: absolute;
|
|
190
|
+
display: none;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.choice-row-header input:checked + .choice-row-toggle.radio {
|
|
194
|
+
border-color: var(--ifm-color-primary-dark);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.choice-row-toggle.radio::after {
|
|
198
|
+
content: '';
|
|
199
|
+
position: absolute;
|
|
200
|
+
display: none;
|
|
201
|
+
border-radius: 50%;
|
|
202
|
+
background-color: var(--ifm-color-primary);
|
|
203
|
+
width: 0.5em;
|
|
204
|
+
height: 0.5em;
|
|
205
|
+
left: 22%;
|
|
206
|
+
top: 22%;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.choice-row-header input:checked + .choice-row-toggle.radio::after {
|
|
210
|
+
display: block;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.choice-row-header input:checked + .choice-row-toggle.checkbox {
|
|
214
|
+
border-color: var(--ifm-color-primary-dark);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.choice-row-header input:checked + .choice-row-toggle.checkbox::after {
|
|
218
|
+
display: block;
|
|
219
|
+
left: 0.29em;
|
|
220
|
+
top: 0.125rem;
|
|
221
|
+
width: 0.1875rem;
|
|
222
|
+
height: 0.4375rem;
|
|
223
|
+
border: solid var(--ifm-color-primary);
|
|
224
|
+
border-width: 0 0.125rem 0.125rem 0;
|
|
225
|
+
transform: rotate(45deg);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* --- Example CodeBlock Styles --- */
|
|
229
|
+
|
|
230
|
+
.schema-examples {
|
|
231
|
+
margin: 0;
|
|
232
|
+
font-size: 0.85em;
|
|
233
|
+
white-space: pre-wrap;
|
|
234
|
+
/* Override theme defaults to make it blend into the table cell */
|
|
235
|
+
background-color: transparent !important;
|
|
236
|
+
box-shadow: none !important;
|
|
237
|
+
border: none !important;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.schema-examples pre,
|
|
241
|
+
.schema-examples code {
|
|
242
|
+
margin: 0 !important;
|
|
243
|
+
padding: 0 !important;
|
|
244
|
+
background-color: transparent !important;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* Hide the copy button within the examples code block */
|
|
248
|
+
.schema-examples button {
|
|
249
|
+
display: none;
|
|
250
|
+
}
|