@@ -35,44 +35,52 @@ <h2>Responses</h2>
35
35
36
36
</ table >
37
37
38
- {{ range $code, $response := $responses }}
39
-
38
+ {{ range $code, $response := $responses }}
40
39
{{ if $response.schema }}
41
40
41
+ < h3 > {{$code}} response</ h3 >
42
+
42
43
{{ $schema := partial "json-schema/resolve-refs" (dict "schema" $response.schema "path" $path) }}
43
44
{{ $schema := partial "json-schema/resolve-allof" $schema }}
44
45
45
- {{ if or $schema.properties (eq $schema.type "array") }}
46
- < h3 > {{ $code}} response</ h3 >
47
-
48
- {{/*
49
- All this is to work out how to express the content of the response
50
- in the case where it is an array.
51
- */}}
52
- {{ if eq $schema.type "array" }}
53
- {{ $type_of := "" }}
54
- {{ if reflect.IsSlice $schema.items }}
55
- {{ $types := slice }}
56
- {{ range $schema.items }}
57
- {{ if .title }}
58
- {{ $types = $types | append .title}}
59
- {{ else }}
60
- {{ $types = $types | append .type }}
61
- {{ end }}
46
+ {{/*
47
+ All this is to work out how to express the content of the response
48
+ in the case where it is an array.
49
+ */}}
50
+ {{ if eq $schema.type "array" }}
51
+ {{ $type_of := "" }}
52
+ {{ if reflect.IsSlice $schema.items }}
53
+ {{ $types := slice }}
54
+ {{ range $schema.items }}
55
+ {{ if .title }}
56
+ {{ $types = $types | append .title}}
57
+ {{ else }}
58
+ {{ $types = $types | append .type }}
62
59
{{ end }}
63
- {{ $type_of = delimit $types ", "}}
64
- {{ else }}
65
- {{ $type_of = $schema.items.title }}
66
60
{{ end }}
67
- < p > Array of < code > {{ $type_of }}</ code > .</ p >
61
+ {{ $type_of = delimit $types ", "}}
62
+ {{ else }}
63
+ {{ $type_of = $schema.items.title }}
68
64
{{ end }}
65
+ < p > Array of < code > {{ $type_of }}</ code > .</ p >
66
+ {{ end }}
69
67
70
- {{ $additional_types := partial "json-schema/resolve-additional-types" $schema }}
71
- {{ $additional_types = uniq $additional_types }}
72
- {{ range $additional_types }}
73
- {{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
74
- {{ end }}
75
68
69
+ {{/*
70
+ render object tables for any objects referenced in the
71
+ response. (This will be a no-op for response types which aren't
72
+ objects or arrays.)
73
+ */}}
74
+ {{ $additional_types := partial "json-schema/resolve-additional-types" $schema }}
75
+ {{ $additional_types = uniq $additional_types }}
76
+ {{ range $additional_types }}
77
+ {{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
78
+ {{ end }}
79
+
80
+ {{/*
81
+ render an example. currently this is only supported for arrays and objects.
82
+ */}}
83
+ {{ if or (eq $schema.type "object") (eq $schema.type "array") }}
76
84
{{ $example := partial "json-schema/resolve-example" $schema }}
77
85
{{ if $response.examples }}
78
86
{{ $example = partial "json-schema/resolve-refs" (dict "schema" $response.examples "path" $path) }}
0 commit comments