File size: 1,976 Bytes
b855ced
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{{/*

  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.
  * `anchor_base`: an optional prefix for the HTML IDs generated by
  this template.
  * `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.

  This template replaces the old {{*_http_api}} template.

*/}}

{{ $api_data := index .api_data }}
{{ $base_url := .base_url }}
{{ $anchor_base := .anchor_base }}
{{ $page := .page }}
{{ $module := .module }}

{{ 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" . "anchor_base" $anchor_base "page" $page "module" $module) }}
        {{ partial "openapi/render-operation" $operation_params }}

    {{ end }}

    {{ with $path_data.post }}

        {{ $operation_params := merge $params (dict "method" "POST" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
        {{ partial "openapi/render-operation" $operation_params }}

    {{ end }}

    {{ with $path_data.put }}

        {{ $operation_params := merge $params (dict "method" "PUT" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
        {{ partial "openapi/render-operation" $operation_params }}

    {{ end }}

    {{ with $path_data.delete }}

        {{ $operation_params := merge $params (dict "method" "DELETE" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
        {{ partial "openapi/render-operation" $operation_params }}

    {{ end }}

{{ end }}