Allow to specify a prefix for generated HTML IDs of API endpoints (#1882)

* Allow to specify a prefix for generated HTML IDs of API endpoints

Allows to deduplicate IDs of duplicate endpoints

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Add changelog

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2024-06-20 17:39:50 +02:00 committed by GitHub
parent bd20d946c4
commit 18628dc5d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 25 additions and 8 deletions

View file

@ -11,6 +11,9 @@
The file extension is omitted. For example:
{{% http-api spec="server-server" api="public_rooms" %}}
* an optional `anchor_base` parameter, which should be used as a
prefix for the HTML IDs generated by this template. It should only
be necessary to provide one for duplicate endpoints.
This template replaces the old {{*_http_api}} template.
@ -18,6 +21,7 @@
{{ $spec := .Params.spec}}
{{ $api := .Params.api}}
{{ $anchor_base := .Params.anchor_base}}
{{ $api_data := index .Site.Data.api .Params.spec .Params.api }}
{{ $base_url := (index $api_data.servers 0).variables.basePath.default }}
@ -26,4 +30,4 @@
{{ $api_data = partial "json-schema/resolve-refs" (dict "schema" $api_data "path" $path) }}
{{ $api_data = partial "json-schema/resolve-allof" $api_data }}
{{ partial "openapi/render-api" (dict "api_data" $api_data "base_url" $base_url) }}
{{ partial "openapi/render-api" (dict "api_data" $api_data "base_url" $base_url "anchor_base" $anchor_base) }}