Skip to content

Commit c0175fe

Browse files
Merge pull request #15 from veraison/api
feat: add REST API description
2 parents 3758f53 + e997a50 commit c0175fe

File tree

3 files changed

+202
-0
lines changed

3 files changed

+202
-0
lines changed

.github/workflows/api.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: API checks
2+
3+
on:
4+
push:
5+
paths:
6+
- 'docs/api/**'
7+
pull_request:
8+
paths:
9+
- 'docs/api/**'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install OpenAPI spec validator
19+
run: pip install openapi-spec-validator
20+
21+
- name: Check RATSD API
22+
run: make -C docs/api check

docs/api/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.DEFAULT_GOAL := help
2+
3+
# To validate an OpenAPI module, append the file name (without the .yaml
4+
# extension) to the API variable. A "check_<YAML module>" target is
5+
# automatically constructed and appended to the top level "check" goal.
6+
API := ratsd
7+
8+
CMD := openapi-spec-validator
9+
10+
ifeq (, $(shell which $(CMD)))
11+
$(error "No openapi-spec-validator in $(PATH); To install it, run: 'pip install openapi-spec-validator'")
12+
endif
13+
14+
define OPENAPI_CHECK_template
15+
.PHONY: check_$(1)
16+
17+
check_$(1): ; @printf ">>> $(1): " && $(CMD) $(1).yaml
18+
19+
HELP += "check_$(1): check only the $(1) template"
20+
endef
21+
22+
$(foreach a,$(API),$(eval $(call OPENAPI_CHECK_template,$(a))))
23+
24+
.PHONY: check
25+
check: $(foreach t,$(API),check_$(t))
26+
27+
.PHONY: help
28+
help:
29+
@printf "\nAvailable targets:\n"
30+
@printf "\tcheck: run the OpenAPI spec validator on all API templates\n\n"
31+
@printf "\t%s\n\n" $(HELP)

docs/api/ratsd.yaml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
openapi: 3.0.0
2+
info:
3+
title: RATS Evidence Collection Daemon API
4+
version: 0.0.1
5+
tags: []
6+
paths:
7+
/ratsd/chares:
8+
post:
9+
description: Challenge response API. Accepts a challenge and, upon success, generates the evidence in EAT w/ CMW format.
10+
operationId: Ratsd_chares
11+
parameters:
12+
- $ref: '#/components/parameters/ChaResRequestParameters.accept'
13+
responses:
14+
'200':
15+
description: The request has succeeded.
16+
content:
17+
application/eat+jwt; eat_profile="tag:github.com,2024:veraison/ratsd":
18+
schema:
19+
$ref: '#/components/schemas/EAT'
20+
'400':
21+
description: The server could not understand the request due to invalid syntax.
22+
content:
23+
application/problem+json:
24+
schema:
25+
$ref: '#/components/schemas/BadRequestError'
26+
'401':
27+
description: Access is unauthorized.
28+
content:
29+
application/problem+json:
30+
schema:
31+
$ref: '#/components/schemas/UnauthorizedError'
32+
requestBody:
33+
required: true
34+
content:
35+
application/vnd.veraison.chares+json:
36+
schema:
37+
$ref: '#/components/schemas/ChaResRequest'
38+
security:
39+
- BearerAuth: []
40+
components:
41+
parameters:
42+
ChaResRequestParameters.accept:
43+
name: accept
44+
in: header
45+
required: false
46+
schema:
47+
type: string
48+
schemas:
49+
BadRequestError:
50+
type: object
51+
required:
52+
- type
53+
- title
54+
- status
55+
properties:
56+
type:
57+
type: string
58+
enum:
59+
- tag:github.com,2024:veraison/ratsd:error:invalidrequest
60+
title:
61+
type: string
62+
enum:
63+
- invalid request
64+
status:
65+
type: number
66+
enum:
67+
- 400
68+
detail:
69+
type: string
70+
instance:
71+
type: string
72+
CMW:
73+
type: object
74+
required:
75+
- typ
76+
- val
77+
properties:
78+
typ:
79+
type: string
80+
enum:
81+
- application/vnd.veraison.configfs-tsm+json
82+
val:
83+
type: string
84+
format: base64url
85+
ChaResRequest:
86+
type: object
87+
required:
88+
- nonce
89+
properties:
90+
nonce:
91+
type: string
92+
format: base64url
93+
EAT:
94+
type: object
95+
required:
96+
- eat_profile
97+
- nested-token
98+
properties:
99+
eat_profile:
100+
type: string
101+
enum:
102+
- tag:github.com,2024:veraison/ratsd
103+
nested-token:
104+
$ref: '#/components/schemas/CMW'
105+
ProblemDetails:
106+
type: object
107+
properties:
108+
type:
109+
type: string
110+
title:
111+
type: string
112+
status:
113+
type: integer
114+
detail:
115+
type: string
116+
instance:
117+
type: string
118+
UnauthorizedError:
119+
type: object
120+
required:
121+
- type
122+
- title
123+
- status
124+
properties:
125+
type:
126+
type: string
127+
enum:
128+
- tag:github.com,2024:veraison/ratsd:error:unauthorized
129+
title:
130+
type: string
131+
enum:
132+
- access unauthorized
133+
status:
134+
type: number
135+
enum:
136+
- 401
137+
detail:
138+
type: string
139+
instance:
140+
type: string
141+
Versions:
142+
type: string
143+
enum:
144+
- 0.0.1
145+
securitySchemes:
146+
BearerAuth:
147+
type: http
148+
scheme: bearer
149+

0 commit comments

Comments
 (0)