( endpoint: IRouteDocumentation, modelService: IModelService, )
| 335 | }; |
| 336 | |
| 337 | const toRequestParameters = ( |
| 338 | endpoint: IRouteDocumentation, |
| 339 | modelService: IModelService, |
| 340 | ) => { |
| 341 | const parameters: any = [ |
| 342 | { |
| 343 | in: "header", |
| 344 | name: "Accept-Language", |
| 345 | schema: { |
| 346 | type: "string", |
| 347 | example: "en;q=0.8, de;q=0.7, *;q=0.5", |
| 348 | }, |
| 349 | required: false, |
| 350 | }, |
| 351 | ]; |
| 352 | |
| 353 | if (endpoint.url.includes(":")) { |
| 354 | const sections = endpoint.url |
| 355 | .split("/") |
| 356 | .filter((item) => item.includes(":")) |
| 357 | .map((item) => item.replace(":", "")); |
| 358 | |
| 359 | for (const section of sections) { |
| 360 | parameters.push({ |
| 361 | in: "path", |
| 362 | name: section, |
| 363 | required: true, |
| 364 | }); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | if (endpoint.handler === HandlerTypes.PAGINATE) { |
| 369 | parameters.push( |
| 370 | ...[ |
| 371 | { |
| 372 | name: "page", |
| 373 | in: "query", |
| 374 | description: "The page number to list", |
| 375 | required: false, |
| 376 | schema: { |
| 377 | type: "integer", |
| 378 | default: 1, |
| 379 | }, |
| 380 | }, |
| 381 | { |
| 382 | name: "per_page", |
| 383 | in: "query", |
| 384 | description: "Number of records to list on a page", |
| 385 | required: false, |
| 386 | schema: { |
| 387 | type: "integer", |
| 388 | default: 10, |
| 389 | }, |
| 390 | }, |
| 391 | { |
| 392 | name: "sort", |
| 393 | in: "query", |
| 394 | description: "The field to sort the data (ASC: id, DESC: -id)", |
no test coverage detected