From 6ff0202bd6497a9e84a61c87064ad4280e48b1df Mon Sep 17 00:00:00 2001 From: Kozer4 Date: Tue, 23 Jul 2024 17:56:39 +0300 Subject: [PATCH] feat(Swagger): add info about Header config --- rest-api/src/controller/rest.controller.ts | 160 ++++++++++++++++++++- rest-api/tsoa.json | 35 ++++- 2 files changed, 190 insertions(+), 5 deletions(-) diff --git a/rest-api/src/controller/rest.controller.ts b/rest-api/src/controller/rest.controller.ts index d40cff4..7926d79 100644 --- a/rest-api/src/controller/rest.controller.ts +++ b/rest-api/src/controller/rest.controller.ts @@ -25,7 +25,7 @@ import { } from '@nestjs/common'; import { VersionedTransaction } from '@solana/web3.js'; import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon/horizon_api'; -import { Example, Response, Route, Tags } from 'tsoa'; +import { Example, Header, Response, Route, Tags } from 'tsoa'; import { TransactionConfig } from 'web3-core'; import { BridgeAmounts, @@ -52,7 +52,14 @@ export class RestController { @Response(400, 'Bad request') @Get('/chains') @Tags('Tokens') - async chainDetailsMap(@Request() req: Request): Promise { + async chainDetailsMap( + @Request() req: Request, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, + ): Promise { try { return this.sdkServiceBuilder .getSDKService(req.headers) @@ -68,7 +75,14 @@ export class RestController { @Response(400, 'Bad request') @Get('/tokens') @Tags('Tokens') - async getTokens(@Request() req: Request): Promise { + async getTokens( + @Request() req: Request, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, + ): Promise { try { return this.sdkServiceBuilder.getSDKService(req.headers).getTokens(); } catch (e) { @@ -95,6 +109,11 @@ export class RestController { * The maximum amount by default. */ @Query('amount') amount?: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const tokenAddressObj = await sdkService.getTokenByAddress(tokenAddress); @@ -154,6 +173,11 @@ export class RestController { * If solanaTxFeeParams is EXTRA_FEE_IN_LAMPORTS then string value represent Total Priority Fee as extraFeeInLamports param
*/ @Query('solanaTxFeeValue') solanaTxFeeValue?: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -330,6 +354,11 @@ export class RestController { * If solanaTxFeeParams is EXTRA_FEE_IN_LAMPORTS then string value represent Total Priority Fee as extraFeeInLamports param
*/ @Query('solanaTxFeeValue') solanaTxFeeValue?: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -418,6 +447,11 @@ export class RestController { @Request() req: Request, @Query('xdrTx') xdrTx: string, @Query('sender') sender: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { try { return await this.sdkServiceBuilder @@ -445,6 +479,11 @@ export class RestController { */ @Query('destinationToken') destinationToken: string, @Query('messenger') messenger: keyof typeof Messenger, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -484,6 +523,11 @@ export class RestController { @Request() req: Request, @Query('chain') chain: keyof typeof ChainSymbol, @Query('txId') txId: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { if (!Object.keys(ChainSymbol).includes(chain)) { throw new HttpException('Invalid chain', HttpStatus.BAD_REQUEST); @@ -508,6 +552,11 @@ export class RestController { @Request() req: Request, @Query('address') address: string, @Query('token') token: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise<{ result: string }> { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const tokenObj = await sdkService.getTokenByAddress(token); @@ -536,6 +585,11 @@ export class RestController { @Request() req: Request, @Query('address') address: string, @Query('chain') chain: keyof typeof ChainSymbol, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { if (!Object.keys(ChainSymbol).includes(chain)) { throw new HttpException('Invalid chain', HttpStatus.BAD_REQUEST); @@ -560,6 +614,11 @@ export class RestController { @Request() req: Request, @Query('address') address: string, @Query('chain') chain: keyof typeof ChainSymbol, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { if (!Object.keys(ChainSymbol).includes(chain)) { throw new HttpException('Invalid chain', HttpStatus.BAD_REQUEST); @@ -591,6 +650,11 @@ export class RestController { */ @Query('destinationToken') destinationToken: string, @Query('messenger') messenger: keyof typeof Messenger, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -630,6 +694,11 @@ export class RestController { @Request() req: Request, @Query('address') address: string, @Query('chain') chain: keyof typeof ChainSymbol, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { if (!Object.keys(ChainSymbol).includes(chain)) { throw new HttpException('Invalid chain', HttpStatus.BAD_REQUEST); @@ -654,6 +723,11 @@ export class RestController { @Request() req: Request, @Query('sourceToken') sourceToken: string, @Query('destinationToken') destinationToken: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -692,6 +766,11 @@ export class RestController { @Query('amount') amount: string, @Query('sourceToken') sourceToken: string, @Query('destinationToken') destinationToken: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -738,6 +817,11 @@ export class RestController { * selected token on the destination chain. */ @Query('destinationToken') destinationToken: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -784,6 +868,11 @@ export class RestController { * selected token on the destination chain. */ @Query('destinationToken') destinationToken: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -837,6 +926,11 @@ export class RestController { * *Optional:If provided, the fee will be deducted from the transaction amount */ @Query('relayerFeeInStables') relayerFeeInStables?: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -902,6 +996,11 @@ export class RestController { * *Optional:If provided, the fee will be deducted from the transaction amount */ @Query('relayerFeeInStables') relayerFeeInStables?: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const sourceTokenObj = await sdkService.getTokenByAddress(sourceToken); @@ -972,6 +1071,11 @@ export class RestController { * If solanaTxFeeParams is EXTRA_FEE_IN_LAMPORTS then string value represent Total Priority Fee as extraFeeInLamports param
*/ @Query('solanaTxFeeValue') solanaTxFeeValue?: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const tokenAddressObj = await sdkService.getTokenByAddress(tokenAddress); @@ -1048,6 +1152,11 @@ export class RestController { * If solanaTxFeeParams is EXTRA_FEE_IN_LAMPORTS then string value represent Total Priority Fee as extraFeeInLamports param
*/ @Query('solanaTxFeeValue') solanaTxFeeValue?: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const tokenAddressObj = await sdkService.getTokenByAddress(tokenAddress); @@ -1120,6 +1229,11 @@ export class RestController { * If solanaTxFeeParams is EXTRA_FEE_IN_LAMPORTS then string value represent Total Priority Fee as extraFeeInLamports param
*/ @Query('solanaTxFeeValue') solanaTxFeeValue?: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const tokenAddressObj = await sdkService.getTokenByAddress(tokenAddress); @@ -1173,6 +1287,11 @@ export class RestController { @Request() req: Request, @Query('address') address: string, @Query('token') token: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { try { return await this.sdkServiceBuilder @@ -1201,6 +1320,11 @@ export class RestController { */ @Query('tokenAddress') tokenAddress: string, @Query('feePaymentMethod') feePaymentMethod?: keyof typeof FeePaymentMethod, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const tokenAddressObj = await sdkService.getTokenByAddress(tokenAddress); @@ -1243,6 +1367,11 @@ export class RestController { * selected token on the source chain. */ @Query('poolAddress') poolAddress: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const poolAddressObj = await sdkService.getTokenByAddress(poolAddress); @@ -1268,6 +1397,11 @@ export class RestController { * selected token on the source chain. */ @Query('poolAddress') poolAddress: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise> { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const poolAddressObj = await sdkService.getTokenByAddress(poolAddress); @@ -1295,6 +1429,11 @@ export class RestController { */ @Query('poolAddress') poolAddress: string, @Query('feePaymentMethod') feePaymentMethod?: keyof typeof FeePaymentMethod, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const poolAddressObj = await sdkService.getTokenByAddress(poolAddress); @@ -1333,6 +1472,11 @@ export class RestController { * selected token on the source chain. */ @Query('poolAddress') poolAddress: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const poolAddressObj = await sdkService.getTokenByAddress(poolAddress); @@ -1362,6 +1506,11 @@ export class RestController { * selected token on the source chain. */ @Query('tokenAddress') tokenAddress: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const tokenAddressObj = await sdkService.getTokenByAddress(tokenAddress); @@ -1392,6 +1541,11 @@ export class RestController { * selected token on the source chain. */ @Query('tokenAddress') tokenAddress: string, + /** + * You can set up some properties via Headers. See README + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Header('_NODE_URL') docOnly?: any, ): Promise { const sdkService = this.sdkServiceBuilder.getSDKService(req.headers); const tokenAddressObj = await sdkService.getTokenByAddress(tokenAddress); diff --git a/rest-api/tsoa.json b/rest-api/tsoa.json index 053ffb0..7282220 100644 --- a/rest-api/tsoa.json +++ b/rest-api/tsoa.json @@ -2,11 +2,42 @@ "entryFile": "src/main.ts", "noImplicitAdditionalProperties": "throw-on-extras", "controllerPathGlobs": ["**/*controller.ts"], + "description": "@@@@@@@", "spec": { "outputDirectory": "public", - "specVersion": 3 + "specVersion": 3, + "tags": [ + { + "name": "Tokens", + "externalDocs": { + "description": "You can set up some properties via Headers.", + "url": "https://github.com/allbridge-io/allbridge-core-rest-api/blob/master/README.md?plain=1#L53" + } + }, + { + "name": "Pool", + "externalDocs": { + "description": "You can set up some properties via Headers.", + "url": "https://github.com/allbridge-io/allbridge-core-rest-api/blob/master/README.md?plain=1#L53" + } + }, + { + "name": "Transfers", + "externalDocs": { + "description": "You can set up some properties via Headers.", + "url": "https://github.com/allbridge-io/allbridge-core-rest-api/blob/master/README.md?plain=1#L53" + } + }, + { + "name": "Raw Transactions", + "externalDocs": { + "description": "You can set up some properties via Headers.", + "url": "https://github.com/allbridge-io/allbridge-core-rest-api/blob/master/README.md?plain=1#L53" + } + } + ] }, "routes": { - "routesDir": "src" + "description": "@@@@@@@" } } \ No newline at end of file