Skip to content

Commit

Permalink
🐛 Added security scheme to openapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Aug 2, 2024
1 parent d0a4ab1 commit 4e37912
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
14 changes: 11 additions & 3 deletions packages/api/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LoggerService } from '@@core/@core-services/logger/logger.service';
import { Controller, Get } from '@nestjs/common';
import { ApiOperation, ApiResponse } from '@nestjs/swagger';
import { ApiOkResponse, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { AppService } from './app.service';
import { ApiGetCustomResponse } from '@@core/utils/dtos/openapi.respone.dto';

Expand All @@ -14,14 +14,22 @@ export class AppController {
}

@ApiOperation({ operationId: 'hello' })
@ApiGetCustomResponse(String)
@ApiOkResponse({
schema: {
type: 'string',
},
})
@Get()
hello(): string {
return this.appService.getHello();
}

@ApiOperation({ operationId: 'health' })
@ApiGetCustomResponse(Number)
@ApiOkResponse({
schema: {
type: 'number',
},
})
@Get('health')
health(): number {
return 200;
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function addSpeakeasyGroup(document: any) {
const pathParts = path.split('/').filter((part) => part);
let groupName;

if (pathParts[0] === 'webhook') {
groupName = 'webhook';
if (pathParts[0] === 'webhooks') {
groupName = 'webhooks';
} else if (pathParts[0] === 'sync') {
groupName = 'sync';
} else if (pathParts[0] === 'linked-users') {
Expand Down
18 changes: 7 additions & 11 deletions packages/api/swagger/swagger-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/String'
type: string
/health:
get:
operationId: health
Expand All @@ -23,7 +23,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Number'
type: number
/webhooks:
get:
operationId: listWebhooks
Expand All @@ -40,6 +40,7 @@ paths:
$ref: '#/components/schemas/WebhookResponse'
tags: &ref_0
- webhooks
x-speakeasy-group: webhooks
post:
operationId: createWebhookPublic
summary: Add webhook metadata
Expand All @@ -58,6 +59,7 @@ paths:
schema:
$ref: '#/components/schemas/WebhookResponse'
tags: *ref_0
x-speakeasy-group: webhooks
/webhooks/{id}:
delete:
operationId: delete
Expand All @@ -78,7 +80,7 @@ paths:
schema:
$ref: '#/components/schemas/WebhookResponse'
tags: *ref_0
x-speakeasy-group: webhooks.{id}
x-speakeasy-group: webhooks
put:
operationId: updateStatus
summary: Update webhook status
Expand All @@ -98,7 +100,7 @@ paths:
schema:
$ref: '#/components/schemas/WebhookResponse'
tags: *ref_0
x-speakeasy-group: webhooks.{id}
x-speakeasy-group: webhooks
/webhooks/verifyEvent:
post:
operationId: verifyEvent
Expand All @@ -124,7 +126,7 @@ paths:
'201':
description: ''
tags: *ref_0
x-speakeasy-group: webhooks.verifyevent
x-speakeasy-group: webhooks
/ticketing/tickets:
get:
operationId: listTicketingTicket
Expand Down Expand Up @@ -7790,12 +7792,6 @@ components:
type: http
scheme: bearer
schemas:
String:
type: object
properties: {}
Number:
type: object
properties: {}
WebhookResponse:
type: object
properties:
Expand Down

0 comments on commit 4e37912

Please sign in to comment.