Only show empty examples if the object is suppoed to be empty

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2025-02-21 16:09:47 +01:00
parent a5c9f91927
commit b83bc65850
No known key found for this signature in database
GPG key ID: 0C971D9DBC9D678D
2 changed files with 8 additions and 4 deletions

View file

@ -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" }}

View file

@ -58,11 +58,13 @@
{{ 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>