docusaurus-plugin-generate-schema-docs 1.5.4 → 1.7.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 (38) hide show
  1. package/__tests__/__fixtures__/static/schemas/battle-test-event.json +771 -0
  2. package/__tests__/__fixtures__/static/schemas/conditional-event.json +52 -0
  3. package/__tests__/__fixtures__/static/schemas/nested-conditional-event.json +50 -0
  4. package/__tests__/__snapshots__/generateEventDocs.anchor.test.js.snap +3 -2
  5. package/__tests__/__snapshots__/generateEventDocs.nested.test.js.snap +4 -2
  6. package/__tests__/__snapshots__/generateEventDocs.test.js.snap +3 -2
  7. package/__tests__/components/ConditionalRows.test.js +150 -0
  8. package/__tests__/components/ConnectorLines.visualRegression.test.js +93 -0
  9. package/__tests__/components/FoldableRows.test.js +7 -4
  10. package/__tests__/components/SchemaRows.test.js +31 -0
  11. package/__tests__/components/__snapshots__/ConnectorLines.visualRegression.test.js.snap +7 -0
  12. package/__tests__/generateEventDocs.anchor.test.js +7 -0
  13. package/__tests__/generateEventDocs.nested.test.js +7 -0
  14. package/__tests__/generateEventDocs.partials.test.js +134 -0
  15. package/__tests__/generateEventDocs.test.js +7 -0
  16. package/__tests__/helpers/buildExampleFromSchema.test.js +49 -0
  17. package/__tests__/helpers/schemaToExamples.test.js +75 -0
  18. package/__tests__/helpers/schemaToTableData.battleTest.test.js +704 -0
  19. package/__tests__/helpers/schemaToTableData.hierarchicalLines.test.js +190 -7
  20. package/__tests__/helpers/schemaToTableData.test.js +263 -2
  21. package/__tests__/helpers/validator.test.js +6 -6
  22. package/components/ConditionalRows.js +156 -0
  23. package/components/FoldableRows.js +88 -61
  24. package/components/PropertiesTable.js +1 -1
  25. package/components/PropertyRow.js +24 -8
  26. package/components/SchemaRows.css +115 -0
  27. package/components/SchemaRows.js +31 -4
  28. package/generateEventDocs.js +55 -37
  29. package/helpers/buildExampleFromSchema.js +11 -0
  30. package/helpers/choice-index-template.js +2 -1
  31. package/helpers/continuingLinesStyle.js +169 -0
  32. package/helpers/schema-doc-template.js +2 -5
  33. package/helpers/schema-processing.js +3 -0
  34. package/helpers/schemaToExamples.js +75 -2
  35. package/helpers/schemaToTableData.js +252 -26
  36. package/helpers/update-schema-ids.js +3 -3
  37. package/helpers/validator.js +7 -19
  38. package/package.json +3 -2
@@ -0,0 +1,52 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tracking-docs-demo.buchert.digital/schemas/events/conditional-event.json",
4
+ "title": "Conditional Event",
5
+ "description": "An event with conditional properties based on country.",
6
+ "type": "object",
7
+ "properties": {
8
+ "event": {
9
+ "type": "string",
10
+ "const": "form_submit"
11
+ },
12
+ "country": {
13
+ "type": "string",
14
+ "description": "The user's country.",
15
+ "enum": ["US", "CA"],
16
+ "examples": ["US"]
17
+ }
18
+ },
19
+ "required": ["event", "country"],
20
+ "if": {
21
+ "properties": {
22
+ "country": { "const": "US" }
23
+ },
24
+ "required": ["country"]
25
+ },
26
+ "then": {
27
+ "properties": {
28
+ "postal_code": {
29
+ "type": "string",
30
+ "description": "US ZIP code format.",
31
+ "pattern": "[0-9]{5}",
32
+ "examples": ["90210"]
33
+ },
34
+ "state": {
35
+ "type": "string",
36
+ "description": "US state abbreviation.",
37
+ "examples": ["CA"]
38
+ }
39
+ },
40
+ "required": ["postal_code"]
41
+ },
42
+ "else": {
43
+ "properties": {
44
+ "postal_code": {
45
+ "type": "string",
46
+ "description": "Canadian postal code format.",
47
+ "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]",
48
+ "examples": ["K1A 0B1"]
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tracking-docs-demo.buchert.digital/schemas/events/nested-conditional-event.json",
4
+ "title": "Nested Conditional Event",
5
+ "description": "An event with conditional properties nested inside a property.",
6
+ "type": "object",
7
+ "properties": {
8
+ "event": {
9
+ "type": "string",
10
+ "const": "order_placed"
11
+ },
12
+ "shipping": {
13
+ "type": "object",
14
+ "description": "Shipping details.",
15
+ "properties": {
16
+ "method": {
17
+ "type": "string",
18
+ "description": "The shipping method.",
19
+ "examples": ["express"]
20
+ }
21
+ },
22
+ "required": ["method"],
23
+ "if": {
24
+ "properties": {
25
+ "method": { "const": "express" }
26
+ },
27
+ "required": ["method"]
28
+ },
29
+ "then": {
30
+ "properties": {
31
+ "priority_level": {
32
+ "type": "string",
33
+ "description": "Express priority level.",
34
+ "examples": ["high"]
35
+ }
36
+ }
37
+ },
38
+ "else": {
39
+ "properties": {
40
+ "estimated_days": {
41
+ "type": "integer",
42
+ "description": "Estimated delivery days.",
43
+ "examples": [5]
44
+ }
45
+ }
46
+ }
47
+ }
48
+ },
49
+ "required": ["event", "shipping"]
50
+ }
@@ -4,6 +4,7 @@ exports[`generateEventDocs (oneOf with $anchor) should generate documentation us
4
4
  "---
5
5
  title: Parent Event Anchor
6
6
  description: "This is a parent event with oneOf."
7
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/static/schemas/parent-event-anchor.json
7
8
  ---
8
9
  import SchemaJsonViewer from '@theme/SchemaJsonViewer';
9
10
 
@@ -25,7 +26,7 @@ exports[`generateEventDocs (oneOf with $anchor) should generate documentation us
25
26
  title: Child Event Anchor
26
27
  description: "This is a child event with an anchor."
27
28
  sidebar_label: Child Event Anchor
28
- custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/docs/parent-event-anchor/01-child-event-with-anchor.json
29
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/static/schemas/parent-event-anchor.json
29
30
  ---
30
31
 
31
32
  import SchemaViewer from '@theme/SchemaViewer';
@@ -54,7 +55,7 @@ exports[`generateEventDocs (oneOf with $anchor) should generate documentation us
54
55
  title: Child Event Title
55
56
  description: "This is a child event with only a title."
56
57
  sidebar_label: Child Event Title
57
- custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/docs/parent-event-anchor/02-child-event-title.json
58
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/static/schemas/parent-event-anchor.json
58
59
  ---
59
60
 
60
61
  import SchemaViewer from '@theme/SchemaViewer';
@@ -4,6 +4,7 @@ exports[`generateEventDocs (nested oneOf) should generate nested documentation c
4
4
  "---
5
5
  title: Parent Event
6
6
  description: "undefined"
7
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/static/schemas/parent-event.json
7
8
  ---
8
9
  import SchemaJsonViewer from '@theme/SchemaJsonViewer';
9
10
 
@@ -23,6 +24,7 @@ exports[`generateEventDocs (nested oneOf) should generate nested documentation c
23
24
  "---
24
25
  title: Child Event
25
26
  description: "undefined"
27
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/static/schemas/child-event.json
26
28
  ---
27
29
  import SchemaJsonViewer from '@theme/SchemaJsonViewer';
28
30
 
@@ -44,7 +46,7 @@ exports[`generateEventDocs (nested oneOf) should generate nested documentation c
44
46
  title: Grandchild A
45
47
  description: undefined
46
48
  sidebar_label: Grandchild A
47
- custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/docs/parent-event/01-child-event/01-grandchild-a.json
49
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/static/schemas/child-event.json
48
50
  ---
49
51
 
50
52
  import SchemaViewer from '@theme/SchemaViewer';
@@ -73,7 +75,7 @@ exports[`generateEventDocs (nested oneOf) should generate nested documentation c
73
75
  title: Grandchild B
74
76
  description: undefined
75
77
  sidebar_label: Grandchild B
76
- custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/docs/parent-event/01-child-event/02-grandchild-b.json
78
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/static/schemas/child-event.json
77
79
  ---
78
80
 
79
81
  import SchemaViewer from '@theme/SchemaViewer';
@@ -91,6 +91,7 @@ exports[`generateEventDocs (non-versioned) should generate documentation correct
91
91
  "---
92
92
  title: Root Choice Event
93
93
  description: "An example event that has oneOf at the root level."
94
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/static/schemas/root-choice-event.json
94
95
  ---
95
96
  import SchemaJsonViewer from '@theme/SchemaJsonViewer';
96
97
 
@@ -112,7 +113,7 @@ exports[`generateEventDocs (non-versioned) should generate documentation correct
112
113
  title: Option A
113
114
  description: "An example event that has oneOf at the root level."
114
115
  sidebar_label: Option A
115
- custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/docs/root-choice-event/01-option-a.json
116
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/static/schemas/root-choice-event.json
116
117
  ---
117
118
 
118
119
  import SchemaViewer from '@theme/SchemaViewer';
@@ -141,7 +142,7 @@ exports[`generateEventDocs (non-versioned) should generate documentation correct
141
142
  title: Option B
142
143
  description: "An example event that has oneOf at the root level."
143
144
  sidebar_label: Option B
144
- custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/docs/root-choice-event/02-option-b.json
145
+ custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures__/static/schemas/root-choice-event.json
145
146
  ---
146
147
 
147
148
  import SchemaViewer from '@theme/SchemaViewer';
@@ -0,0 +1,150 @@
1
+ import '@testing-library/jest-dom';
2
+ import React from 'react';
3
+ import { render, screen, fireEvent } from '@testing-library/react';
4
+ import ConditionalRows from '../../components/ConditionalRows';
5
+
6
+ jest.mock('../../components/SchemaRows', () => {
7
+ const MockSchemaRows = (props) => (
8
+ <tr data-testid="schema-rows">
9
+ <td>{JSON.stringify(props.tableData)}</td>
10
+ </tr>
11
+ );
12
+ MockSchemaRows.displayName = 'MockSchemaRows';
13
+ return MockSchemaRows;
14
+ });
15
+
16
+ describe('ConditionalRows', () => {
17
+ const conditionalRow = {
18
+ type: 'conditional',
19
+ path: ['if/then/else'],
20
+ level: 0,
21
+ continuingLevels: [],
22
+ condition: {
23
+ title: 'If',
24
+ description: 'When country is US',
25
+ rows: [{ name: 'country', isCondition: true }],
26
+ },
27
+ branches: [
28
+ {
29
+ title: 'Then',
30
+ description: 'US-specific fields',
31
+ rows: [{ name: 'postal_code' }],
32
+ },
33
+ {
34
+ title: 'Else',
35
+ description: 'Non-US fields',
36
+ rows: [{ name: 'province' }],
37
+ },
38
+ ],
39
+ };
40
+
41
+ it('renders condition (if) rows always visible', () => {
42
+ render(
43
+ <table>
44
+ <tbody>
45
+ <ConditionalRows row={conditionalRow} />
46
+ </tbody>
47
+ </table>,
48
+ );
49
+
50
+ expect(screen.getByText('If')).toBeInTheDocument();
51
+ expect(
52
+ screen.getByText(
53
+ JSON.stringify([{ name: 'country', isCondition: true }]),
54
+ ),
55
+ ).toBeInTheDocument();
56
+ });
57
+
58
+ it('shows Then branch by default', () => {
59
+ render(
60
+ <table>
61
+ <tbody>
62
+ <ConditionalRows row={conditionalRow} />
63
+ </tbody>
64
+ </table>,
65
+ );
66
+
67
+ expect(
68
+ screen.getByText(JSON.stringify([{ name: 'postal_code' }])),
69
+ ).toBeInTheDocument();
70
+ expect(
71
+ screen.queryByText(JSON.stringify([{ name: 'province' }])),
72
+ ).not.toBeInTheDocument();
73
+ });
74
+
75
+ it('switches to Else branch when clicked', () => {
76
+ render(
77
+ <table>
78
+ <tbody>
79
+ <ConditionalRows row={conditionalRow} />
80
+ </tbody>
81
+ </table>,
82
+ );
83
+
84
+ // Click the Else toggle
85
+ fireEvent.click(screen.getByText('Else'));
86
+
87
+ // Now Else should be visible and Then should be hidden
88
+ expect(
89
+ screen.queryByText(JSON.stringify([{ name: 'postal_code' }])),
90
+ ).not.toBeInTheDocument();
91
+ expect(
92
+ screen.getByText(JSON.stringify([{ name: 'province' }])),
93
+ ).toBeInTheDocument();
94
+ });
95
+
96
+ it('renders condition description when present', () => {
97
+ render(
98
+ <table>
99
+ <tbody>
100
+ <ConditionalRows row={conditionalRow} />
101
+ </tbody>
102
+ </table>,
103
+ );
104
+
105
+ expect(screen.getByText('When country is US')).toBeInTheDocument();
106
+ });
107
+
108
+ it('applies correct indentation for nested levels', () => {
109
+ const nestedRow = {
110
+ ...conditionalRow,
111
+ level: 2,
112
+ continuingLevels: [0],
113
+ };
114
+
115
+ const { container } = render(
116
+ <table>
117
+ <tbody>
118
+ <ConditionalRows row={nestedRow} />
119
+ </tbody>
120
+ </table>,
121
+ );
122
+
123
+ const cells = container.querySelectorAll('td[colspan="5"]');
124
+ // level 2: 2 * 1.25 + 0.5 = 3rem
125
+ cells.forEach((cell) => {
126
+ expect(cell.style.paddingLeft).toBe('3rem');
127
+ });
128
+ });
129
+
130
+ it('handles conditional with only Then branch (no Else)', () => {
131
+ const rowWithoutElse = {
132
+ ...conditionalRow,
133
+ branches: [conditionalRow.branches[0]],
134
+ };
135
+
136
+ render(
137
+ <table>
138
+ <tbody>
139
+ <ConditionalRows row={rowWithoutElse} />
140
+ </tbody>
141
+ </table>,
142
+ );
143
+
144
+ expect(screen.getByText('Then')).toBeInTheDocument();
145
+ expect(screen.queryByText('Else')).not.toBeInTheDocument();
146
+ expect(
147
+ screen.getByText(JSON.stringify([{ name: 'postal_code' }])),
148
+ ).toBeInTheDocument();
149
+ });
150
+ });
@@ -0,0 +1,93 @@
1
+ import '@testing-library/jest-dom';
2
+ import React from 'react';
3
+ import { fireEvent, render, screen } from '@testing-library/react';
4
+ import FoldableRows from '../../components/FoldableRows';
5
+ import ConditionalRows from '../../components/ConditionalRows';
6
+ import { schemaToTableData } from '../../helpers/schemaToTableData';
7
+ import battleTestSchema from '../__fixtures__/static/schemas/battle-test-event.json';
8
+
9
+ const renderInTable = (ui) =>
10
+ render(
11
+ <table>
12
+ <tbody>{ui}</tbody>
13
+ </table>,
14
+ );
15
+
16
+ const getPropertyCellByName = (container, name) => {
17
+ const strongEls = Array.from(
18
+ container.querySelectorAll('span.property-name > strong'),
19
+ );
20
+ const strong = strongEls.find((el) => el.textContent === name);
21
+ return strong?.closest('td');
22
+ };
23
+
24
+ describe('connector lines visual regressions', () => {
25
+ const rows = schemaToTableData(battleTestSchema);
26
+
27
+ it('keeps user_id option row open when user conditional follows', () => {
28
+ const userIdChoice = rows.find(
29
+ (row) => row.type === 'choice' && row.name === 'user_id',
30
+ );
31
+
32
+ const { container } = renderInTable(<FoldableRows row={userIdChoice} />);
33
+ fireEvent.click(screen.getByText('Integer ID'));
34
+
35
+ const userIdCell = getPropertyCellByName(container, 'user_id');
36
+ expect(userIdCell).toBeInTheDocument();
37
+ expect(userIdCell).not.toHaveClass('is-last');
38
+ expect(userIdCell.outerHTML).toMatchSnapshot();
39
+ });
40
+
41
+ it('keeps wallet_provider option row open when wallet_email follows', () => {
42
+ const paymentChoice = rows.find(
43
+ (row) =>
44
+ row.type === 'choice' &&
45
+ row.path[0] === 'payment' &&
46
+ row.choiceType === 'anyOf',
47
+ );
48
+ const digitalWallet = paymentChoice.options.find(
49
+ (option) => option.title === 'Digital Wallet',
50
+ );
51
+ const walletProviderChoice = digitalWallet.rows.find(
52
+ (row) => row.type === 'choice' && row.name === 'wallet_provider',
53
+ );
54
+
55
+ const { container } = renderInTable(
56
+ <FoldableRows row={walletProviderChoice} />,
57
+ );
58
+ fireEvent.click(screen.getByText('Custom Provider'));
59
+
60
+ const walletProviderCell = getPropertyCellByName(
61
+ container,
62
+ 'wallet_provider',
63
+ );
64
+ expect(walletProviderCell).toBeInTheDocument();
65
+ expect(walletProviderCell).not.toHaveClass('is-last');
66
+ expect(walletProviderCell.outerHTML).toMatchSnapshot();
67
+ });
68
+
69
+ it('keeps cvv row open when payment choice has following options', () => {
70
+ const paymentChoice = rows.find(
71
+ (row) =>
72
+ row.type === 'choice' &&
73
+ row.path[0] === 'payment' &&
74
+ row.choiceType === 'anyOf',
75
+ );
76
+ const creditCard = paymentChoice.options.find(
77
+ (option) => option.title === 'Credit Card',
78
+ );
79
+ const cardConditional = creditCard.rows.find(
80
+ (row) => row.type === 'conditional',
81
+ );
82
+
83
+ const { container } = renderInTable(
84
+ <ConditionalRows row={cardConditional} />,
85
+ );
86
+ fireEvent.click(screen.getByText('Else'));
87
+
88
+ const cvvCell = getPropertyCellByName(container, 'cvv');
89
+ expect(cvvCell).toBeInTheDocument();
90
+ expect(cvvCell).not.toHaveClass('is-last');
91
+ expect(cvvCell.outerHTML).toMatchSnapshot();
92
+ });
93
+ });
@@ -233,7 +233,7 @@ describe('FoldableRows', () => {
233
233
  });
234
234
  });
235
235
 
236
- it('has no background-image for root level choices with no continuing levels', () => {
236
+ it('has a bracket gradient for root level choices with no continuing levels', () => {
237
237
  const rootLevelRow = {
238
238
  type: 'choice',
239
239
  choiceType: 'oneOf',
@@ -241,6 +241,7 @@ describe('FoldableRows', () => {
241
241
  level: 0,
242
242
  description: 'Root level choice',
243
243
  continuingLevels: [],
244
+ groupBrackets: [],
244
245
  options: [
245
246
  {
246
247
  title: 'Option A',
@@ -257,9 +258,10 @@ describe('FoldableRows', () => {
257
258
  </table>,
258
259
  );
259
260
 
261
+ // Root-level choice rows get a bracket gradient even without tree-line continuing levels
260
262
  const cells = container.querySelectorAll('td[colspan="5"]');
261
263
  cells.forEach((cell) => {
262
- expect(cell.style.backgroundImage).toBe('');
264
+ expect(cell.style.backgroundImage).toContain('linear-gradient');
263
265
  });
264
266
  });
265
267
 
@@ -290,9 +292,10 @@ describe('FoldableRows', () => {
290
292
  const cells = container.querySelectorAll('td[colspan="5"]');
291
293
  cells.forEach((cell) => {
292
294
  const bgImage = cell.style.backgroundImage;
293
- // Should have multiple gradients (one for each continuing level + parent)
295
+ // colSpan=5 rows only have bracket lines (right side), not tree lines (left side).
296
+ // Should have exactly 1 bracket gradient.
294
297
  const gradientCount = (bgImage.match(/linear-gradient/g) || []).length;
295
- expect(gradientCount).toBeGreaterThanOrEqual(2);
298
+ expect(gradientCount).toBeGreaterThanOrEqual(1);
296
299
  });
297
300
  });
298
301
 
@@ -24,6 +24,16 @@ jest.mock('../../components/FoldableRows', () => {
24
24
  return MockFoldableRows;
25
25
  });
26
26
 
27
+ jest.mock('../../components/ConditionalRows', () => {
28
+ const MockConditionalRows = (props) => (
29
+ <tr>
30
+ <td>Mocked ConditionalRows: {props.row.condition.title}</td>
31
+ </tr>
32
+ );
33
+ MockConditionalRows.displayName = 'MockConditionalRows';
34
+ return MockConditionalRows;
35
+ });
36
+
27
37
  describe('SchemaRows', () => {
28
38
  it('renders a PropertyRow for each property type item in tableData', () => {
29
39
  const tableData = [
@@ -107,4 +117,25 @@ describe('SchemaRows', () => {
107
117
  expect(getByText('Mocked FoldableRows: anyOf')).toBeInTheDocument();
108
118
  expect(getByText('Mocked PropertyRow: prop2')).toBeInTheDocument();
109
119
  });
120
+
121
+ it('renders a ConditionalRows for conditional type items in tableData', () => {
122
+ const tableData = [
123
+ {
124
+ type: 'conditional',
125
+ path: ['if/then/else'],
126
+ condition: { title: 'If', rows: [] },
127
+ branches: [],
128
+ },
129
+ ];
130
+
131
+ const { getByText } = render(
132
+ <table>
133
+ <tbody>
134
+ <SchemaRows tableData={tableData} />
135
+ </tbody>
136
+ </table>,
137
+ );
138
+
139
+ expect(getByText('Mocked ConditionalRows: If')).toBeInTheDocument();
140
+ });
110
141
  });
@@ -0,0 +1,7 @@
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
+
3
+ exports[`connector lines visual regressions keeps cvv row open when payment choice has following options 1`] = `"<td rowspan="1" style="padding-left: 1.75rem;" class="level-1"><span class="property-name"><strong>cvv</strong></span></td>"`;
4
+
5
+ exports[`connector lines visual regressions keeps user_id option row open when user conditional follows 1`] = `"<td rowspan="1" style="padding-left: 1.75rem;" class="level-1"><span class="property-name"><strong>user_id</strong></span></td>"`;
6
+
7
+ exports[`connector lines visual regressions keeps wallet_provider option row open when wallet_email follows 1`] = `"<td rowspan="2" style="padding-left: 1.75rem;" class="level-1"><span class="property-name"><strong>wallet_provider</strong></span></td>"`;
@@ -61,11 +61,18 @@ describe('generateEventDocs (oneOf with $anchor)', () => {
61
61
  'utf-8',
62
62
  );
63
63
  expect(childWithAnchor).toMatchSnapshot();
64
+ // Inline oneOf options (using $anchor for slug) must link to the parent schema file
65
+ expect(childWithAnchor).toContain(
66
+ 'custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/static/schemas/parent-event-anchor.json',
67
+ );
64
68
 
65
69
  const childWithTitle = fs.readFileSync(
66
70
  path.join(parentDir, '02-child-event-title.mdx'),
67
71
  'utf-8',
68
72
  );
69
73
  expect(childWithTitle).toMatchSnapshot();
74
+ expect(childWithTitle).toContain(
75
+ 'custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_anchor__/static/schemas/parent-event-anchor.json',
76
+ );
70
77
  });
71
78
  });
@@ -70,11 +70,18 @@ describe('generateEventDocs (nested oneOf)', () => {
70
70
  'utf-8',
71
71
  );
72
72
  expect(grandchildA).toMatchSnapshot();
73
+ // Nested $ref-based oneOf options must link to the resolved source schema file
74
+ expect(grandchildA).toContain(
75
+ 'custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/static/schemas/child-event.json',
76
+ );
73
77
 
74
78
  const grandchildB = fs.readFileSync(
75
79
  path.join(childDir, '02-grandchild-b.mdx'),
76
80
  'utf-8',
77
81
  );
78
82
  expect(grandchildB).toMatchSnapshot();
83
+ expect(grandchildB).toContain(
84
+ 'custom_edit_url: https://github.com/test-org/test-project/edit/main/__fixtures_nested__/static/schemas/child-event.json',
85
+ );
79
86
  });
80
87
  });