howmuch/api/openapi/openapi.yaml
2024-10-13 22:22:44 +02:00

206 lines
5.7 KiB
YAML

# 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.
swagger: "2.0"
openapi: 3.1.0
info:
title: Howmuch Expense-sharing app
description: |-
A simple web application that can help you share your expense with your
friends.
contact:
email: vinchent@vinchent.xyz
license:
name: MIT
url: https://opensource.org/license/MIT
version: '0.0.1'
servers:
- url: https:/localhost:8000/v1
tags:
- name: user
- name: session
paths:
/user/create:
post:
tags:
- user
description: Create a new user
requestBody:
description: Create a new user
content:
application/json:
schema:
$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:
- session
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
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
example: "user not logged in."
'500':
description: Server side error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrResponse'
security:
- jwt: []
components:
schemas:
UserCreateRequest:
type: object
properties:
email:
type: string
example: bruce@wayne.com
first_name:
type: string
example: Bruce
last_name:
type: string
example: Wayne
password:
type: string
example: verystrongpassword
required:
- 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
ErrResponse:
type: object
properties:
code:
type: string
example: InternalError
message:
type: string
example: "Server internal error."
securitySchemes:
jwt:
name: Bearer authentication
type: http
bearerFormat: "JWT"
scheme: bearer