Api doc draft
This commit is contained in:
parent
a60fc317f3
commit
6af55ce61d
10
Makefile
Normal file
10
Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
api_doc_output=docs/index.html
|
||||
api_blueprint_src=api-doc/api.apib
|
||||
aglio_template=default
|
||||
aglio_theme=cyborg
|
||||
|
||||
# API doc
|
||||
gen-api-doc:
|
||||
aglio -i $(api_blueprint_src) -o $(api_doc_output)\
|
||||
--theme-template=$(aglio_template) \
|
||||
--theme-variables=$(aglio_theme)
|
||||
8
api-doc/api.apib
Normal file
8
api-doc/api.apib
Normal file
@ -0,0 +1,8 @@
|
||||
FORMAT: 1A
|
||||
HOST: http://localhost:5000
|
||||
|
||||
# Notes API
|
||||
|
||||
<!-- include(./users/index.apib) -->
|
||||
<!-- include(./notes/index.apib) -->
|
||||
<!-- include(./tags/index.apib) -->
|
||||
110
api-doc/notes/index.apib
Normal file
110
api-doc/notes/index.apib
Normal file
@ -0,0 +1,110 @@
|
||||
# Data Structures
|
||||
|
||||
## Chapter (object)
|
||||
+ title: Chapter 1 (string)
|
||||
+ content: ... (string)
|
||||
|
||||
|
||||
# Group Notes
|
||||
|
||||
## Notes [/notes]
|
||||
|
||||
### Create a Note [POST]
|
||||
|
||||
+ Request (application/json)
|
||||
+ Headers
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
|
||||
+ Attributes (object)
|
||||
+ title: Kotlin (string)
|
||||
+ tags: Dev, Server (array[string])
|
||||
|
||||
+ Response 200
|
||||
|
||||
### Get Notes [GET]
|
||||
|
||||
+ Request (application/json)
|
||||
+ Headers
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (array)
|
||||
+ (object)
|
||||
+ title: Kotlin (string)
|
||||
+ tags: Dev, Server (array[string])
|
||||
+ updatedAt: `2020-01-20T00:00:00` (string)
|
||||
+ (object)
|
||||
+ title: Java (string)
|
||||
+ tags: Dev (array[string])
|
||||
+ updatedAt: `2018-01-20T00:00:00` (string)
|
||||
|
||||
|
||||
## Note [/notes/{noteTitle}]
|
||||
|
||||
+ Parameters
|
||||
+ noteTitle: `Kotlin` (string) - The title of the Note.
|
||||
|
||||
### Get Note [GET]
|
||||
|
||||
+ Request (application/json)
|
||||
+ Headers
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (object)
|
||||
+ title: Kotlin (string)
|
||||
+ tags: Dev, Server (array[string])
|
||||
+ chapters (array)
|
||||
+ (Chapter)
|
||||
+ title: Introduction
|
||||
+ content: ...
|
||||
+ (Chapter)
|
||||
+ title: Objects
|
||||
+ content: ...
|
||||
|
||||
+ Response 404
|
||||
|
||||
### Delete Note [DELETE]
|
||||
|
||||
+ Request (application/json)
|
||||
+ Headers
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
|
||||
+ Response 204
|
||||
|
||||
+ Response 404
|
||||
|
||||
### Update a Note [PATCH]
|
||||
|
||||
+ Request (application/json)
|
||||
+ Headers
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
|
||||
+ Attributes (object)
|
||||
+ title: NewTitle (string)
|
||||
|
||||
|
||||
+ Request (application/json)
|
||||
+ Headers
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
|
||||
+ Attributes (object)
|
||||
+ tags: new, tags (array[string])
|
||||
|
||||
+ Request (application/json)
|
||||
+ Headers
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
|
||||
+ Attributes (object)
|
||||
+ chapters (array)
|
||||
+ (Chapter)
|
||||
+ title: Introduction
|
||||
+ content: ...
|
||||
+ (Chapter)
|
||||
+ title: Objects
|
||||
+ content: ...
|
||||
|
||||
+ Response 200
|
||||
|
||||
+ Response 404
|
||||
14
api-doc/tags/index.apib
Normal file
14
api-doc/tags/index.apib
Normal file
@ -0,0 +1,14 @@
|
||||
# Group Tags
|
||||
|
||||
## Tags [/tags]
|
||||
|
||||
### Get all tags [GET]
|
||||
|
||||
+ Request (application/json)
|
||||
+ Headers
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes
|
||||
+ tags: Dev, Server (array[string])
|
||||
48
api-doc/users/index.apib
Normal file
48
api-doc/users/index.apib
Normal file
@ -0,0 +1,48 @@
|
||||
# Data Structures
|
||||
|
||||
## Login (object)
|
||||
+ username: babar (string)
|
||||
+ password: tortue (string)
|
||||
|
||||
## Token (object)
|
||||
+ token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c (string)
|
||||
|
||||
## InvalidCredentials (object)
|
||||
+ description: Invalid credentials (string),
|
||||
+ error: Bad Request (string),
|
||||
+ status_code: 401 (number)
|
||||
|
||||
# Group Accounts
|
||||
|
||||
## Create an account [/register]
|
||||
|
||||
### Register a new user [POST]
|
||||
|
||||
+ Request (application/json)
|
||||
+ Attributes (object)
|
||||
+ username: babar (string)
|
||||
+ email: michel@seed-it.eu (string)
|
||||
+ password: tortue (string)
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (object)
|
||||
+ message: Created (string)
|
||||
|
||||
+ Response 409 (application/json)
|
||||
+ Attributes (object)
|
||||
+ message: User already exists (string)
|
||||
|
||||
|
||||
## Authenticate user [/login]
|
||||
Authenticate one user to access protected routes.
|
||||
|
||||
### Authenticate a user [POST]
|
||||
|
||||
+ Request (application/json)
|
||||
+ Attributes (Login)
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (Token)
|
||||
|
||||
+ Response 401 (application/json)
|
||||
+ Attributes (InvalidCredentials)
|
||||
@ -26,7 +26,7 @@ class UserController(kodein: Kodein) : KodeinController(kodein) {
|
||||
private val db by instance<Database>()
|
||||
|
||||
override fun Routing.registerRoutes() {
|
||||
post<Routes.SignIn> {
|
||||
post<Routes.Login> {
|
||||
data class Response(val token: String)
|
||||
|
||||
val credential = call.receive<UsernamePasswordCredential>()
|
||||
@ -46,10 +46,10 @@ class UserController(kodein: Kodein) : KodeinController(kodein) {
|
||||
return@post call.respond(Response(simpleJwt.sign(email)))
|
||||
}
|
||||
|
||||
post<Routes.SignUp> {
|
||||
post<Routes.Register> {
|
||||
data class Response(val message: String)
|
||||
|
||||
val user = call.receive<SignUpInfo>()
|
||||
val user = call.receive<RegisterInfo>()
|
||||
|
||||
val exists = db.from(Users)
|
||||
.select()
|
||||
@ -76,13 +76,13 @@ class UserController(kodein: Kodein) : KodeinController(kodein) {
|
||||
}
|
||||
|
||||
object Routes {
|
||||
@Location("/signin")
|
||||
class SignIn
|
||||
@Location("/login")
|
||||
class Login
|
||||
|
||||
@Location("/signup")
|
||||
class SignUp
|
||||
@Location("/register")
|
||||
class Register
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
data class SignUpInfo(val username: String, val email: String, val password: String)
|
||||
data class RegisterInfo(val username: String, val email: String, val password: String)
|
||||
430
docs/index.html
Normal file
430
docs/index.html
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user