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
This commit is contained in:
Richard van der Hoff 2022-07-19 20:25:30 +01:00 committed by GitHub
parent 16eb4cb961
commit 5f3b34448d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 64 additions and 36 deletions

View file

@ -22,13 +22,14 @@
{{ $endpoint := .endpoint }}
{{ $operation_data := .operation_data }}
{{ $path := .path }}
{{ $anchor := anchorize $endpoint }}
<section class="rendered-data http-api {{ $method }}">
<details {{ if not site.Params.ui.rendered_data_collapsed }}open{{ end }}>
<summary>
<h1 id="{{ lower $method }}{{ anchorize $endpoint }}">
<h1 id="{{ lower $method }}{{ $anchor }}">
<span class="http-api-method {{ $method }}">{{ $method }}</span>
<span class="endpoint{{ if $operation_data.deprecated }} deprecated-inline{{ end }}">{{ $endpoint }}</span>
</h1>
@ -63,9 +64,9 @@
</table>
<hr/>
{{ partial "openapi/render-request" (dict "parameters" $operation_data.parameters "path" $path) }}
{{ partial "openapi/render-request" (dict "parameters" $operation_data.parameters "path" $path "anchor_base" $anchor ) }}
<hr/>
{{ partial "openapi/render-responses" (dict "responses" $operation_data.responses "path" $path) }}
{{ partial "openapi/render-responses" (dict "responses" $operation_data.responses "path" $path "anchor_base" $anchor ) }}
</details>