Commit ede0080c authored by nanahira's avatar nanahira

better docs

parent d9deb6bd
Pipeline #22249 passed with stages
in 1 minute and 33 seconds
...@@ -182,7 +182,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> { ...@@ -182,7 +182,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> {
throw new BlankReturnMessageDto(500, 'Internal error').toException(); throw new BlankReturnMessageDto(500, 'Internal error').toException();
} }
}); });
return new this.entityReturnMessageDto(201, 'success', savedEnt); return new this.entityReturnMessageDto(200, 'success', savedEnt);
} }
get entityAliasName() { get entityAliasName() {
...@@ -346,7 +346,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> { ...@@ -346,7 +346,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> {
`${this.entityName} ID ${id} not found.`, `${this.entityName} ID ${id} not found.`,
).toException(); ).toException();
} }
return new BlankReturnMessageDto(204, 'success'); return new BlankReturnMessageDto(200, 'success');
} }
async importEntities( async importEntities(
...@@ -381,7 +381,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> { ...@@ -381,7 +381,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> {
...data.results.map((e) => ({ entry: e, result: 'OK' })), ...data.results.map((e) => ({ entry: e, result: 'OK' })),
]; ];
return new this.importReturnMessageDto( return new this.importReturnMessageDto(
201, 200,
'success', 'success',
results.map((r) => { results.map((r) => {
const entry = new this.importEntryDto(); const entry = new this.importEntryDto();
......
...@@ -19,9 +19,10 @@ import { ...@@ -19,9 +19,10 @@ import {
import { MergeMethodDecorators } from './merge'; import { MergeMethodDecorators } from './merge';
import { ClassType } from '../utility/insert-field'; import { ClassType } from '../utility/insert-field';
import { import {
ApiBadRequestResponse,
ApiBody, ApiBody,
ApiCreatedResponse, ApiInternalServerErrorResponse,
ApiNoContentResponse, ApiNotFoundResponse,
ApiOkResponse, ApiOkResponse,
ApiOperation, ApiOperation,
ApiParam, ApiParam,
...@@ -97,6 +98,10 @@ export class RestfulFactory<T> { ...@@ -97,6 +98,10 @@ export class RestfulFactory<T> {
}), }),
ApiBody({ type: this.createDto }), ApiBody({ type: this.createDto }),
ApiOkResponse({ type: this.entityReturnMessageDto }), ApiOkResponse({ type: this.entityReturnMessageDto }),
ApiBadRequestResponse({
type: BlankReturnMessageDto,
description: `The ${this.entityClass.name} is not valid`,
}),
]); ]);
} }
...@@ -113,6 +118,10 @@ export class RestfulFactory<T> { ...@@ -113,6 +118,10 @@ export class RestfulFactory<T> {
}), }),
ApiParam({ name: 'id', type: this.idType, required: true }), ApiParam({ name: 'id', type: this.idType, required: true }),
ApiOkResponse({ type: this.entityReturnMessageDto }), ApiOkResponse({ type: this.entityReturnMessageDto }),
ApiNotFoundResponse({
type: BlankReturnMessageDto,
description: `The ${this.entityClass.name} with the given id was not found`,
}),
]); ]);
} }
...@@ -147,6 +156,18 @@ export class RestfulFactory<T> { ...@@ -147,6 +156,18 @@ export class RestfulFactory<T> {
ApiParam({ name: 'id', type: this.idType, required: true }), ApiParam({ name: 'id', type: this.idType, required: true }),
ApiBody({ type: this.updateDto }), ApiBody({ type: this.updateDto }),
ApiOkResponse({ type: BlankReturnMessageDto }), ApiOkResponse({ type: BlankReturnMessageDto }),
ApiNotFoundResponse({
type: BlankReturnMessageDto,
description: `The ${this.entityClass.name} with the given id was not found`,
}),
ApiBadRequestResponse({
type: BlankReturnMessageDto,
description: `The ${this.entityClass.name} is not valid`,
}),
ApiInternalServerErrorResponse({
type: BlankReturnMessageDto,
description: 'Internal error',
}),
]); ]);
} }
...@@ -164,6 +185,14 @@ export class RestfulFactory<T> { ...@@ -164,6 +185,14 @@ export class RestfulFactory<T> {
}), }),
ApiParam({ name: 'id', type: this.idType, required: true }), ApiParam({ name: 'id', type: this.idType, required: true }),
ApiOkResponse({ type: BlankReturnMessageDto }), ApiOkResponse({ type: BlankReturnMessageDto }),
ApiNotFoundResponse({
type: BlankReturnMessageDto,
description: `The ${this.entityClass.name} with the given id was not found`,
}),
ApiInternalServerErrorResponse({
type: BlankReturnMessageDto,
description: 'Internal error',
}),
]); ]);
} }
...@@ -175,7 +204,11 @@ export class RestfulFactory<T> { ...@@ -175,7 +204,11 @@ export class RestfulFactory<T> {
...extras, ...extras,
}), }),
ApiBody({ type: ImportDataDto(this.createDto) }), ApiBody({ type: ImportDataDto(this.createDto) }),
ApiCreatedResponse({ type: this.importReturnMessageDto }), ApiOkResponse({ type: this.importReturnMessageDto }),
ApiInternalServerErrorResponse({
type: BlankReturnMessageDto,
description: 'Internal error',
}),
]); ]);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment