Skip to content

Commit

Permalink
Only show empty examples if the object is suppoed to be empty
Browse files Browse the repository at this point in the history
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
  • Loading branch information
zecakeh committed Feb 21, 2025
1 parent a5c9f91 commit b83bc65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion layouts/partials/json-schema/resolve-examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
{{ end }}
{{ end }}

{{ $examples = slice $example }}
{{ if (or $example (not $this_object.properties)) }}
{{ $examples = slice $example }}
{{ end }}

{{ else if eq $this_object.type "array" }}

Expand Down
8 changes: 5 additions & 3 deletions layouts/shortcodes/definition.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ <h1>
{{ partial "openapi/render-object-table" . }}
{{end}}

{{ $examples := partial "json-schema/resolve-examples" $definition }}
{{ if $examples }}
<h2>Examples</h2>

{{ $examples := partial "json-schema/resolve-examples" $definition }}
{{ range $examples }}
{{ partial "render-example" (dict "example" .) }}
{{ range $examples }}
{{ partial "render-example" (dict "example" .) }}
{{ end }}
{{ end }}

</details>
Expand Down

0 comments on commit b83bc65

Please sign in to comment.