docs-matrix-spec/layouts/partials/openapi/render-parameters.html
Richard van der Hoff 5f3b34448d
Add HTML ids for object definitions in the formatted specification (#1174)
* Remove redundant call to resolve-allof

All of the callers to resolve-additional-types already call resolve-allof (or
if not, they should), so this is redundant.

* Update `resolve-additional-types` to take a dict

I want to add more params to this, so first make it take a dict.

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

... which means we can use the result from resolve-additional-types directly.

* render-object-table: support adding an anchor to generated tables.

* resolve-additional-types: generate an id for each returned type

* render-event: pass an anchor_base into resolve-additional-types

This means that it will generate an anchor for each type, whihc will then be
passed into render-object-table and used as an `id` for the table.

* render-operation: pass an anchor_base into resolve-additional-types

* newsfiles
2022-07-19 13:25:30 -06:00

30 lines
893 B
HTML

{{/*
Render the parameters of a given type, given:
* `parameters`: OpenAPI/Swagger data specifying the parameters
* `type`: the type of parameters to render: "header, ""path", "query"
* `caption`: caption to use for the table
This template renders a single table containing parameters of the given type.
*/}}
{{ $parameters := .parameters }}
{{ $type := .type }}
{{ $caption := .caption }}
{{ $parameters_of_type := where $parameters "in" $type }}
{{ with $parameters_of_type }}
{{/* build a dict mapping from name->parameter, which render-object-table expects */}}
{{ $param_dict := dict }}
{{ range $parameter := . }}
{{ $param_dict = merge $param_dict (dict $parameter.name $parameter )}}
{{ end }}
{{/* and render the parameters */}}
{{ partial "openapi/render-object-table" (dict "title" $caption "properties" $param_dict) }}
{{ end }}