(endpoint: IRouteDocumentation)
| 247 | }; |
| 248 | |
| 249 | const toEndpointResponse = (endpoint: IRouteDocumentation) => { |
| 250 | const response: any = {}; |
| 251 | |
| 252 | if (ALLOWED_2XX_HANDLERS.includes(endpoint.handler)) { |
| 253 | response["200"] = { |
| 254 | ...to2XXResponse(endpoint), |
| 255 | description: "OK", |
| 256 | }; |
| 257 | } |
| 258 | |
| 259 | if (endpoint.handler === HandlerTypes.INSERT) { |
| 260 | response["201"] = { |
| 261 | ...to2XXResponse(endpoint), |
| 262 | description: "Created", |
| 263 | }; |
| 264 | response["400"] = { |
| 265 | description: "Bad request", |
| 266 | content: { |
| 267 | "application/json": { |
| 268 | schema: { |
| 269 | $ref: `#/components/schemas/ValidationError`, |
| 270 | }, |
| 271 | }, |
| 272 | }, |
| 273 | }; |
| 274 | } |
| 275 | |
| 276 | if (NO_CONTENT_HANDLERS.includes(endpoint.handler)) { |
| 277 | response["204"] = { |
| 278 | description: "No Content", |
| 279 | }; |
| 280 | } |
| 281 | |
| 282 | if ( |
| 283 | POSSIBLE_404_HANDLERS.includes(endpoint.handler) || |
| 284 | endpoint.parentModel |
| 285 | ) { |
| 286 | response["404"] = { |
| 287 | description: "Not Found", |
| 288 | content: { |
| 289 | "application/json": { |
| 290 | schema: { |
| 291 | $ref: `#/components/schemas/Error`, |
| 292 | }, |
| 293 | }, |
| 294 | }, |
| 295 | }; |
| 296 | } |
| 297 | |
| 298 | return response; |
| 299 | }; |
| 300 | |
| 301 | const toFillableFieldProperties = (model: IModelService) => { |
| 302 | const fields = model.instance.getFillableFields(HttpMethods.POST); |
no test coverage detected