Skip to content

Commit 2d0e0e5

Browse files
committed
backend: add documentation
1 parent 318921f commit 2d0e0e5

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

backend/controllers/StationsController.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { type Station } from "../models/station.ts";
22
import { mapToEnum, Products } from "../models/products.ts";
3-
import { Controller, Get, Path, Query, Res, Route, type TsoaResponse } from "tsoa";
3+
import { Controller, Get, Path, Query, Res, Route, Tags, type TsoaResponse } from "tsoa";
44
import { getRedisClient } from "../lib/redis.ts";
55

66
@Route("stations")
7+
@Tags("Stations")
78
export class StationController extends Controller {
89
@Get()
910
async queryStations(

backend/controllers/timetable/BahnhofController.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type RequestType, retrieveBahnhofJourneys } from "./requests.ts";
2-
import { Controller, Get, Queries, Route } from "tsoa";
2+
import { Controller, Get, Queries, Route, Tags } from "tsoa";
33
import type { Journey } from "../../models/connection.ts";
44

55
class BahnhofQuery {
@@ -10,6 +10,7 @@ class BahnhofQuery {
1010
}
1111

1212
@Route("timetable/bahnhof")
13+
@Tags("Bahnhof")
1314
export class BahnhofController extends Controller {
1415
@Get()
1516
async getBahnhofJourneys(@Queries() query: BahnhofQuery): Promise<Journey[]> {

backend/controllers/timetable/CombinedController.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { RequestType, retrieveBahnhofJourneys, retrieveCombinedConnections } fro
33
import type { Connection, Journey } from "../../models/connection.ts";
44
import { isMatching } from "../../lib/merge.ts";
55
import calculateDuration from "../../lib/time.ts";
6-
import { Controller, Get, Queries, Res, Route, type TsoaResponse } from "tsoa";
6+
import { Controller, Get, Queries, Res, Route, Tags, type TsoaResponse } from "tsoa";
77

88
class CombinedQuery {
99
evaNumber!: string;
@@ -15,6 +15,7 @@ class CombinedQuery {
1515
}
1616

1717
@Route("timetable/combined")
18+
@Tags("Combined")
1819
export class CombinedController extends Controller {
1920
@Get()
2021
async getCombinedJourneys(

backend/controllers/timetable/VendoController.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DateTime } from "luxon";
22
import { Profile, RequestType, retrieveCombinedConnections, retrieveConnections } from "./requests.ts";
3-
import { Controller, Get, Queries, Res, Route, type TsoaResponse } from "tsoa";
3+
import { Controller, Get, Queries, Res, Route, Tags, type TsoaResponse } from "tsoa";
44
import type { Journey } from "../../models/connection.ts";
55

66
class VendoQuery {
@@ -13,6 +13,7 @@ class VendoQuery {
1313
}
1414

1515
@Route("timetable/vendo")
16+
@Tags("Vendo")
1617
export class VendoController extends Controller {
1718
@Get()
1819
async getVendoJourneys(

backend/tsoa.json

+23-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,29 @@
66
"outputDirectory": "build",
77
"specVersion": 3,
88
"version": "1.0.0",
9-
"basePath": "/api/v1/"
9+
"basePath": "/api/v1/",
10+
"tags": [
11+
{
12+
"name": "Bahnhof",
13+
"description": "Returns journeys from the DeutscheBahn Bahnhof API. All journeys are returned with a RIS ID"
14+
},
15+
{
16+
"name": "Vendo",
17+
"description": "Returns journeys from the [email protected]. It is possible to select the profile which returns the journeys with the depending ID of the profile",
18+
"externalDocs": {
19+
"description": "See more in the API Documentation",
20+
"url": "https://github.com/public-transport/db-vendo-client"
21+
}
22+
},
23+
{
24+
"name": "Combined",
25+
"description": "Combines both Bahnhof & Vendo journeys into a single response for better convenience"
26+
},
27+
{
28+
"name": "Stations",
29+
"description": "Returns all stations from the DeutscheBahn API"
30+
}
31+
]
1032
},
1133
"routes": {
1234
"routesDir": "build",

0 commit comments

Comments
 (0)