2021-01-30 00:30:39 +01:00
|
|
|
{{/*
|
|
|
|
|
|
|
|
|
|
Render an HTTP API, given:
|
|
|
|
|
|
2023-09-19 19:26:07 +02:00
|
|
|
* `api_data`: the OpenAPI data
|
2021-01-30 00:30:39 +01:00
|
|
|
* `base_url`: the base URL: that is, the part we glue onto the front
|
|
|
|
|
of each value in `paths` to get a complete URL.
|
2024-06-20 17:39:50 +02:00
|
|
|
* `anchor_base`: an optional prefix for the HTML IDs generated by
|
|
|
|
|
this template.
|
2025-12-18 15:59:18 +01:00
|
|
|
* `page`: the (Hugo) Page object to store endpoint metadata in the Scratch of. Used to build the endpoints TOC.
|
|
|
|
|
* `module`: the current CS API module name, if any. Used to group endpoints in the TOC.
|
2024-06-20 17:39:50 +02:00
|
|
|
|
|
|
|
|
This template replaces the old {{*_http_api}} template.
|
2021-01-30 00:30:39 +01:00
|
|
|
|
|
|
|
|
*/}}
|
|
|
|
|
|
|
|
|
|
{{ $api_data := index .api_data }}
|
|
|
|
|
{{ $base_url := .base_url }}
|
2024-06-20 17:39:50 +02:00
|
|
|
{{ $anchor_base := .anchor_base }}
|
2025-12-18 15:59:18 +01:00
|
|
|
{{ $page := .page }}
|
|
|
|
|
{{ $module := .module }}
|
2021-01-30 00:30:39 +01:00
|
|
|
|
|
|
|
|
{{ range $path_name, $path_data := $api_data.paths }}
|
|
|
|
|
|
|
|
|
|
{{ $endpoint := delimit (slice $base_url $path_name ) "" }}
|
|
|
|
|
|
|
|
|
|
{{/* note that a `paths` entry can be a $ref */}}
|
|
|
|
|
|
2024-04-09 19:06:53 +02:00
|
|
|
{{ $params := dict "endpoint" $endpoint }}
|
2021-01-30 00:30:39 +01:00
|
|
|
|
|
|
|
|
{{ with $path_data.get }}
|
|
|
|
|
|
2025-12-18 15:59:18 +01:00
|
|
|
{{ $operation_params := merge $params (dict "method" "GET" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
|
2021-01-30 00:30:39 +01:00
|
|
|
{{ partial "openapi/render-operation" $operation_params }}
|
|
|
|
|
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
|
|
{{ with $path_data.post }}
|
|
|
|
|
|
2025-12-18 15:59:18 +01:00
|
|
|
{{ $operation_params := merge $params (dict "method" "POST" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
|
2021-01-30 00:30:39 +01:00
|
|
|
{{ partial "openapi/render-operation" $operation_params }}
|
|
|
|
|
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
|
|
{{ with $path_data.put }}
|
|
|
|
|
|
2025-12-18 15:59:18 +01:00
|
|
|
{{ $operation_params := merge $params (dict "method" "PUT" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
|
2021-01-30 00:30:39 +01:00
|
|
|
{{ partial "openapi/render-operation" $operation_params }}
|
|
|
|
|
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
|
|
{{ with $path_data.delete }}
|
|
|
|
|
|
2025-12-18 15:59:18 +01:00
|
|
|
{{ $operation_params := merge $params (dict "method" "DELETE" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
|
2021-01-30 00:30:39 +01:00
|
|
|
{{ partial "openapi/render-operation" $operation_params }}
|
|
|
|
|
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
|
|
{{ end }}
|