docs-matrix-spec/layouts/partials/openapi/render-api.html
Kévin Commaille 2678370f2c
Simplify uses of resolve-refs partial (#1773)
* Use the resolve-refs partial as soon as possible

Call it right after accessing the site.Data,
since it is recursing it will solve all references in the tree.
That way we don't need to wonder where to call it,
we trust the validators that the refs will be used in the right place.

* Enable strict $ref rule in OpenAPI validator

* Document use of $ref to compose examples

* Fix schema path in event-fields shortcode

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-09 18:06:53 +01:00

50 lines
1.3 KiB
HTML

{{/*
Render an HTTP API, given:
* `api_data`: the OpenAPI data
* `base_url`: the base URL: that is, the part we glue onto the front
of each value in `paths` to get a complete URL.
*/}}
{{ $api_data := index .api_data }}
{{ $base_url := .base_url }}
{{ range $path_name, $path_data := $api_data.paths }}
{{ $endpoint := delimit (slice $base_url $path_name ) "" }}
{{/* note that a `paths` entry can be a $ref */}}
{{ $params := dict "endpoint" $endpoint }}
{{ with $path_data.get }}
{{ $operation_params := merge $params (dict "method" "GET" "operation_data" . ) }}
{{ partial "openapi/render-operation" $operation_params }}
{{ end }}
{{ with $path_data.post }}
{{ $operation_params := merge $params (dict "method" "POST" "operation_data" . ) }}
{{ partial "openapi/render-operation" $operation_params }}
{{ end }}
{{ with $path_data.put }}
{{ $operation_params := merge $params (dict "method" "PUT" "operation_data" . ) }}
{{ partial "openapi/render-operation" $operation_params }}
{{ end }}
{{ with $path_data.delete }}
{{ $operation_params := merge $params (dict "method" "DELETE" "operation_data" . ) }}
{{ partial "openapi/render-operation" $operation_params }}
{{ end }}
{{ end }}