forked from TheThingsNetwork/lorawan-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.md.tmpl
115 lines (81 loc) · 2.99 KB
/
api.md.tmpl
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<a name="top"></a>
# API Documentation
## <a name="toc">Table of Contents</a>
{{ range .Files }}{{ $file_name := .Name -}}
- [File `{{ .Name }}`](#{{ .Name }})
{{- range .Messages }}
- [Message `{{ .LongName }}`](#{{ .FullName }})
{{- end -}}
{{- range .Enums }}
- [Enum `{{ .LongName }}`](#{{ .FullName }})
{{- end -}}
{{- range .Services }}
- [Service `{{ .Name }}`](#{{ .FullName }})
{{- end }}
{{ end -}}
- [Scalar Value Types](#scalar-value-types)
{{- range .Files }}{{ $file_name := .Name }}
## <a name="{{ .Name }}">File `{{ .Name }}`</a>
{{- with .Description }}
{{ . }}
{{- end }}
{{- range .Messages }}{{ $message := . }}
### <a name="{{ .FullName }}">Message `{{ .LongName }}`</a>
{{- with .Description }}
{{ . }}
{{- end }}
{{- if .HasFields }}
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
{{- range .Fields }}
| `{{ .Name }}` | [`{{ .LongType }}`](#{{ .FullType }}) | {{ .Label }} | {{ nobr (.Description | replace "\n\n" "\n") }}{{ if .DefaultValue }} Default: {{ .DefaultValue }}{{ end }} |
{{- end -}}
{{- if $message.FieldsWithOption "validate.rules" }}
#### Field Rules
| Field | Validations |
| ----- | ----------- |
{{- range $message.FieldsWithOption "validate.rules" }}
| `{{ .Name }}` | {{range (.Option "validate.rules").Rules}}<p>`{{.Name}}`: `{{.Value}}`</p>{{end}} |
{{- end -}}
{{ end -}}
{{ end -}}
{{ end }}
{{- range .Enums }}{{ $enum := . }}
### <a name="{{ .FullName }}">Enum `{{ .LongName }}`</a>
{{- with .Description }}
{{ . }}
{{- end }}
| Name | Number | Description |
| ---- | ------ | ----------- |
{{- range .Values }}
| `{{ .Name }}` | {{ .Number }} | {{ nobr (.Description | replace "\n\n" "\n") }} |
{{- end -}}
{{ end -}}
{{- range .Services }}{{ $service := . }}
### <a name="{{ .FullName }}">Service `{{ .LongName }}`</a>
{{- with .Description }}
{{ . }}
{{- end }}
| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
{{- range .Methods }}
| `{{ .Name }}` | [`{{ .RequestLongType }}`](#{{ .RequestFullType }}){{ if .RequestStreaming }} _stream_{{ end }} | [`{{ .ResponseLongType }}`](#{{ .ResponseFullType }}){{ if .ResponseStreaming }} _stream_{{ end }} | {{ nobr (.Description | replace "\n\n" "\n") }} |
{{- end -}}
{{- if $service.MethodsWithOption "google.api.http" }}
#### HTTP bindings
| Method Name | Method | Pattern | Body |
| ----------- | ------ | ------- | ---- |
{{- range $service.MethodsWithOption "google.api.http" }}{{ $method := . }}
{{- range (.Option "google.api.http").Rules }}
| `{{ $method.Name }}` | `{{ .Method }}` | `/api/v3{{ .Pattern }}` | {{ with .Body }}`{{ . }}`{{ end }} |
{{- end -}}
{{- end -}}
{{ end -}}
{{ end -}}
{{ end }}
## Scalar Value Types
| .proto Type | Notes | C++ Type | Java Type | Python Type |
| ----------- | ----- | -------- | --------- | ----------- |
{{- range .Scalars }}
| <a name="{{ .ProtoType }}" /> {{ .ProtoType }} | {{ .Notes }} | {{ .CppType }} | {{ .JavaType }} | {{ .PythonType }} |
{{- end }}