1
0
Fork 0
This repository has been archived on 2025-09-02. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mareshq-yggdrasil/api/v1/openapi.yaml
Vojtech Mares 2d32c80182
feat!: add slug to training
BREAKING CHANGE: update init migration
2024-06-26 22:24:36 +02:00

831 lines
23 KiB
YAML

openapi: "3.0.0"
info:
version: "0.1.0"
title: MaresHQ API
license:
name: Proprietary
contact:
name: Vojtěch Mareš
email: iam@vojtechmares.com
url: https://www.vojtechmares.com
servers:
- url: http://localhost:3000
description: Local development server
tags:
- name: Trainings
description: Operations about trainings
paths:
/v1/trainings:
get:
summary: List all trainings
operationId: listTrainings
tags:
- Trainings
responses:
"200":
description: A list of trainings
content:
application/json:
schema:
$ref: "#/components/schemas/ListTrainingsResponse"
"500":
$ref: "#/components/responses/InternalError"
post:
summary: Create a new training
operationId: createTraining
tags:
- Trainings
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTrainingRequest"
responses:
"201":
description: Training created
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTrainingResponse"
"400":
$ref: "#/components/responses/InvalidInputError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}:
get:
summary: Get a training by ID
operationId: getTraining
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
responses:
"200":
description: A training
content:
application/json:
schema:
$ref: "#/components/schemas/GetTrainingResponse"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
put:
summary: Update a training by ID
operationId: updateTraining
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateTrainingRequest"
responses:
"200":
description: Training updated
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateTrainingResponse"
"400":
$ref: "#/components/responses/InvalidInputError"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
delete:
summary: Delete a training by ID
operationId: deleteTraining
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
responses:
"204":
description: Training deleted
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}/dates:
get:
summary: List all dates of a training
operationId: listTrainingDates
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
responses:
"200":
description: List of training dates
content:
application/json:
schema:
$ref: "#/components/schemas/ListTrainingDatesResponse"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
post:
summary: Create a new training date
operationId: createTrainingDate
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTrainingDateRequest"
responses:
"201":
description: Training date created
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTrainingDateResponse"
"400":
$ref: "#/components/responses/InvalidInputError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}/dates/{trainingDateID}:
get:
summary: Get a training date by ID
operationId: getTrainingDate
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
responses:
"200":
description: List of training dates
content:
application/json:
schema:
$ref: "#/components/schemas/GetTrainingDateResponse"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
put:
summary: Update a training date by ID
operationId: updateTrainingDate
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateTrainingDateRequest"
responses:
"200":
description: Training date updated
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateTrainingDateResponse"
"400":
$ref: "#/components/responses/InvalidInputError"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
delete:
summary: Delete a training date by ID
operationId: deleteTrainingDate
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
responses:
"204":
description: Training date deleted
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}/upcoming-dates:
get:
summary: List upcoming dates of a training
operationId: listTrainingUpcomingDates
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
responses:
"200":
description: List of training dates
content:
application/json:
schema:
$ref: "#/components/schemas/ListTrainingUpcomingDatesResponse"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/upcoming-dates:
get:
summary: List all upcoming dates of all trainings
operationId: listAllUpcomingTrainingDates
tags:
- Trainings
responses:
"200":
description: List of all training upcoming dates
content:
application/json:
schema:
$ref: "#/components/schemas/ListAllUpcomingTrainingDatesResponse"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}/dates/{trainingDateID}/attendees:
get:
summary: List all attendees of a training date
operationId: listTrainingDateAttendees
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
responses:
"200":
description: List of training date attendees
content:
application/json:
schema:
$ref: "#/components/schemas/ListTrainingDateAttendeesResponse"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
post:
summary: Create a new training date attendee
operationId: createTrainingDateAttendee
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTrainingDateAttendeeRequest"
responses:
"201":
description: Training date attendee created
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTrainingDateAttendeeResponse"
"400":
$ref: "#/components/responses/InvalidInputError"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}/dates/{trainingDateID}/attendees/{trainingDateAttendeeID}:
get:
summary: Get a training date attendee by ID
operationId: getTrainingDateAttendee
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
- $ref: "#/components/parameters/TrainingDateAttendeeID"
responses:
"200":
description: Training date attendee
content:
application/json:
schema:
$ref: "#/components/schemas/GetTrainingDateAttendeeResponse"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
put:
summary: Update a training date attendee by ID
operationId: updateTrainingDateAttendee
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
- $ref: "#/components/parameters/TrainingDateAttendeeID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateTrainingDateAttendeeRequest"
responses:
"200":
description: Training date attendee updated
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateTrainingDateAttendeeResponse"
"400":
$ref: "#/components/responses/InvalidInputError"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
delete:
summary: Delete a training date attendee by ID
operationId: deleteTrainingDateAttendee
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
- $ref: "#/components/parameters/TrainingDateAttendeeID"
responses:
"204":
description: Training date attendee deleted
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}/dates/{trainingDateID}/attendees/{trainingDateAttendeeID}/paid:
put:
summary: Update status of a training date attendee payment
operationId: updateTrainingDateAttendeePayment
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
- $ref: "#/components/parameters/TrainingDateAttendeeID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TrainingDateAttendeePaymentUpdateRequest"
responses:
"200":
description: Training date attendee payment status updated
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateTrainingDateAttendeeResponse"
"400":
$ref: "#/components/responses/InvalidInputError"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}/dates/{trainingDateID}/attendees/{trainingDateAttendeeID}/attended:
put:
summary: Update status of a training date attendee attendance
operationId: updateTrainingDateAttendeeAttendance
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
- $ref: "#/components/parameters/TrainingDateAttendeeID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TrainingDateAttendeeAttendanceUpdateRequest"
responses:
"200":
description: Training date attendee attendance status updated
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateTrainingDateAttendeeResponse"
"400":
$ref: "#/components/responses/InvalidInputError"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
/v1/trainings/{trainingID}/dates/{trainingDateID}/attendees/count:
get:
summary: Get a training date attendee count
operationId: getTrainingDateAttendeeCount
tags:
- Trainings
parameters:
- $ref: "#/components/parameters/TrainingID"
- $ref: "#/components/parameters/TrainingDateID"
responses:
"200":
description: Count of training date attendees
content:
application/json:
schema:
$ref: "#/components/schemas/GetTrainingDateAttendeeCountResponse"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/InternalError"
components:
parameters:
TrainingID:
in: path
name: trainingID
required: true
schema:
$ref: "#/components/schemas/TrainingID"
description: Training ID
TrainingDateID:
in: path
name: trainingDateID
required: true
schema:
$ref: "#/components/schemas/TrainingDateID"
description: Training Date ID
TrainingDateAttendeeID:
in: path
name: trainingDateAttendeeID
required: true
schema:
$ref: "#/components/schemas/TrainingDateAttendeeID"
description: Training Date Attendee ID
schemas:
CreateTrainingRequest:
$ref: "#/components/schemas/NewTraining"
CreateTrainingResponse:
$ref: "#/components/schemas/Training"
ListTrainingsResponse:
type: array
items:
$ref: "#/components/schemas/Training"
GetTrainingResponse:
$ref: "#/components/schemas/Training"
UpdateTrainingRequest:
$ref: "#/components/schemas/NewTraining"
UpdateTrainingResponse:
$ref: "#/components/schemas/Training"
NewTraining:
type: object
properties:
name:
type: string
days:
type: integer
format: int8
minimum: 1
maximum: 5
description:
type: string
pricing:
type: array
items:
$ref: "#/components/schemas/TrainingPrice"
slug:
type: string
required:
- name
- days
- description
- pricing
Training:
allOf:
- $ref: "#/components/schemas/NewTraining"
- type: object
properties:
id:
$ref: "#/components/schemas/TrainingID"
required:
- id
- slug
TrainingID:
type: integer
minimum: 1
x-go-type: training.ID
x-go-type-import:
path: gitlab.mareshq.com/hq/yggdrasil/pkg/training
TrainingPrice:
allOf:
- $ref: "#/components/schemas/Price"
- type: object
properties:
type:
type: string
enum:
- OPEN
- CORPORATE
required:
- type
CreateTrainingDateRequest:
$ref: "#/components/schemas/NewTrainingDate"
CreateTrainingDateResponse:
$ref: "#/components/schemas/TrainingDate"
ListTrainingDatesResponse:
type: array
items:
$ref: "#/components/schemas/TrainingDate"
GetTrainingDateResponse:
$ref: "#/components/schemas/TrainingDate"
UpdateTrainingDateRequest:
$ref: "#/components/schemas/NewTrainingDate"
UpdateTrainingDateResponse:
$ref: "#/components/schemas/TrainingDate"
ListAllUpcomingTrainingDatesResponse:
type: array
items:
type: object
properties:
trainingID:
$ref: "#/components/schemas/TrainingID"
dates:
type: array
items:
$ref: "#/components/schemas/TrainingDate"
required:
- trainingID
- dates
ListTrainingUpcomingDatesResponse:
type: array
items:
$ref: "#/components/schemas/TrainingDate"
NewTrainingDate:
type: object
properties:
date:
type: string
format: date
startTime:
type: string
format: time
days:
type: integer
format: int8
minimum: 1
maximum: 5
isOnline:
type: boolean
location:
type: string
address:
type: string
capacity:
type: integer
format: int8
minimum: 1
price:
$ref: "#/components/schemas/Price"
required:
- date
- startTime
- days
- isOnline
- location
- address
- capacity
- price
TrainingDate:
allOf:
- $ref: "#/components/schemas/NewTrainingDate"
- type: object
properties:
id:
$ref: "#/components/schemas/TrainingDateID"
required:
- id
TrainingDateID:
type: integer
minimum: 1
x-go-type: training.DateID
x-go-type-import:
path: gitlab.mareshq.com/hq/yggdrasil/pkg/training
CreateTrainingDateAttendeeRequest:
$ref: "#/components/schemas/NewTrainingDateAttendee"
CreateTrainingDateAttendeeResponse:
$ref: "#/components/schemas/TrainingDateAttendee"
ListTrainingDateAttendeesResponse:
type: array
items:
$ref: "#/components/schemas/TrainingDateAttendee"
GetTrainingDateAttendeeResponse:
$ref: "#/components/schemas/TrainingDateAttendee"
UpdateTrainingDateAttendeeRequest:
$ref: "#/components/schemas/NewTrainingDateAttendee"
UpdateTrainingDateAttendeeResponse:
$ref: "#/components/schemas/TrainingDateAttendee"
GetTrainingDateAttendeeCountResponse:
type: object
properties:
count:
type: integer
format: int8
minimum: 0
required:
- count
TrainingDateAttendeePaymentUpdateRequest:
type: object
properties:
paid:
type: boolean
required:
- paid
TrainingDateAttendeeAttendanceUpdateRequest:
type: object
properties:
attended:
type: boolean
required:
- attended
TrainingDateAttendeeID:
type: integer
minimum: 1
x-go-type: training.AttendeeID
x-go-type-import:
path: gitlab.mareshq.com/hq/yggdrasil/pkg/training
NewTrainingDateAttendee:
type: object
properties:
name:
type: string
email:
type: string
format: email
phone:
type: string
company:
type: string
position:
type: string
isStudent:
type: boolean
default: false
required:
- name
- email
- phone
- company
- position
TrainingDateAttendee:
allOf:
- $ref: "#/components/schemas/NewTrainingDateAttendee"
- type: object
properties:
id:
$ref: "#/components/schemas/TrainingDateAttendeeID"
bill:
$ref: "#/components/schemas/Price"
hasPaid:
type: boolean
default: false
hasAttended:
type: boolean
default: false
required:
- id
- bill
- hasPaid
- hasAttended
Price:
type: object
properties:
currency:
type: string
enum:
- CZK
- EUR
- USD
x-go-type: money.Currency
x-go-type-package:
path: gitlab.mareshq.com/hq/yggdrasil/internal/money
amount:
type: string
# x-go-type: decimal.Decimal
# x-go-type-package:
# path: github.com/shopspring/decimal
required:
- currency
- amount
ProblemDetails:
type: object
description: >
Schema that carries the details of an error in an HTTP response.
See https://datatracker.ietf.org/doc/html/rfc7807 for more information.
properties:
type:
type: string
description: A URI reference that identifies the problem type.
title:
type: string
description: A human-readable summary of the problem type.
status:
type: integer
description: The HTTP status code generated by the origin server for this occurrence of the problem.
detail:
type: string
description: A human-readable explanation specific to this occurrence of the problem.
instance:
type: string
description: A URI reference that identifies the specific occurrence of the problem.
required:
- type
- title
- status
- detail
- instance
responses:
InvalidInputError:
description: Invalid input error
content:
application/problem+json:
schema:
$ref: "#/components/schemas/ProblemDetails"
InternalError:
description: Internal error
content:
application/problem+json:
schema:
$ref: "#/components/schemas/ProblemDetails"
NotFoundError:
description: Not found error
content:
application/problem+json:
schema:
$ref: "#/components/schemas/ProblemDetails"