diff --git a/layouts/partials/json-schema/resolve-examples.html b/layouts/partials/json-schema/resolve-examples.html index 2caf3e95..a0bb7090 100644 --- a/layouts/partials/json-schema/resolve-examples.html +++ b/layouts/partials/json-schema/resolve-examples.html @@ -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" }} diff --git a/layouts/shortcodes/definition.html b/layouts/shortcodes/definition.html index 875ac16a..1a9643d9 100644 --- a/layouts/shortcodes/definition.html +++ b/layouts/shortcodes/definition.html @@ -58,11 +58,13 @@ {{ partial "openapi/render-object-table" . }} {{end}} +{{ $examples := partial "json-schema/resolve-examples" $definition }} +{{ if $examples }}

Examples

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