render-object-table: take a "title" rather than a "caption"

... which means we can use the result from resolve-additional-types directly.
This commit is contained in:
Richard van der Hoff 2022-07-19 17:44:27 +01:00
parent c508f1e917
commit 1ed4e40362
7 changed files with 14 additions and 12 deletions

View file

@ -56,7 +56,7 @@
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event_data.properties.content) }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
{{ partial "openapi/render-object-table" . }}
{{end}}
<h2>Examples</h2>

View file

@ -2,23 +2,25 @@
Render a table listing the properties of an object, given:
* `caption`: optional caption for the table
* `title`: optional caption for the table
* `properties`: dictionary of the properties to list, each given as:
`property_name` : `property_data`
`property_name` : `property_data`
* `required`: array containing the names of required properties.
In some cases (such as response body specifications) this isn't used, and
instead properties have a `required` boolean attribute. We support this too.
In some cases (such as response body specifications) this isn't used, and
instead properties have a `required` boolean attribute. We support this too.
*/}}
{{ $caption := .caption }}
{{ $title := .title }}
{{ $properties := .properties}}
{{ $required := .required}}
{{ if $properties }}
<table class>
{{ with $caption }}
{{ with $title }}
<caption>{{ . }}</caption>
{{ end }}
<thead>

View file

@ -25,6 +25,6 @@
{{ end }}
{{/* and render the parameters */}}
{{ partial "openapi/render-object-table" (dict "caption" $caption "properties" $param_dict) }}
{{ partial "openapi/render-object-table" (dict "title" $caption "properties" $param_dict) }}
{{ end }}

View file

@ -41,7 +41,7 @@
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema) }}
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
{{ partial "openapi/render-object-table" . }}
{{ end }}
<h3>Request body example</h3>

View file

@ -74,7 +74,7 @@
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema) }}
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
{{ partial "openapi/render-object-table" . }}
{{ end }}
{{/*

View file

@ -49,7 +49,7 @@
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
{{ partial "openapi/render-object-table" . }}
{{end}}
<h2>Examples</h2>

View file

@ -37,7 +37,7 @@
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event) }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
{{ partial "openapi/render-object-table" . }}
{{end}}
</details>