diff --git a/layouts/_partials/endpoints-toc.html b/layouts/_partials/endpoints-toc.html
index 88d37a09..740160c6 100644
--- a/layouts/_partials/endpoints-toc.html
+++ b/layouts/_partials/endpoints-toc.html
@@ -16,9 +16,9 @@
{{/* Sort by module to group visually */}}
{{ $sorted := sort $endpoints "module" }}
{{ $current := "" }}
- {{ $seen := newScratch }}
{{ range $sorted }}
{{ $mod := .module }}
+ {{/* Set a title for the base endpoints */}}
{{ if not $mod }}{{ $mod = "Required" }}{{ end }}
{{ if ne $mod $current }}
{{ if $current }}{{ end }}
@@ -28,16 +28,13 @@
{{ $current = $mod }}
{{ end }}
{{ $key := printf "%s|%s" .method .anchor }}
- {{ if not ($seen.Get $key) }}
- {{ $seen.Set $key true }}
-
-
- {{ .method }}
- {{ .endpoint }}
- {{ if .deprecated }}(deprecated){{ end }}
-
-
- {{ end }}
+
+
+ {{ .method }}
+ {{ .endpoint }}
+ {{ if .deprecated }}(deprecated){{ end }}
+
+
{{ end }}
{{ if $current }}{{ end }}
diff --git a/layouts/_partials/openapi/render-operation.html b/layouts/_partials/openapi/render-operation.html
index 7ab30a8f..710993b2 100644
--- a/layouts/_partials/openapi/render-operation.html
+++ b/layouts/_partials/openapi/render-operation.html
@@ -35,10 +35,21 @@
{{ if $page }}
{{/* Store each endpoint's metadata in a scratch variable */}}
{{ $entry := dict "anchor" $anchor "method" $method "endpoint" $endpoint "summary" $operation_data.summary "deprecated" $operation_data.deprecated "module" $module }}
+ {{ if not ($page.Scratch.Get "api_endpoints_seen") }}
+ {{ $page.Scratch.Set "api_endpoints_seen" dict }}
+ {{ end }}
+ {{/* Keep a map of seen endpoints. This is necessary as this partial may be
+ rendered multiple times for the same endpoint (e.g. in the TOC and
+ in the main content), leading to duplicates. */}}
+ {{ $seen := $page.Scratch.Get "api_endpoints_seen" }}
+ {{ $key := printf "%s|%s" $method $endpoint }}
+ {{ if not (index $seen $key) }}
{{ if not (reflect.IsSlice ($page.Scratch.Get "api_endpoints")) }}
{{ $page.Scratch.Set "api_endpoints" (slice) }}
{{ end }}
{{ $page.Scratch.Add "api_endpoints" (slice $entry) }}
+ {{ $page.Scratch.SetInMap "api_endpoints_seen" $key true }}
+ {{ end }}
{{ end }}