diff --git a/src/controllers/ScanController.ts b/src/controllers/ScanController.ts
index ce25e16..c716b50 100644
--- a/src/controllers/ScanController.ts
+++ b/src/controllers/ScanController.ts
@@ -28,10 +28,10 @@ export class ScanController {
@Authorized("SCAN:GET")
@ResponseSchema(ResponseScan, { isArray: true })
@ResponseSchema(ResponseTrackScan, { isArray: true })
- @OpenAPI({ description: 'Lists all scans (normal or track) from all runners.
This includes the runner\'s group and distance ran.' })
+ @OpenAPI({ description: 'Lists all scans (normal or track) from all runners.
This includes the scan\'s runner\'s distance ran.' })
async getAll() {
let responseScans: ResponseScan[] = new Array();
- const scans = await this.scanRepository.find({ relations: ['runner'] });
+ const scans = await this.scanRepository.find({ relations: ['runner', 'runner.scans', 'runner.scans.track'] });
scans.forEach(scan => {
responseScans.push(scan.toResponse());
});
@@ -44,9 +44,9 @@ export class ScanController {
@ResponseSchema(ResponseTrackScan)
@ResponseSchema(ScanNotFoundError, { statusCode: 404 })
@OnUndefined(ScanNotFoundError)
- @OpenAPI({ description: 'Lists all information about the runner whose id got provided.' })
+ @OpenAPI({ description: 'Lists all information about the scan whose id got provided. This includes the scan\'s runner\'s distance ran.' })
async getOne(@Param('id') id: number) {
- let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner'] })
+ let scan = await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'runner.scans', 'runner.scans.track'] })
if (!scan) { throw new ScanNotFoundError(); }
return scan.toResponse();
}
@@ -54,7 +54,8 @@ export class ScanController {
@Post()
@UseBefore(ScanAuth)
@ResponseSchema(ResponseScan)
- @OpenAPI({ description: 'Create a new runner.
Please remeber to provide the runner\'s group\'s id.' })
+ @ResponseSchema(RunnerNotFoundError, { statusCode: 404 })
+ @OpenAPI({ description: 'Create a new scan.
Please remeber to provide the scan\'s runner\'s id and distance for normal scans.' })
async post(@Body({ validate: true }) createScan: CreateScan) {
let scan = await createScan.toScan();
scan = await this.scanRepository.save(scan);
@@ -64,6 +65,7 @@ export class ScanController {
@Post("/trackscans")
@UseBefore(ScanAuth)
@ResponseSchema(ResponseScan)
+ @ResponseSchema(RunnerNotFoundError, { statusCode: 404 })
@OpenAPI({ description: 'Create a new track scan.
This is just a alias for posting /scans' })
async postTrackScans(@Body({ validate: true }) createScan: CreateTrackScan) {
return this.post(createScan);
@@ -75,7 +77,7 @@ export class ScanController {
@ResponseSchema(ScanNotFoundError, { statusCode: 404 })
@ResponseSchema(RunnerNotFoundError, { statusCode: 404 })
@ResponseSchema(ScanIdsNotMatchingError, { statusCode: 406 })
- @OpenAPI({ description: "Update the runner whose id you provided.
Please remember that ids can't be changed." })
+ @OpenAPI({ description: "Update the scan whose id you provided.
Please remember that ids can't be changed and distances must be positive." })
async put(@Param('id') id: number, @Body({ validate: true }) scan: UpdateScan) {
let oldScan = await this.scanRepository.findOne({ id: id });
@@ -96,7 +98,7 @@ export class ScanController {
@ResponseSchema(ResponseScan)
@ResponseSchema(ResponseEmpty, { statusCode: 204 })
@OnUndefined(204)
- @OpenAPI({ description: 'Delete the runner whose id you provided.
If no runner with this id exists it will just return 204(no content).' })
+ @OpenAPI({ description: 'Delete the scan whose id you provided.
If no scan with this id exists it will just return 204(no content).' })
async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
let scan = await this.scanRepository.findOne({ id: id });
if (!scan) { return null; }
diff --git a/src/controllers/ScanStationController.ts b/src/controllers/ScanStationController.ts
index 7ad2630..4e32971 100644
--- a/src/controllers/ScanStationController.ts
+++ b/src/controllers/ScanStationController.ts
@@ -25,7 +25,7 @@ export class ScanStationController {
@Get()
@Authorized("STATION:GET")
@ResponseSchema(ResponseScanStation, { isArray: true })
- @OpenAPI({ description: 'Lists all scans (normal or track) from all runners.
This includes the runner\'s group and distance ran.' })
+ @OpenAPI({ description: 'Lists all stations.
This includes their associated tracks.' })
async getAll() {
let responseStations: ResponseScanStation[] = new Array();
const stations = await this.stationRepository.find({ relations: ['track'] });
@@ -40,7 +40,7 @@ export class ScanStationController {
@ResponseSchema(ResponseScanStation)
@ResponseSchema(ScanStationNotFoundError, { statusCode: 404 })
@OnUndefined(ScanStationNotFoundError)
- @OpenAPI({ description: 'Lists all information about the runner whose id got provided.' })
+ @OpenAPI({ description: 'Lists all information about the station whose id got provided.
This includes it\'s associated track.' })
async getOne(@Param('id') id: number) {
let scan = await this.stationRepository.findOne({ id: id }, { relations: ['track'] })
if (!scan) { throw new ScanStationNotFoundError(); }
@@ -51,7 +51,7 @@ export class ScanStationController {
@Authorized("STATION:CREATE")
@ResponseSchema(ResponseScanStation)
@ResponseSchema(TrackNotFoundError, { statusCode: 404 })
- @OpenAPI({ description: 'Create a new runner.
Please remeber to provide the runner\'s group\'s id.' })
+ @OpenAPI({ description: 'Create a new station.
Please remeber to provide the station\'s track\'s id.
Please also remember that the station key is only visibe on creation.' })
async post(@Body({ validate: true }) createStation: CreateScanStation) {
let newStation = await createStation.toEntity();
const station = await this.stationRepository.save(newStation);
@@ -87,7 +87,7 @@ export class ScanStationController {
@ResponseSchema(ResponseEmpty, { statusCode: 204 })
@ResponseSchema(ScanStationHasScansError, { statusCode: 406 })
@OnUndefined(204)
- @OpenAPI({ description: 'Delete the runner whose id you provided.
If no runner with this id exists it will just return 204(no content).' })
+ @OpenAPI({ description: 'Delete the station whose id you provided.
If no station with this id exists it will just return 204(no content).
If the station still has scans associated you have to provide the force=true query param (warning: this deletes all scans associated with/created by this station - please disable it instead).' })
async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
let station = await this.stationRepository.findOne({ id: id });
if (!station) { return null; }