Skip to content

Commit

Permalink
docs: correctly display response of swap-routes route in swagger doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tmrdlt committed Aug 26, 2024
1 parent fe5ef01 commit 99bfe22
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/api/swap-routes/swap-routes.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { CacheInterceptor } from '@nestjs/cache-manager';
import { Controller, Get, Param, Query, UseInterceptors } from '@nestjs/common';
import { ApiOperation, ApiParam, ApiQuery, ApiResponse } from '@nestjs/swagger';
import {
ApiExtraModels,
ApiOperation,
ApiParam,
ApiQuery,
ApiResponse,
getSchemaPath,
} from '@nestjs/swagger';
import * as prisma from '@prisma/client';

import * as dto from '@/api/api.model';
Expand Down Expand Up @@ -42,10 +49,9 @@ export class SwapRoutesController {

@ApiOperation({
summary: 'Retrieves all swap routes between two tokens',
description: `Gets all swap routes directly or with one intermediate token from one token to another. \
The routes are represented as arrays of pairs.<br\> <b>NOTE</b>: the response is an array of pair arrays, but \
because of nest-swagger limitation the documentation can't show a multi-dimensional array. Though, please take in consideration \
the real response type is \`Array<Array<PairWithLiquidityAndTokenAddresses>>\``,
description:
'Gets all swap routes directly or with one intermediate token from one token to another. \
The routes are represented as arrays of pairs.',
})
@Get(':from/:to?')
@ApiQuery({
Expand All @@ -55,10 +61,18 @@ the real response type is \`Array<Array<PairWithLiquidityAndTokenAddresses>>\``,
'Retrieves only the pairs having both tokens added in the official token list',
required: false,
})
@ApiExtraModels(dto.PairWithLiquidityAndTokenAddresses)
@ApiResponse({
status: 200,
type: dto.PairWithLiquidityAndTokenAddresses,
isArray: true,
schema: {
type: 'array',
items: {
type: 'array',
items: {
$ref: getSchemaPath(dto.PairWithLiquidityAndTokenAddresses),
},
},
},
})
@ApiParam({
name: 'from',
Expand Down

0 comments on commit 99bfe22

Please sign in to comment.