Skip to content

Commit c6111a4

Browse files
authored
OpenAPI (#18)
1 parent cfb5485 commit c6111a4

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed

docs/contributing.rst

+19
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ And run kisee in development mode using::
1515
adev runserver kisee/kisee.py
1616

1717

18+
Building the API doc
19+
--------------------
20+
21+
We have a description of the kisee API using OpenAPI v3, that can be checked using::
22+
23+
pip install openapi-spec-validator
24+
openapi-spec-validator kisee.yaml
25+
26+
so we can generate some things from here, like a documentation, for
27+
example::
28+
29+
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.0-beta2/openapi-generator-cli-5.0.0-beta2.jar -O openapi-generator-cli.jar
30+
java -jar openapi-generator-cli.jar generate -g html2 -i kisee.yaml -o apidocs/
31+
32+
33+
Or by using `the plain old standalone HTML/CSS/JS swagger-ui
34+
<https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/installation.md#plain-old-htmlcssjs-standalone>`_.
35+
36+
1837
Internals
1938
---------
2039

kisee.yml

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
3+
openapi: 3.0.0
4+
info:
5+
title: Kisee Identity Manager
6+
description: An elementary identity manager, which only expose any user/password storage as an API.
7+
contact:
8+
name: Author
9+
url: https://github.com/meltygroup/kisee
10+
license:
11+
name: MIT
12+
url: https://opensource.org/licenses/mit-license.php
13+
version: v1
14+
paths:
15+
/users/:
16+
get:
17+
description: Just give some informations about the users endpoint.
18+
responses:
19+
'200':
20+
description: "Endpoint informations, but no users."
21+
post:
22+
description: User registration
23+
requestBody:
24+
required: true
25+
description: User informations
26+
content:
27+
application/json:
28+
schema:
29+
$ref: '#/components/schemas/user_info'
30+
responses:
31+
'201':
32+
description: Newly created user, see Location header.
33+
'400':
34+
description: An input field is missing, or email is invalid.
35+
'409':
36+
description: User already exists.
37+
patch:
38+
description: To change a user password.
39+
requestBody:
40+
required: true
41+
content:
42+
application/json-patch+json:
43+
schema:
44+
$ref: '#/components/schemas/patch'
45+
responses:
46+
'204':
47+
description: "Empty body, patch successfull."
48+
'400':
49+
description: "Patch body may be an invalid json-patch, or try to change something else than the password."
50+
'403':
51+
description: "You're not allowed to change this user's password."
52+
/jwt/:
53+
post:
54+
description: Create a new JWT
55+
requestBody:
56+
description: User username and password
57+
required: true
58+
content:
59+
application/json:
60+
schema:
61+
$ref: '#/components/schemas/user_password'
62+
responses:
63+
'200':
64+
description: Newly created JWT
65+
content:
66+
application/json:
67+
schema:
68+
$ref: '#/components/schemas/new_jwt'
69+
'400':
70+
description: "A required field is missing."
71+
'403':
72+
description: "Invalid username or password."
73+
74+
get:
75+
description: Only a hint POST is possible.
76+
responses:
77+
'200':
78+
description: 'Currently only here to describe the API.'
79+
80+
/password_recoveries/:
81+
get:
82+
description: Only a hint POST is possible.
83+
responses:
84+
'200':
85+
description: 'Currently only here to describe the API.'
86+
post:
87+
description: Start a password recovery process
88+
requestBody:
89+
description: User username or email.
90+
required: true
91+
content:
92+
application/json:
93+
schema:
94+
$ref: '#/components/schemas/username_or_email'
95+
96+
/jwt{/jid}:
97+
get:
98+
description: Not implemented
99+
responses:
100+
'500':
101+
description: "This is literally not implemented yet."
102+
103+
104+
components:
105+
schemas:
106+
user:
107+
type: object
108+
new_jwt:
109+
type: object
110+
properties:
111+
tokens:
112+
type: array
113+
items:
114+
type: string
115+
example: eyJ0eXAiOiJKV1QiLCJhbGciOiJ...
116+
user_password:
117+
type: object
118+
required: ["username", "password"]
119+
properties:
120+
username:
121+
type: string
122+
password:
123+
type: string
124+
format: password
125+
jwt:
126+
type: object
127+
additionalProperties:
128+
type: object
129+
user_info:
130+
allOf:
131+
- $ref: '#/components/schemas/user_password'
132+
- type: object
133+
required: ["email"]
134+
properties:
135+
email:
136+
type: string
137+
format: email
138+
username_or_email:
139+
oneOf:
140+
- type: object
141+
required: ["username"]
142+
properties:
143+
username:
144+
type: string
145+
- type: object
146+
required: ["email"]
147+
properties:
148+
email:
149+
type: string
150+
format: email
151+
patch:
152+
type: array
153+
items:
154+
type: object
155+
properties:
156+
op:
157+
type: string
158+
path:
159+
type: string
160+
value:
161+
type: string

0 commit comments

Comments
 (0)