overhauled API:

- wrote openapi schema
- re-implemented api endpoint following openapi schema
- intensified and improved working with Result objects

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2024-12-31 00:02:14 +01:00
parent 10ad309d8c
commit 4822320961
28 changed files with 874 additions and 542 deletions

View File

@@ -13,110 +13,6 @@ servers:
- url: https://cal.srsoftware.de
- url: http://localhost:8080
paths:
/api/events/json:
get:
description: |-
Get a list of events from the server in JSON format.
Filters may be applied by using request parameters.
parameters:
- description: Filter keywords. Only events having all provided tags are listed
example: magrathea,heartofgold
in: query
name: tags
required: false
schema:
format: comma-separated values
type: string
- description: start time. Only events after this date time are returned
example: 2024-12-30T10:32
in: query
name: start
required: false
schema:
format: date-time
type: string
- description: |-
Return past events, if set. Allowed values:
* all → return all events
* [n]m return events including the last n months
* [n]y - return events including the last n years
example: 2m
in: query
name: past
required: false
schema:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/AppointmentList'
'400':
description: invalid input
'500':
description: server fault
summary: Fetch event list
/api/events/ical:
get:
description: |-
Get a list of events from the server in ICAL format.
Filters may be applied by using request parameters.
parameters:
- description: Filter keywords. Only events having all provided tags are listed
example: magrathea,heartofgold
in: query
name: tags
required: false
schema:
format: comma-separated values
type: string
- description: start time. Only events after this date time are returned
example: 2024-12-30T10:32
in: query
name: start
required: false
schema:
format: date-time
type: string
- description: |-
Return past events, if set. Allowed values:
* all → return all events
* [n]m return events including the last n months
* [n]y - return events including the last n years
example: 2m
in: query
name: past
required: false
schema:
type: string
responses:
'200':
description: successful operation
content:
text/calendar:
schema:
description: event list in ical format
example: |-
BEGIN:VCALENDAR
VERSION:2.0
PRODID:OpenCloudCal
BEGIN:VEVENT
UID:42@cal.srsoftware.de
DTSTART:20241230T100757Z
DTEND:20241231T100757Z
SUMMARY:Demolition of the earth
END:VEVENT
END:VCALENDAR
type: string
'400':
description: invalid input
'500':
description: server fault
summary: Fetch event list
/api/event:
delete:
description: Deletes the specified element from the list of events.
@@ -139,6 +35,8 @@ paths:
responses:
'200':
description: successfull operation
'400':
description: id missing
'404':
description: invalid id (no such event)
'412':
@@ -219,7 +117,155 @@ paths:
description: invalid input
'500':
description: server fault
summary: store a new event in the database
summary:
store a new event in the database
/api/events/ical:
get:
description: |-
Get a list of events from the server in ICAL format.
Filters may be applied by using request parameters.
parameters:
- description: Filter keywords. Only events having all provided tags are listed
example: magrathea,heartofgold
in: query
name: tags
required: false
schema:
format: comma-separated values
type: string
- description: start time. Only events after this date time are returned
example: 2024-12-30T10:32
in: query
name: start
required: false
schema:
format: date-time
type: string
- description: |-
Return past events, if set. Allowed values:
* all → return all events
* [n]m return events including the last n months
* [n]y - return events including the last n years
example: 2m
in: query
name: past
required: false
schema:
type: string
responses:
'200':
description: successful operation
content:
text/calendar:
schema:
description: event list in ical format
example: |-
BEGIN:VCALENDAR
VERSION:2.0
PRODID:OpenCloudCal
BEGIN:VEVENT
UID:42@cal.srsoftware.de
DTSTART:20241230T100757Z
DTEND:20241231T100757Z
SUMMARY:Demolition of the earth
END:VEVENT
END:VCALENDAR
type: string
'400':
description: invalid input
'500':
description: server fault
summary: Fetch event list
/api/events/json:
get:
description: |-
Get a list of events from the server in JSON format.
Filters may be applied by using request parameters.
parameters:
- description: Maximum number of appointments to return
example: 100
in: query
name: count
required: false
schema:
format: int32
type: number
- description: skip number of appointments when listing
example: 50
in: query
name: offset
required: false
schema:
format: int32
type: number
- description: |-
Return past events, if set. Allowed values:
* all → return all events
* [n]m return events including the last n months
* [n]y - return events including the last n years
example: 2m
in: query
name: past
required: false
schema:
type: string
- description: start time. Only events after this date time are returned
example: 2024-12-30T10:32
in: query
name: start
required: false
schema:
format: date-time
type: string
- description: Filter keywords. Only events having all provided tags are listed
example: magrathea,heartofgold
in: query
name: tags
required: false
schema:
format: comma-separated values
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/AppointmentList'
'400':
description: invalid input
'500':
description: server fault
summary:
Fetch event list
/api/tags:
get:
description: list tags
parameters:
- description: substring to search in tags
example: rock
in: query
name: infix
required: true
schema:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
description: keywords that describe the event. may be used to filter events
example:
- GlamRock
- HardRock
- Rockabilly
- RockNRoll
items:
type: string
type: array
components:
schemas:
Appointment: