-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(swagger): add examples to all api params (#280)
- Loading branch information
Showing
10 changed files
with
156 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import { | |
ApiOkResponse, | ||
ApiOperation, | ||
ApiProduces, | ||
ApiQuery, | ||
ApiTags, | ||
} from '@nestjs/swagger'; | ||
import * as dotT from 'dot'; | ||
|
@@ -73,6 +74,7 @@ export class AppController { | |
} | ||
|
||
@Get('goto') | ||
@ApiQuery({ name: 'url', example: 'https://google.com', required: true }) | ||
@ApiOperation({ | ||
description: API_DESC_REDIRECT_REQUEST, | ||
}) | ||
|
@@ -85,6 +87,17 @@ export class AppController { | |
} | ||
|
||
@Post('metadata') | ||
@ApiProduces('text/plain') | ||
@ApiConsumes('text/plain') | ||
@ApiBody({ | ||
type: String, | ||
examples: { | ||
xml_doc: { | ||
summary: 'XML doc', | ||
value: `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 915 585"><g stroke-width="3.45" fill="none"><path stroke="#000" d="M11.8 11.8h411v411l-411 .01v-411z"/><path stroke="#448" d="M489 11.7h415v411H489v-411z"/></g></svg>`, | ||
}, | ||
}, | ||
}) | ||
@ApiOperation({ | ||
description: API_DESC_XML_METADATA, | ||
}) | ||
|
@@ -120,6 +133,7 @@ export class AppController { | |
} | ||
|
||
@Get('spawn') | ||
@ApiQuery({ name: 'command', example: 'ls -la', required: true }) | ||
@ApiOperation({ | ||
description: API_DESC_LAUNCH_COMMAND, | ||
}) | ||
|
@@ -191,6 +205,7 @@ export class AppController { | |
} | ||
|
||
@Get('/v1/userinfo/:email') | ||
@ApiQuery({ name: 'email', example: '[email protected]', required: true }) | ||
@UseInterceptors(ClassSerializerInterceptor) | ||
@SerializeOptions({ groups: [BASIC_USER_INFO] }) | ||
@ApiOperation({ | ||
|
@@ -219,6 +234,7 @@ export class AppController { | |
} | ||
|
||
@Get('/v2/userinfo/:email') | ||
@ApiQuery({ name: 'email', example: '[email protected]', required: true }) | ||
@UseGuards(AuthGuard) | ||
@JwtType(JwtProcessorType.RSA) | ||
@UseInterceptors(ClassSerializerInterceptor) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import { Controller, Logger, Post, Query } from '@nestjs/common'; | ||
import { ApiCreatedResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
import { | ||
ApiCreatedResponse, | ||
ApiOperation, | ||
ApiQuery, | ||
ApiTags, | ||
} from '@nestjs/swagger'; | ||
import { SWAGGER_DESC_CREATE_SUBSCRIPTION } from './subscriptions.controller.swagger.desc'; | ||
|
||
@Controller('/api/subscriptions') | ||
|
@@ -8,6 +13,11 @@ export class SubscriptionsController { | |
private readonly logger = new Logger(SubscriptionsController.name); | ||
|
||
@Post() | ||
@ApiQuery({ | ||
name: 'email', | ||
example: '[email protected]', | ||
required: true, | ||
}) | ||
@ApiOperation({ | ||
description: SWAGGER_DESC_CREATE_SUBSCRIPTION, | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.