howmuch/api/openapi/openapi.yaml

206 lines
5.7 KiB
YAML
Raw Normal View History

# MIT License
#
# Copyright (c) 2024 vinchent <vinchent@vinchent.xyz>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
2024-09-30 21:00:34 +00:00
swagger: "2.0"
2024-10-05 16:00:01 +00:00
openapi: 3.1.0
2024-09-30 21:00:34 +00:00
info:
2024-10-05 16:00:01 +00:00
title: Howmuch Expense-sharing app
2024-09-30 21:00:34 +00:00
description: |-
A simple web application that can help you share your expense with your
friends.
contact:
2024-10-05 16:00:01 +00:00
email: vinchent@vinchent.xyz
2024-09-30 21:00:34 +00:00
license:
name: MIT
url: https://opensource.org/license/MIT
2024-10-05 16:00:01 +00:00
version: '0.0.1'
2024-09-30 21:00:34 +00:00
servers:
2024-10-05 16:00:01 +00:00
- url: https:/localhost:8000/v1
2024-09-30 21:00:34 +00:00
tags:
- name: user
- name: session
2024-10-05 16:00:01 +00:00
2024-09-30 21:00:34 +00:00
paths:
/user/create:
2024-09-30 21:00:34 +00:00
post:
tags:
- user
description: Create a new user
2024-09-30 21:00:34 +00:00
requestBody:
description: Create a new user
2024-09-30 21:00:34 +00:00
content:
application/json:
schema:
$ref: '#/components/schemas/UserCreateRequest'
2024-09-30 21:00:34 +00:00
responses:
'200':
description: Successful operation
2024-10-05 16:00:01 +00:00
'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
2024-09-30 21:00:34 +00:00
content:
application/json:
schema:
2024-10-05 16:00:01 +00:00
$ref: '#/components/schemas/ErrResponse'
/session/create:
post:
tags:
2024-10-12 15:11:16 +00:00
- session
description: Create a new session for a user
requestBody:
description: Create session
content:
application/json:
schema:
$ref: '#/components/schemas/SessionCreateRequest'
2024-10-13 20:22:44 +00:00
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
token:
type: string
example: fakjshdflauhkjhsometokenakjsdhfaksj
'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:
application/json:
schema:
$ref: '#/components/schemas/ErrResponse'
/session/delete:
post:
tags:
- session
description: Delete an existing session for a user
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
2024-10-13 20:22:44 +00:00
example: "user not logged in."
2024-10-05 16:00:01 +00:00
'500':
description: Server side error
2024-09-30 21:00:34 +00:00
content:
application/json:
schema:
2024-10-05 16:00:01 +00:00
$ref: '#/components/schemas/ErrResponse'
2024-10-13 20:22:44 +00:00
security:
- jwt: []
2024-10-05 16:00:01 +00:00
2024-09-30 21:00:34 +00:00
components:
schemas:
UserCreateRequest:
2024-09-30 21:00:34 +00:00
type: object
properties:
email:
type: string
2024-10-05 16:00:01 +00:00
example: bruce@wayne.com
first_name:
2024-09-30 21:00:34 +00:00
type: string
2024-10-05 16:00:01 +00:00
example: Bruce
last_name:
2024-09-30 21:00:34 +00:00
type: string
2024-10-05 16:00:01 +00:00
example: Wayne
password:
2024-09-30 21:00:34 +00:00
type: string
2024-10-05 16:00:01 +00:00
example: verystrongpassword
2024-09-30 21:00:34 +00:00
required:
2024-10-05 16:00:01 +00:00
- email
- fist_name
- last_name
- password
SessionCreateRequest:
type: object
properties:
email:
type: string
example: bruce@wayne.com
password:
type: string
example: verystrongpassword
required:
- email
- password
2024-10-05 16:00:01 +00:00
ErrResponse:
2024-09-30 21:00:34 +00:00
type: object
properties:
code:
type: string
example: InternalError
2024-09-30 21:00:34 +00:00
message:
type: string
example: "Server internal error."
2024-10-13 20:22:44 +00:00
securitySchemes:
jwt:
name: Bearer authentication
type: http
bearerFormat: "JWT"
scheme: bearer