feat: add openapi spec
This commit is contained in:
parent
2acfb39ca5
commit
ecdf67f371
1 changed files with 218 additions and 0 deletions
218
api/v1/openapi.yaml
Normal file
218
api/v1/openapi.yaml
Normal file
|
|
@ -0,0 +1,218 @@
|
||||||
|
openapi: "3.1.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
|
||||||
|
|
||||||
|
paths:
|
||||||
|
/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"
|
||||||
|
|
||||||
|
/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"
|
||||||
|
|
||||||
|
components:
|
||||||
|
parameters:
|
||||||
|
TrainingID:
|
||||||
|
in: path
|
||||||
|
name: trainingID
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
description: Training 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: int32
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- days
|
||||||
|
|
||||||
|
Training:
|
||||||
|
allOf:
|
||||||
|
- $ref: "#/components/schemas/NewTraining"
|
||||||
|
- type: object
|
||||||
|
- properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
- required:
|
||||||
|
- id
|
||||||
|
|
||||||
|
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"
|
||||||
Reference in a new issue