fix: correct openapi schema for decks

This commit is contained in:
2024-05-21 13:00:47 +02:00
parent 8c8ad9789d
commit 68110c9cfb
3 changed files with 7002 additions and 5450 deletions

12069
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -37,12 +37,7 @@ import { Card, CardWithGrade, PaginatedCardsWithGrade } from '../cards/entities/
import { CreateDeckDto, GetAllDecksDto, UpdateDeckDto } from './dto' import { CreateDeckDto, GetAllDecksDto, UpdateDeckDto } from './dto'
import { GetRandomCardDto } from './dto/get-random-card.dto' import { GetRandomCardDto } from './dto/get-random-card.dto'
import { import { Deck, PaginatedDecks, PaginatedDecksWithMaxCardsCount } from './entities/deck.entity'
Deck,
DeckWithAuthor,
PaginatedDecks,
PaginatedDecksWithMaxCardsCount,
} from './entities/deck.entity'
import { MinMaxCards } from './entities/min-max-cards.entity' import { MinMaxCards } from './entities/min-max-cards.entity'
import { import {
CreateCardCommand, CreateCardCommand,
@@ -120,7 +115,7 @@ export class DecksController {
cover: Express.Multer.File[] cover: Express.Multer.File[]
}, },
@Body() createDeckDto: CreateDeckDto @Body() createDeckDto: CreateDeckDto
): Promise<DeckWithAuthor> { ): Promise<Deck> {
const userId = req.user.id const userId = req.user.id
return this.commandBus.execute( return this.commandBus.execute(
@@ -133,7 +128,7 @@ export class DecksController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':id') @Get(':id')
@ApiBearerAuth() @ApiBearerAuth()
findOne(@Param('id') id: string): Promise<DeckWithAuthor> { findOne(@Param('id') id: string): Promise<Deck> {
return this.commandBus.execute(new GetDeckByIdCommand(id)) return this.commandBus.execute(new GetDeckByIdCommand(id))
} }
@@ -153,7 +148,7 @@ export class DecksController {
}, },
@Body() updateDeckDto: UpdateDeckDto, @Body() updateDeckDto: UpdateDeckDto,
@Req() req @Req() req
): Promise<DeckWithAuthor> { ): Promise<Deck> {
return this.commandBus.execute( return this.commandBus.execute(
new UpdateDeckCommand(id, updateDeckDto, req.user.id, files?.cover?.[0]) new UpdateDeckCommand(id, updateDeckDto, req.user.id, files?.cover?.[0])
) )

View File

@@ -257,7 +257,7 @@ LIMIT $${conditions.length + havingConditions.length + 1} OFFSET $${
}, },
}) })
return { ...result, cardsCount: result._count.card } return omit({ ...result, cardsCount: result._count.card }, ['_count'])
} catch (e) { } catch (e) {
this.logger.error(e?.message) this.logger.error(e?.message)
throw new InternalServerErrorException(e?.message) throw new InternalServerErrorException(e?.message)