Stop autogenerating examples where we already have one (#1384)

If an object definition already has an example, we shouldn't try to extend that
definition by adding examples derived from the individual properties. Doing so
is confusing, and there is no way to inhibit it when it is not desired. It's
also not what the RapiDoc viewere does, so we end up with examples being
inconsistent.
This commit is contained in:
Richard van der Hoff 2022-12-21 16:24:11 +00:00 committed by GitHub
parent 966f3c443a
commit 7bd48ca9c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 27 deletions

View file

@ -13,21 +13,20 @@
{{ $example := $this_object.example }}
{{ if eq $this_object.type "object" }}
{{ if not $example }}
{{ if not $example }}
{{ if eq $this_object.type "object" }}
{{ $example = dict }}
{{ end }}
{{ range $key, $property := $this_object.properties}}
{{ $this_property_example := partial "json-schema/resolve-example" $property }}
{{ if $this_property_example }}
{{ $example = merge (dict $key $this_property_example) $example }}
{{ range $key, $property := $this_object.properties}}
{{ $this_property_example := partial "json-schema/resolve-example" $property }}
{{ if $this_property_example }}
{{ $example = merge (dict $key $this_property_example) $example }}
{{ end }}
{{ end }}
{{ end }}
{{ else if eq $this_object.type "array" }}
{{ else if eq $this_object.type "array" }}
{{ if not $example }}
{{/* the "items" within an array can either be an object (where we have a
list of items which match the schema), or a list (for tuple
validation, where each item has a different schema).