Skip to content

Commit

Permalink
added JWT bearer Auth for Swagger UI, fixed spelling mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
egerj committed Mar 29, 2021
1 parent 31a2cfa commit 82ac140
Show file tree
Hide file tree
Showing 6 changed files with 6,644 additions and 6,275 deletions.
25 changes: 25 additions & 0 deletions src/SwaggerCSS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ export const css = `
color: #fff;
}
.swagger-ui .dialog-ux .modal-ux-content p {
color: #fff;
font-size: 16px;
}
.swagger-ui label {
display: none;
}
.swagger-ui .dialog-ux .modal-ux-content h4 {
color: #fff;
}
.swagger-ui .dialog-ux .modal-ux-header h3 {
color: #fff;
}
.swagger-ui .dialog-ux .modal-ux {
background: black;
}
.swagger-ui .scheme-container {
background: black;
}
.swagger-ui .opblock-tag {
border-color: rgba(255, 255, 255, 0.3)
}
Expand Down
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ async function bootstrap() {
.setTitle('Börsen API')
.setDescription('Die offizielle API der Börse')
.setVersion('1.0')
.addBearerAuth({
in: 'header',
type: 'http',
bearerFormat: 'JWT',
name: 'JWT',
description: 'Enter your given JWT token',
})
.build();

const options: SwaggerCustomOptions = {
Expand Down
2 changes: 2 additions & 0 deletions src/market/market.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class MarketController {

@ApiResponse({
description: 'Returns current state of market',
content: { 'text/plain': { schema: { example: 'open' } } },
status: 200,
})
@Get('status')
public async getStatus(): Promise<string> {
Expand Down
3 changes: 2 additions & 1 deletion src/order/order.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiParam, ApiTags } from '@nestjs/swagger';
import { MSBroker } from 'src/broker/broker.decorator';
import { BrokerTypeGuard, BrokerTypes } from 'src/broker/brokerType.guard';
import { BrokerModel } from 'src/broker/models/Broker.model';
Expand Down Expand Up @@ -53,6 +53,7 @@ export class OrderController {
}

@ApiBearerAuth()
@ApiParam({ name: 'id', example: '6053133b6f29c24f4851dd7e' })
@UseGuards(AuthGuard('jwt'))
@Get(':id')
async getOrderStatus(
Expand Down
2 changes: 1 addition & 1 deletion src/order/order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class OrderService {

/**
* get Orders
* @param broker: iformation about broker
* @param broker: information about broker
* @param id: id of Order
*/
public async getOrder(broker: BrokerModel, id: string): Promise<Order> {
Expand Down
Loading

0 comments on commit 82ac140

Please sign in to comment.