summaryrefslogtreecommitdiff
path: root/src/docs/api/endpoints/view.pug
blob: 4a11c4cd02fb40fa56b59657bc31a655fbb5dd3b (plain)
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
extends ../../base
include ../mixins

block meta
	link(rel="stylesheet" href="/docs/assets/api/endpoints/style.css")

block main
	h1= title

	p#url
		span.method POST
		span.host
			= url.host
			| /
		span.path= url.path

	if endpoint.desc
		p#desc= endpoint.desc[lang] || endpoint.desc['ja']

	if endpoint.requireCredential
		div.ui.info: p= i18n('docs.api.endpoints.require-credential')

	if endpoint.limit
		div.ui.info.warn
			p
				b!= i18n('docs.api.endpoints.has-limit')
				if endpoint.limit.duration
					!= i18n('docs.api.endpoints.duration-limit').replace('{duration}', endpoint.limit.duration).replace('{max}', endpoint.limit.max)
				if endpoint.limit.minInterval
					!= i18n('docs.api.endpoints.min-interval-limit').replace('{interval}', endpoint.limit.minInterval)

	if params && Object.keys(params).length > 0
		section
			h2= i18n('docs.api.endpoints.params')
			+propTable(params)

			if paramDefs
				each paramDef in paramDefs
					section(id= paramDef.name)
						h3= paramDef.name
						+propTable(paramDef.params)
	if params && Object.keys(params).length == 0
		section
			h2= i18n('docs.api.endpoints.params')
			p= i18n('docs.api.endpoints.no-params')

	if res
		section
			h2= i18n('docs.api.endpoints.res')

			if resProps
				+propTable(resProps)

				if resDefs
					each resDef in resDefs
						section(id= resDef.name)
							h3= resDef.name
							+propTable(resDef.props)
			else
				if res.type.startsWith('entity')
					a(href=`/docs/${lang}/api/entities/${kebab(res.entity)}`)= res.entity

block footer
	div.ui.info: p
		i.fas.fa-info-circle(style="margin-right: 4px")
		= i18n('docs.api.endpoints.generated')
	p
		= i18n('docs.api.endpoints.show-src')
		a(href=src target="_blank")= i18n('docs.api.endpoints.show-src-link')