fix: change API design to be more RESTful
This commit is contained in:
@ -37,28 +37,79 @@ servers:
|
||||
- url: https:/localhost:8000/v1
|
||||
tags:
|
||||
- name: user
|
||||
- name: session
|
||||
|
||||
paths:
|
||||
/user/signup:
|
||||
/user/create:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
description: Sign up as a new user
|
||||
description: Create a new user
|
||||
requestBody:
|
||||
description: Sign up
|
||||
description: Create a new user
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UserSignUpRequest'
|
||||
$ref: '#/components/schemas/UserCreateRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
'400':
|
||||
description: Client side error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
example: FailedOperation.UserExisted
|
||||
message:
|
||||
type: string
|
||||
example: "Email already existed."
|
||||
'500':
|
||||
description: Server side error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrResponse'
|
||||
/session/create:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
description: Create a new session for a user
|
||||
requestBody:
|
||||
description: Create session
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/SessionCreateRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
headers:
|
||||
X-Expires-After:
|
||||
description: date in UTC when token expires
|
||||
schema:
|
||||
type: string
|
||||
format: date-time
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
'400':
|
||||
description: Client side error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
example: AuthFailure
|
||||
message:
|
||||
type: string
|
||||
example: "wrong email password."
|
||||
'500':
|
||||
description: Server side error
|
||||
content:
|
||||
@ -68,7 +119,7 @@ paths:
|
||||
|
||||
components:
|
||||
schemas:
|
||||
UserSignUpRequest:
|
||||
UserCreateRequest:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
@ -88,12 +139,24 @@ components:
|
||||
- fist_name
|
||||
- last_name
|
||||
- password
|
||||
SessionCreateRequest:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
example: bruce@wayne.com
|
||||
password:
|
||||
type: string
|
||||
example: verystrongpassword
|
||||
required:
|
||||
- email
|
||||
- password
|
||||
ErrResponse:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
example: FailedOperation.UserExisted
|
||||
example: InternalError
|
||||
message:
|
||||
type: string
|
||||
example: "Email already existed."
|
||||
example: "Server internal error."
|
||||
|
Reference in New Issue
Block a user