You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
matrix-spec/layouts/partials/openapi/render-api.html

55 lines
1.5 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.
* `path`: the directory under /data where we found this API definition.
We use this to resolve "$ref" values, since they are relative to the schema's
location.
*/}}
{{ $api_data := index .api_data }}
{{ $base_url := .base_url }}
{{ $path := .path }}
{{ 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 "path" $path }}
{{ 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 }}