|
| 1 | +import type { ApiResponseOptions } from '@nestjs/swagger'; |
| 2 | + |
| 3 | +export const CREATE_VENDOR_RESPONSES: Record<number, ApiResponseOptions> = { |
| 4 | + 201: { |
| 5 | + status: 201, |
| 6 | + description: 'Vendor created successfully', |
| 7 | + schema: { |
| 8 | + type: 'object', |
| 9 | + properties: { |
| 10 | + id: { |
| 11 | + type: 'string', |
| 12 | + description: 'Vendor ID', |
| 13 | + example: 'vnd_abc123def456', |
| 14 | + }, |
| 15 | + name: { |
| 16 | + type: 'string', |
| 17 | + description: 'Vendor name', |
| 18 | + example: 'CloudTech Solutions Inc.', |
| 19 | + }, |
| 20 | + description: { |
| 21 | + type: 'string', |
| 22 | + description: 'Vendor description', |
| 23 | + example: 'Cloud infrastructure provider offering AWS-like services including compute, storage, and networking solutions for enterprise customers.', |
| 24 | + }, |
| 25 | + category: { |
| 26 | + type: 'string', |
| 27 | + enum: ['cloud', 'infrastructure', 'software_as_a_service', 'finance', 'marketing', 'sales', 'hr', 'other'], |
| 28 | + example: 'cloud', |
| 29 | + }, |
| 30 | + status: { |
| 31 | + type: 'string', |
| 32 | + enum: ['not_assessed', 'in_progress', 'assessed'], |
| 33 | + example: 'not_assessed', |
| 34 | + }, |
| 35 | + inherentProbability: { |
| 36 | + type: 'string', |
| 37 | + enum: ['very_unlikely', 'unlikely', 'possible', 'likely', 'very_likely'], |
| 38 | + example: 'possible', |
| 39 | + }, |
| 40 | + inherentImpact: { |
| 41 | + type: 'string', |
| 42 | + enum: ['insignificant', 'minor', 'moderate', 'major', 'severe'], |
| 43 | + example: 'moderate', |
| 44 | + }, |
| 45 | + residualProbability: { |
| 46 | + type: 'string', |
| 47 | + enum: ['very_unlikely', 'unlikely', 'possible', 'likely', 'very_likely'], |
| 48 | + example: 'unlikely', |
| 49 | + }, |
| 50 | + residualImpact: { |
| 51 | + type: 'string', |
| 52 | + enum: ['insignificant', 'minor', 'moderate', 'major', 'severe'], |
| 53 | + example: 'minor', |
| 54 | + }, |
| 55 | + website: { |
| 56 | + type: 'string', |
| 57 | + nullable: true, |
| 58 | + example: 'https://www.cloudtechsolutions.com', |
| 59 | + }, |
| 60 | + organizationId: { |
| 61 | + type: 'string', |
| 62 | + example: 'org_abc123def456', |
| 63 | + }, |
| 64 | + assigneeId: { |
| 65 | + type: 'string', |
| 66 | + nullable: true, |
| 67 | + description: 'ID of the user assigned to manage this vendor', |
| 68 | + example: 'mem_abc123def456', |
| 69 | + }, |
| 70 | + createdAt: { |
| 71 | + type: 'string', |
| 72 | + format: 'date-time', |
| 73 | + description: 'When the vendor was created', |
| 74 | + }, |
| 75 | + updatedAt: { |
| 76 | + type: 'string', |
| 77 | + format: 'date-time', |
| 78 | + description: 'When the vendor was last updated', |
| 79 | + }, |
| 80 | + authType: { |
| 81 | + type: 'string', |
| 82 | + enum: ['api-key', 'session'], |
| 83 | + description: 'How the request was authenticated', |
| 84 | + }, |
| 85 | + authenticatedUser: { |
| 86 | + type: 'object', |
| 87 | + description: 'User information (only for session auth)', |
| 88 | + properties: { |
| 89 | + id: { type: 'string', example: 'usr_def456ghi789' }, |
| 90 | + email: { type: 'string', example: 'user@example.com' }, |
| 91 | + }, |
| 92 | + }, |
| 93 | + }, |
| 94 | + }, |
| 95 | + }, |
| 96 | + 400: { |
| 97 | + status: 400, |
| 98 | + description: 'Bad request - Invalid input data', |
| 99 | + schema: { |
| 100 | + type: 'object', |
| 101 | + properties: { |
| 102 | + message: { |
| 103 | + type: 'array', |
| 104 | + items: { type: 'string' }, |
| 105 | + example: [ |
| 106 | + 'name should not be empty', |
| 107 | + 'description should not be empty', |
| 108 | + 'category must be a valid enum value', |
| 109 | + 'website must be a URL address', |
| 110 | + ], |
| 111 | + }, |
| 112 | + error: { type: 'string', example: 'Bad Request' }, |
| 113 | + statusCode: { type: 'number', example: 400 }, |
| 114 | + }, |
| 115 | + }, |
| 116 | + }, |
| 117 | + 401: { |
| 118 | + status: 401, |
| 119 | + description: 'Unauthorized - Invalid authentication or insufficient permissions', |
| 120 | + schema: { |
| 121 | + type: 'object', |
| 122 | + properties: { |
| 123 | + message: { |
| 124 | + type: 'string', |
| 125 | + examples: [ |
| 126 | + 'Invalid or expired API key', |
| 127 | + 'Invalid or expired session', |
| 128 | + 'User does not have access to organization', |
| 129 | + 'Organization context required', |
| 130 | + ], |
| 131 | + }, |
| 132 | + }, |
| 133 | + }, |
| 134 | + }, |
| 135 | + 404: { |
| 136 | + status: 404, |
| 137 | + description: 'Organization not found', |
| 138 | + schema: { |
| 139 | + type: 'object', |
| 140 | + properties: { |
| 141 | + message: { |
| 142 | + type: 'string', |
| 143 | + example: 'Organization with ID org_abc123def456 not found', |
| 144 | + }, |
| 145 | + }, |
| 146 | + }, |
| 147 | + }, |
| 148 | + 500: { |
| 149 | + status: 500, |
| 150 | + description: 'Internal server error', |
| 151 | + schema: { |
| 152 | + type: 'object', |
| 153 | + properties: { |
| 154 | + message: { |
| 155 | + type: 'string', |
| 156 | + example: 'Internal server error', |
| 157 | + }, |
| 158 | + }, |
| 159 | + }, |
| 160 | + }, |
| 161 | +}; |
0 commit comments