Commit bd93a63
committed
fix: conditionally import param and requestBody in controller template
The OpenAPI controller template unconditionally imported `param` and
`requestBody` decorators from `@loopback/rest`, even when the
generated controller did not use any parameters or request bodies.
This caused ESLint errors with `no-unused-imports` rule and was
confusing for developers reading the generated code.
Changes:
- Track whether `@param` and `@requestBody` decorators are used
in controller methods
- Conditionally import these decorators in the template only when needed
Fixes #33351 parent d1838ad commit bd93a63
2 files changed
Lines changed: 8 additions & 1 deletion
File tree
- packages/cli/generators/openapi
- templates/src/controllers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
458 | 465 | | |
459 | 466 | | |
460 | 467 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
0 commit comments