Skip to content

Commit

Permalink
Fix attributes next to ref not rendered when re-used (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
dblanchette authored May 1, 2024
1 parent c62d0f8 commit a4380d3
Show file tree
Hide file tree
Showing 28 changed files with 36,635 additions and 95 deletions.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# 0.48

(Issue #190) Now correctly display elements next to a `$ref` with reused nodes, e.g.:

```json
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"title": "Example",
"properties": {
"prop1": {
"$ref": "#/$defs/a",
"description": "Prop1",
"examples": ["1"]
},
"prop2": {
"$ref": "#/$defs/a",
"description": "Prop2",
"examples": ["2"]
}
},
"$defs": {
"a": {
"type": "string",
"maxLength": 5
}
}
}
```

Previously, `prop2` would have been a link to `prop1`, hiding the different example for `prop2`.

This may increase the size of rendered schemas in certain situations.
66 changes: 66 additions & 0 deletions docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,72 @@ the description of an attribute
[examples/examples_md_nested_with_badges/ref_merge.md](examples/examples_md_nested_with_badges/ref_merge.md ':include')
</details>

## --ref_with_other_elements--
### ref_with_other_elements


<details>
<summary>Json schema - Click here to expand source code...</summary>

[examples/cases/ref_with_other_elements.json](examples/cases/ref_with_other_elements.json ':include :type=code')
</details>


<details>
<summary>JS template - Click here to expand the rendered result...</summary>
<a href="https://coveooss.github.io/json-schema-for-humans/examples/examples_js_default/ref_with_other_elements.html" target="_blank">Open it in full page</a>

[examples/examples_js_default/ref_with_other_elements.html](examples/examples_js_default/ref_with_other_elements.html ':include :type=iframe width=100% height=400px')
</details>


<details>
<summary>JS Offline template - Click here to expand the rendered result...</summary>
<a href="https://coveooss.github.io/json-schema-for-humans/examples/examples_js_offline_default/ref_with_other_elements.html" target="_blank">Open it in full page</a>

[examples/examples_js_offline_default/ref_with_other_elements.html](examples/examples_js_offline_default/ref_with_other_elements.html ':include :type=iframe width=100% height=400px')
</details>


<details>
<summary>Flat template - Click here to expand the rendered result...</summary>
<a href="https://coveooss.github.io/json-schema-for-humans/examples/examples_flat_default/ref_with_other_elements.html" target="_blank">Open it in full page</a>

[examples/examples_flat_default/ref_with_other_elements.html](examples/examples_flat_default/ref_with_other_elements.html ':include :type=iframe width=100% height=400px')
</details>


<details>
<summary>Markdown without badge template - Click here to expand the rendered result...</summary>
<a href="https://github.com/coveooss/json-schema-for-humans/blob/main/docs/examples/examples_md_default/ref_with_other_elements.md" target="_blank">Open it in github</a>

[examples/examples_md_default/ref_with_other_elements.md](examples/examples_md_default/ref_with_other_elements.md ':include')
</details>


<details>
<summary>Markdown with badges template - Click here to expand the rendered result...</summary>
<a href="https://github.com/coveooss/json-schema-for-humans/blob/main/docs/examples/examples_md_with_badges/ref_with_other_elements.md" target="_blank">Open it in github</a>

[examples/examples_md_with_badges/ref_with_other_elements.md](examples/examples_md_with_badges/ref_with_other_elements.md ':include')
</details>


<details>
<summary>Nested Markdown without badges template - Click here to expand the rendered result...</summary>
<a href="https://github.com/coveooss/json-schema-for-humans/blob/main/docs/examples/examples_md_nested_default/ref_with_other_elements.md" target="_blank">Open it in github</a>

[examples/examples_md_nested_default/ref_with_other_elements.md](examples/examples_md_nested_default/ref_with_other_elements.md ':include')
</details>


<details>
<summary>Nested Markdown with badges template - Click here to expand the rendered result...</summary>
<a href="https://github.com/coveooss/json-schema-for-humans/blob/main/docs/examples/examples_md_nested_with_badges/ref_with_other_elements.md" target="_blank">Open it in github</a>

[examples/examples_md_nested_with_badges/ref_with_other_elements.md](examples/examples_md_nested_with_badges/ref_with_other_elements.md ':include')
</details>

## --ref_with_tabs--
### ref_with_tabs

Expand Down
37 changes: 37 additions & 0 deletions docs/examples/cases/ref_with_other_elements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"title": "OF",
"properties": {
"uuid": {
"$ref": "#/$defs/ofString",
"description": "Unique Identifer",
"examples": [
"29292929292929292929292"
]
},
"firstName": {
"$ref": "#/$defs/ofString",
"description": "first name",
"minLength": 10,
"examples": [
"John"
]
},
"lastName": {
"$ref": "#/$defs/ofString",
"description": "last name",
"maxLength": 10,
"examples": [
"Doe"
]
}
},
"$defs": {
"ofString": {
"type": "string",
"minLength": 5,
"maxLength": 250
}
}
}
10 changes: 9 additions & 1 deletion docs/examples/examples_flat_default/defaults.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ <h2 class="mb-0">



<a href="#a" class="ref-link">Same definition as a</a>









</div>
</div>

Expand Down
171 changes: 171 additions & 0 deletions docs/examples/examples_flat_default/ref_with_other_elements.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@


<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Overpass:300,400,600,800">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="schema_doc.css">
<meta charset="utf-8"/>


<title>OF</title>
</head>
<body id="root"><h1>OF</h1>

<div class="breadcrumbs"></div><span class="badge badge-dark value-type">Type: object</span><br/>



















<div class="card">
<div class="card-header" id="uuid">
<h2 class="mb-0">
<a href="#uuid"><span class="property-name">uuid</span></a></h2>
</div>

<div class="card-body property-definition-div">

<div class="breadcrumbs">root
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-right-short" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"
/>
</svg>
<a href="#uuid">uuid</a></div><span class="badge badge-dark value-type">Type: string</span><br/>







<p>Unique Identifer</p>










<p><span class="badge badge-light restriction min-length-restriction" id="uuid_minLength">Must be at least <code>5</code> characters long</span></p><p><span class="badge badge-light restriction max-length-restriction" id="uuid_maxLength">Must be at most <code>250</code> characters long</span></p>

<br/>
<div class="badge badge-secondary">Example:</div>
<br/><div id="uuid_ex1" class="jumbotron examples"><div class="highlight"><pre><span></span><span class="s2">&quot;29292929292929292929292&quot;</span>
</pre></div>
</div>
</div>
</div>

<div class="card">
<div class="card-header" id="firstName">
<h2 class="mb-0">
<a href="#firstName"><span class="property-name">firstName</span></a></h2>
</div>

<div class="card-body property-definition-div">

<div class="breadcrumbs">root
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-right-short" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"
/>
</svg>
<a href="#firstName">firstName</a></div><span class="badge badge-dark value-type">Type: string</span><br/>







<p>first name</p>










<p><span class="badge badge-light restriction min-length-restriction" id="firstName_minLength">Must be at least <code>10</code> characters long</span></p><p><span class="badge badge-light restriction max-length-restriction" id="uuid_maxLength">Must be at most <code>250</code> characters long</span></p>

<br/>
<div class="badge badge-secondary">Example:</div>
<br/><div id="uuid_ex1" class="jumbotron examples"><div class="highlight"><pre><span></span><span class="s2">&quot;John&quot;</span>
</pre></div>
</div>
</div>
</div>

<div class="card">
<div class="card-header" id="lastName">
<h2 class="mb-0">
<a href="#lastName"><span class="property-name">lastName</span></a></h2>
</div>

<div class="card-body property-definition-div">

<div class="breadcrumbs">root
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-right-short" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"
/>
</svg>
<a href="#lastName">lastName</a></div><span class="badge badge-dark value-type">Type: string</span><br/>







<p>last name</p>










<p><span class="badge badge-light restriction min-length-restriction" id="uuid_minLength">Must be at least <code>5</code> characters long</span></p><p><span class="badge badge-light restriction max-length-restriction" id="lastName_maxLength">Must be at most <code>10</code> characters long</span></p>

<br/>
<div class="badge badge-secondary">Example:</div>
<br/><div id="uuid_ex1" class="jumbotron examples"><div class="highlight"><pre><span></span><span class="s2">&quot;Doe&quot;</span>
</pre></div>
</div>
</div>
</div>

<footer>
<p class="generated-by-footer">Generated using <a href="https://github.com/coveooss/json-schema-for-humans">json-schema-for-humans</a></p>
</footer></body>
</html>
Loading

0 comments on commit a4380d3

Please sign in to comment.