openapi-react-query-codegen
openapi-react-query-codegen copied to clipboard
A missing `prettier` formatter is silently ignored
Describe the bug
Generated files under "requests" have tabs instead of spaces although prettier is configured otherwise.
To Reproduce
I have a .prettierrc with
{
"useTabs": false
}
and run openapi-rq -i http://localhost:8080/swagger-ui/api.json -o src/api --format prettier.
The generated *.ts files have tabs instead of spaces.
OpenAPI spec file
n/a
Expected behavior
Spaces instead of tabs should be used according to the prettier configuration.
Additional context
- OS: Fedora Linux 40
- Version 1.3.0
Ok, seems like the problem simply was that prettier was not installed. Manually installing it and rerunning openapi-rq fixes the problem.
Would it be possible to either:
- install
prettierautomatically if configured as a formatter but not present yet on the system, or - warn / error out if
prettieris configured but not present?
Same for Biome, I guess.
This you for opening an issue.
This library passes the values provided to @hey-api/openapi-ts to run the formatting.
It would/could become a maintenance burden to add the checks in this library, opening a ticket in @hey-api/openapi-ts package may be helpful.
I personal do not believe a cli command should install a package automatically.
A console warning would be good.
I am starting to believe we should remove the options for consumers to interface with the format and linter options as this library's generated code will be covered. And change in the underlying service generators formatted would have to maintained in this libraries. Feels hard to maintain. Would be consistent for the consumer to run their own linter and formatted after generating the files.
I am starting to believe we should remove the options for consumers to interface with the format and linter options as this library's generated code will be covered. And change in the underlying service generators formatted would have to maintained in this libraries. Feels hard to maintain. Would be consistent for the consumer to run their own linter and formatted after generating the files.
I completely agree with you. I think it will also be challenging to keep up with future changes in both Prettier and Biome.
I completely agree with you.
For the record, I agree as well, and we have already switched from using the --format to running prettier as a post-processing step.
So, given that I believe no work is planned to address this as instead the --format option is going to be removed, let me close this.