700 lines
19 KiB
YAML
700 lines
19 KiB
YAML
openapi: "3.1.0"
|
|
info:
|
|
version: 1.3.0
|
|
x-go-package: "github.com/oapi-codegen/runtime"
|
|
title: Backoffice API
|
|
license:
|
|
name: Proprietary
|
|
contact:
|
|
name: Vojtěch Mareš
|
|
email: iam@vojtechmares.com
|
|
url: https://www.vojtechmares.com
|
|
x-oapi-codegen-middlewares:
|
|
- Middleware
|
|
servers:
|
|
- url: http://localhost:8080/v1
|
|
description: Local development server
|
|
- url: https://api.backoffice.staging.mareshq.com/v1
|
|
description: Staging server
|
|
- url: https://api.backoffice.mareshq.com/v1
|
|
description: Production server
|
|
paths:
|
|
/trainings:
|
|
get:
|
|
summary: List all trainings
|
|
operationId: listTrainings
|
|
tags:
|
|
- trainings
|
|
responses:
|
|
"200":
|
|
description: A list of trainings
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/Training"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
post:
|
|
summary: Create a new training
|
|
operationId: createTraining
|
|
tags:
|
|
- trainings
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/NewTraining"
|
|
responses:
|
|
"201":
|
|
description: Training created
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/Training"
|
|
"400":
|
|
description: Invalid input
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
/trainings/{trainingID}:
|
|
get:
|
|
summary: Get a training by ID
|
|
operationId: getTraining
|
|
tags:
|
|
- trainings
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
responses:
|
|
"200":
|
|
description: A training
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/Training"
|
|
"404":
|
|
description: Training not found
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
put:
|
|
summary: Update a training by ID
|
|
operationId: updateTraining
|
|
tags:
|
|
- trainings
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/NewTraining"
|
|
responses:
|
|
"200":
|
|
description: Training updated
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/Training"
|
|
"404":
|
|
description: Training not found
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"400":
|
|
description: Invalid input
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
|
|
delete:
|
|
summary: Delete a training by ID
|
|
operationId: deleteTraining
|
|
tags:
|
|
- trainings
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
responses:
|
|
"204":
|
|
description: Training deleted
|
|
"404":
|
|
description: Training not found
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
|
|
/trainings/{trainingID}/dates:
|
|
get:
|
|
summary: List all dates of a training
|
|
operationId: listTrainingDates
|
|
tags:
|
|
- training dates
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
responses:
|
|
"200":
|
|
description: A list of dates
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/TrainingDate"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
|
|
post:
|
|
summary: Create a new date for a training
|
|
operationId: createTrainingDate
|
|
tags:
|
|
- training dates
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/NewTrainingDate"
|
|
responses:
|
|
"201":
|
|
description: Date created
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/TrainingDate"
|
|
"409":
|
|
description: Date already exists
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
|
|
/trainings/{trainingID}/dates/{dateID}:
|
|
delete:
|
|
summary: Delete a date of a training
|
|
operationId: deleteTrainingDate
|
|
tags:
|
|
- training dates
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
- name: dateID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.DateID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
responses:
|
|
"204":
|
|
description: Date deleted
|
|
"404":
|
|
description: Date not found
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
put:
|
|
summary: Update a date of a training
|
|
operationId: updateTrainingDate
|
|
tags:
|
|
- training dates
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
- name: dateID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.DateID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/NewTrainingDate"
|
|
responses:
|
|
"200":
|
|
description: Date updated
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/TrainingDate"
|
|
"404":
|
|
description: Date not found
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"400":
|
|
description: Invalid input
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
|
|
/trainings/{trainingID}/dates/{dateID}/attendees:
|
|
get:
|
|
summary: List all attendees of a date of a training
|
|
operationId: listTrainingDateAttendees
|
|
tags:
|
|
- training dates attendees
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
- name: dateID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.DateID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
responses:
|
|
"200":
|
|
description: A list of attendees
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/TrainingDateAttendee"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
|
|
post:
|
|
summary: Add an attendee to a date of a training
|
|
operationId: createTrainingDateAttendee
|
|
tags:
|
|
- training dates attendees
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
- name: dateID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.DateID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/NewTrainingDateAttendee"
|
|
responses:
|
|
"201":
|
|
description: Attendee created
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/TrainingDateAttendee"
|
|
"409":
|
|
description: Attendee already exists (attendee already registered for this date)
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
|
|
/trainings/{trainingID}/dates/{dateID}/attendees/{attendeeID}:
|
|
delete:
|
|
summary: Delete an attendee of a date of a training
|
|
operationId: deleteTrainingDateAttendee
|
|
tags:
|
|
- training dates attendees
|
|
parameters:
|
|
- name: trainingID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
- name: dateID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.DateID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
- name: attendeeID
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.AttendeeID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
responses:
|
|
"204":
|
|
description: Attendee deleted
|
|
"404":
|
|
description: Attendee not found
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
|
|
/trainings/upcoming-dates:
|
|
get:
|
|
summary: List all upcoming dates of all trainings
|
|
operationId: listUpcomingTrainingDates
|
|
tags:
|
|
- training dates
|
|
parameters:
|
|
- name: from
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
format: date
|
|
- name: to
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
format: date
|
|
- name: limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
format: date
|
|
default: 10
|
|
responses:
|
|
"200":
|
|
description: A list of dates
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
type: object
|
|
properties:
|
|
training:
|
|
$ref: "#/components/schemas/Training"
|
|
date:
|
|
$ref: "#/components/schemas/TrainingDate"
|
|
"500":
|
|
description: Internal error
|
|
content:
|
|
application/problem+json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProblemDetails"
|
|
components:
|
|
schemas:
|
|
NewTraining:
|
|
type: object
|
|
properties:
|
|
name:
|
|
type: string
|
|
days:
|
|
type: integer
|
|
format: int32
|
|
price:
|
|
$ref: "#/components/schemas/TrainingPrice"
|
|
required:
|
|
- name
|
|
- days
|
|
- price
|
|
Training:
|
|
allOf:
|
|
- $ref: "#/components/schemas/NewTraining"
|
|
- type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.ID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
required:
|
|
- id
|
|
|
|
TrainingPrice:
|
|
types: array
|
|
items:
|
|
type: object
|
|
required:
|
|
- type
|
|
- price
|
|
properties:
|
|
type:
|
|
type: string
|
|
enum: [open, corporate]
|
|
price:
|
|
type: object
|
|
required:
|
|
- currency
|
|
- amount
|
|
properties:
|
|
currency:
|
|
type: string
|
|
enum: [CZK, EUR, USD]
|
|
amount:
|
|
type: number
|
|
format: float64
|
|
minimum: 0
|
|
|
|
NewTrainingDate:
|
|
type: object
|
|
properties:
|
|
date:
|
|
type: string
|
|
format: date
|
|
capacity:
|
|
type: integer
|
|
format: int32
|
|
days:
|
|
type: integer
|
|
format: int32
|
|
location:
|
|
type: string
|
|
price:
|
|
$ref: "#/components/schemas/Price"
|
|
required:
|
|
- date
|
|
- capacity
|
|
- price
|
|
- days
|
|
- location
|
|
|
|
TrainingDate:
|
|
allOf:
|
|
- $ref: "#/components/schemas/NewTrainingDate"
|
|
- type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.DateID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
address:
|
|
type: string
|
|
required:
|
|
- id
|
|
|
|
NewTrainingDateAttendee:
|
|
type: object
|
|
properties:
|
|
name:
|
|
type: string
|
|
email:
|
|
type: string
|
|
required:
|
|
- name
|
|
- email
|
|
|
|
TrainingDateAttendee:
|
|
allOf:
|
|
- $ref: "#/components/schemas/NewTrainingDateAttendee"
|
|
- type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
format: uuid
|
|
x-go-type: training.AttendeeID
|
|
x-go-type-import:
|
|
path: gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training
|
|
company:
|
|
type: string
|
|
required:
|
|
- id
|
|
|
|
Price:
|
|
type: object
|
|
properties:
|
|
currency:
|
|
type: string
|
|
enum: [CZK, EUR, USD]
|
|
amount:
|
|
type: number
|
|
format: float
|
|
minimum: 0
|
|
|
|
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
|