chore: strengthen backend eslint profile
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { HttpStatus, applyDecorators } from '@nestjs/common';
|
||||
import { applyDecorators, HttpStatus } from '@nestjs/common';
|
||||
import {
|
||||
ApiExtraModels,
|
||||
ApiProperty,
|
||||
ApiPropertyOptional,
|
||||
ApiResponse,
|
||||
getSchemaPath,
|
||||
} from '@nestjs/swagger';
|
||||
@@ -13,8 +14,8 @@ export class ProblemDetailsDto {
|
||||
@ApiProperty({ example: 'UNAUTHORIZED' })
|
||||
declare code: string;
|
||||
|
||||
@ApiProperty({
|
||||
required: false,
|
||||
// eslint-disable-next-line @darraghor/nestjs-typed/api-property-returning-array-should-set-array -- Raw OpenAPI items schema already declares type: array.
|
||||
@ApiPropertyOptional({
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
@@ -23,7 +24,7 @@ export class ProblemDetailsDto {
|
||||
},
|
||||
example: [{ pointer: '#/email', detail: 'must be a valid email address' }],
|
||||
})
|
||||
errors?: { pointer: string; detail: string }[];
|
||||
errors?: { detail: string; pointer: string }[];
|
||||
}
|
||||
|
||||
function problemResponse(status: number, description: string) {
|
||||
@@ -38,7 +39,7 @@ function problemResponse(status: number, description: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function ApiProblemResponses(): MethodDecorator & ClassDecorator {
|
||||
export function ApiProblemResponses(): ClassDecorator & MethodDecorator {
|
||||
return applyDecorators(
|
||||
ApiExtraModels(ProblemDetailsDto),
|
||||
problemResponse(HttpStatus.BAD_REQUEST, 'Invalid request'),
|
||||
|
||||
Reference in New Issue
Block a user