Skip to content

Commit

Permalink
✨ Added open api docs and sdk generation
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Dec 17, 2023
1 parent 9fbcf84 commit da49ca1
Show file tree
Hide file tree
Showing 214 changed files with 157 additions and 18,655 deletions.
7 changes: 6 additions & 1 deletion packages/api/src/@core/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CreateUserDto } from './dto/create-user.dto';
import { AuthService } from './auth.service';
import { JwtAuthGuard } from './guards/jwt-auth.guard';
import { LoggerService } from '@@core/logger/logger.service';
import { ApiBody, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiKeyDto } from './dto/api-key.dto';
import { LoginDto } from './dto/login.dto';

Expand All @@ -17,32 +17,37 @@ export class AuthController {
this.logger.setContext(AuthController.name);
}

@ApiOperation({ operationId: 'signUp' })
@ApiBody({ type: CreateUserDto })
@ApiResponse({ status: 201 })
@Post('register')
async registerUser(@Body() user: CreateUserDto) {
return this.authService.register(user);
}

@ApiOperation({ operationId: 'signIn' })
@ApiBody({ type: LoginDto })
@ApiResponse({ status: 201 })
@Post('login')
async login(@Body() user: LoginDto) {
return this.authService.login(user);
}

@ApiOperation({ operationId: 'getUsers' })
@ApiResponse({ status: 200 })
@Get('users')
async users() {
return this.authService.getUsers();
}

@ApiOperation({ operationId: 'getApiKeys' })
@ApiResponse({ status: 200 })
@Get('api-keys')
async apiKeys() {
return this.authService.getApiKeys();
}

@ApiOperation({ operationId: 'generateApiKey' })
@ApiBody({ type: ApiKeyDto })
@ApiResponse({ status: 201 })
@UseGuards(JwtAuthGuard)
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/@core/connections/connections.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LoggerService } from '@@core/logger/logger.service';
import { NotFoundError, handleServiceError } from '@@core/utils/errors';
import { PrismaService } from '@@core/prisma/prisma.service';
import { ProviderVertical, getProviderVertical } from '@@core/utils/types';
import { ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiOperation, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';

@ApiTags('connections')
@Controller('connections')
Expand All @@ -18,6 +18,7 @@ export class ConnectionsController {
this.logger.setContext(ConnectionsController.name);
}

@ApiOperation({ operationId: 'handleOAuthCallback' })
@ApiQuery({ name: 'state', required: true, type: String })
@ApiQuery({ name: 'code', required: true, type: String })
@ApiQuery({ name: 'location', required: true, type: String })
Expand Down Expand Up @@ -73,6 +74,7 @@ export class ConnectionsController {
}
}

@ApiOperation({ operationId: 'getConnections' })
@ApiResponse({ status: 200 })
@Get()
async getConnections() {
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/@core/events/events.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Controller, Get } from '@nestjs/common';
import { EventsService } from './events.service';
import { LoggerService } from '@@core/logger/logger.service';
import { PrismaService } from '@@core/prisma/prisma.service';
import { ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
@ApiTags('events')
@Controller('events')
export class EventsController {
Expand All @@ -13,6 +13,7 @@ export class EventsController {
this.logger.setContext(EventsController.name);
}

@ApiOperation({ operationId: 'getEvents' })
@ApiResponse({ status: 200 })
@Get()
async getEvents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DefineTargetFieldDto,
MapFieldToProviderDto,
} from './dto/create-custom-field.dto';
import { ApiResponse, ApiTags, ApiBody } from '@nestjs/swagger';
import { ApiResponse, ApiTags, ApiBody, ApiOperation } from '@nestjs/swagger';

@ApiTags('field-mapping')
@Controller('field-mapping')
Expand All @@ -17,24 +17,28 @@ export class FieldMappingController {
this.logger.setContext(FieldMappingController.name);
}

@ApiOperation({ operationId: 'getFieldMappingsEntities' })
@ApiResponse({ status: 200 })
@Get('entities')
getEntities() {
return this.fieldMappingService.getEntities();
}

@ApiOperation({ operationId: 'getFieldMappings' })
@ApiResponse({ status: 200 })
@Get('attribute')
getAttributes() {
return this.fieldMappingService.getAttributes();
}

@ApiOperation({ operationId: 'getFieldMappingValues' })
@ApiResponse({ status: 200 })
@Get('value')
getValues() {
return this.fieldMappingService.getValues();
}

@ApiOperation({ operationId: 'defineTargetField' })
@ApiBody({ type: DefineTargetFieldDto })
@ApiResponse({ status: 201 })
//define target field on our unified model
Expand All @@ -43,13 +47,15 @@ export class FieldMappingController {
return this.fieldMappingService.defineTargetField(defineTargetFieldDto);
}

@ApiOperation({ operationId: 'mapField' })
@ApiBody({ type: MapFieldToProviderDto })
@ApiResponse({ status: 201 })
@Post('map')
mapFieldToProvider(@Body() mapFieldToProviderDto: MapFieldToProviderDto) {
return this.fieldMappingService.mapFieldToProvider(mapFieldToProviderDto);
}

@ApiOperation({ operationId: 'getCustomProviderProperties' })
@ApiResponse({ status: 200 })
@Get('properties')
getCustomProperties(
Expand Down
11 changes: 10 additions & 1 deletion packages/api/src/@core/linked-users/linked-users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { LinkedUsersService } from './linked-users.service';
import { LoggerService } from '../logger/logger.service';
import { CreateLinkedUserDto } from './dto/create-linked-user.dto';
import { ApiBody, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
import {
ApiBody,
ApiOperation,
ApiQuery,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';

@ApiTags('linked-users')
@Controller('linked-users')
Expand All @@ -14,19 +20,22 @@ export class LinkedUsersController {
this.logger.setContext(LinkedUsersController.name);
}

@ApiOperation({ operationId: 'addLinkedUser' })
@ApiBody({ type: CreateLinkedUserDto })
@ApiResponse({ status: 201 })
@Post('create')
addLinkedUser(@Body() linkedUserCreateDto: CreateLinkedUserDto) {
return this.linkedUsersService.addLinkedUser(linkedUserCreateDto);
}

@ApiOperation({ operationId: 'getLinkedUsers' })
@ApiResponse({ status: 200 })
@Get()
getLinkedUsers() {
return this.linkedUsersService.getLinkedUsers();
}

@ApiOperation({ operationId: 'getLinkedUser' })
@ApiQuery({ name: 'id', required: true, type: String })
@ApiResponse({ status: 200 })
@Get('single')
Expand Down
11 changes: 10 additions & 1 deletion packages/api/src/@core/magic-link/magic-link.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { LoggerService } from '@@core/logger/logger.service';
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { MagicLinkService } from './magic-link.service';
import { CreateMagicLinkDto } from './dto/create-magic-link.dto';
import { ApiBody, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
import {
ApiBody,
ApiOperation,
ApiQuery,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { invite_links as MagicLink } from '@prisma/client';
@ApiTags('magic-link')
@Controller('magic-link')
Expand All @@ -14,19 +20,22 @@ export class MagicLinkController {
this.logger.setContext(MagicLinkController.name);
}

@ApiOperation({ operationId: 'createMagicLink' })
@ApiBody({ type: CreateMagicLinkDto })
@ApiResponse({ status: 201 })
@Post('create')
createLink(@Body() data: CreateMagicLinkDto) {
return this.magicLinkService.createUniqueLink(data);
}

@ApiOperation({ operationId: 'getMagicLinks' })
@ApiResponse({ status: 200 })
@Get()
getMagicLinks() {
return this.magicLinkService.getMagicLinks();
}

@ApiOperation({ operationId: 'getMagicLink' })
@ApiQuery({ name: 'id', required: true, type: String })
@ApiResponse({ status: 200 })
@Get('single')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Body, Controller, Get, Post } from '@nestjs/common';
import { OrganisationsService } from './organisations.service';
import { LoggerService } from '../logger/logger.service';
import { CreateOrganizationDto } from './dto/create-organization.dto';
import { ApiBody, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';

@ApiTags('organisations')
@Controller('organisations')
Expand All @@ -14,11 +14,13 @@ export class OrganisationsController {
this.logger.setContext(OrganisationsController.name);
}

@ApiOperation({ operationId: 'getOrganisations' })
@Get()
getOragnisations() {
return this.organizationsService.getOrganisations();
}

@ApiOperation({ operationId: 'createOrganisation' })
@ApiBody({ type: CreateOrganizationDto })
@ApiResponse({ status: 201 })
@Post('create')
Expand Down
9 changes: 8 additions & 1 deletion packages/api/src/@core/passthrough/passthrough.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { PassThroughRequestDto } from './dto/passthrough.dto';
import { PassThroughResponse } from './types';
import { PassthroughService } from './passthrough.service';
import { LoggerService } from '@@core/logger/logger.service';
import { ApiBody, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
import {
ApiBody,
ApiOperation,
ApiQuery,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';

@ApiTags('passthrough')
@Controller('passthrough')
Expand All @@ -15,6 +21,7 @@ export class PassthroughController {
this.loggerSeervice.setContext(PassthroughController.name);
}

@ApiOperation({ operationId: 'passthroughRequest' })
@ApiQuery({ name: 'integrationId', required: true, type: String })
@ApiQuery({ name: 'linkedUserId', required: true, type: String })
@ApiBody({ type: PassThroughRequestDto })
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/@core/projects/projects.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Body, Controller, Get, Post } from '@nestjs/common';
import { ProjectsService } from './projects.service';
import { LoggerService } from '../logger/logger.service';
import { CreateProjectDto } from './dto/create-project.dto';
import { ApiBody, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';

@ApiTags('projects')
@Controller('projects')
Expand All @@ -14,12 +14,14 @@ export class ProjectsController {
this.logger.setContext(ProjectsController.name);
}

@ApiOperation({ operationId: 'getProjects' })
@ApiResponse({ status: 200 })
@Get()
getProjects() {
return this.projectsService.getProjects();
}

@ApiOperation({ operationId: 'createProject' })
@ApiBody({ type: CreateProjectDto })
@ApiResponse({ status: 201 })
@Post('create')
Expand Down
5 changes: 4 additions & 1 deletion packages/api/src/@core/webhook/webhook.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Body, Controller, Get, Post, Put, Param } from '@nestjs/common';
import { LoggerService } from '@@core/logger/logger.service';
import { ApiBody, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBody, ApiResponse, ApiTags, ApiOperation } from '@nestjs/swagger';
import { WebhookService } from './webhook.service';
import { WebhookDto } from './dto/webhook.dto';

Expand All @@ -14,12 +14,14 @@ export class WebhookController {
this.loggerSeervice.setContext(WebhookController.name);
}

@ApiOperation({ operationId: 'getWebhooksMetadata' })
@ApiResponse({ status: 200 })
@Get()
getWebhooks() {
return this.webhookService.getWebhookEndpoints();
}

@ApiOperation({ operationId: 'updateWebhookStatus' })
@Put(':id')
async updateWebhookStatus(
@Param('id') id: string,
Expand All @@ -28,6 +30,7 @@ export class WebhookController {
return this.webhookService.updateStatusWebhookEndpoint(id, active);
}

@ApiOperation({ operationId: 'createWebhookMetadata' })
@ApiBody({ type: WebhookDto })
@ApiResponse({ status: 201 })
@Post()
Expand Down
13 changes: 12 additions & 1 deletion packages/api/src/crm/contact/contact.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import {
import { ContactService } from './services/contact.service';
import { LoggerService } from '@@core/logger/logger.service';
import { UnifiedContactInput } from './types/model.unified';
import { ApiBody, ApiParam, ApiQuery, ApiTags } from '@nestjs/swagger';
import {
ApiBody,
ApiOperation,
ApiParam,
ApiQuery,
ApiTags,
} from '@nestjs/swagger';
import { ContactResponse, ApiCustomResponse } from './types';
@ApiTags('crm/contact')
@Controller('crm/contact')
Expand All @@ -22,6 +28,7 @@ export class ContactController {
this.logger.setContext(ContactController.name);
}

@ApiOperation({ operationId: 'getContacts' })
@ApiQuery({ name: 'integrationId', required: true, type: String })
@ApiQuery({ name: 'linkedUserId', required: true, type: String })
@ApiQuery({ name: 'remote_data', required: false, type: Boolean })
Expand All @@ -39,6 +46,7 @@ export class ContactController {
);
}

@ApiOperation({ operationId: 'getContact' })
@ApiParam({ name: 'id', required: true, type: String })
@ApiQuery({ name: 'remote_data', required: false, type: Boolean })
@ApiCustomResponse(ContactResponse)
Expand All @@ -50,6 +58,7 @@ export class ContactController {
return this.contactService.getContact(id, remote_data);
}

@ApiOperation({ operationId: 'addContact' })
@ApiQuery({ name: 'integrationId', required: true, type: String })
@ApiQuery({ name: 'linkedUserId', required: true, type: String })
@ApiQuery({ name: 'remote_data', required: false, type: Boolean })
Expand All @@ -70,6 +79,7 @@ export class ContactController {
);
}

@ApiOperation({ operationId: 'addContacts' })
@ApiQuery({ name: 'integrationId', required: true, type: String })
@ApiQuery({ name: 'linkedUserId', required: true, type: String })
@ApiQuery({ name: 'remote_data', required: false, type: Boolean })
Expand All @@ -90,6 +100,7 @@ export class ContactController {
);
}

@ApiOperation({ operationId: 'updateContact' })
@Patch()
updateContact(
@Query('id') id: string,
Expand Down
Loading

0 comments on commit da49ca1

Please sign in to comment.