Skip to content

Feature Request: Specify formatting options such as singleQuote without prettierConfig #959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kazuma0129 opened this issue Oct 28, 2022 · 2 comments
Labels
enhancement New feature or request PRs welcome PRs are welcome to solve this issue!

Comments

@kazuma0129
Copy link

I use this library all the time. Thank you very much.

I would like to be able to specify singleQuote, etc. directly to SwaggerToTSOptions.

Currently, SwaggerToTSOptions has a prettierConfig, which can specify the path to the prettier configuration file.
However, I recently switched formatters from prettier to rome and removed prettierrc(as prettierConfig) from the project.
As a result, I can no longer specify singleQuote, etc. in prettierrc when generating type files with openapi-typescript.

I would like to get your opinion on this, as I am sure there are many people like me who have switched from prettier to rome.
On the other hand, I would like to know if there is a work-around for this kind of singleQuote generation in the current functionality.

Best regards!

@drwpow drwpow added enhancement New feature or request PRs welcome PRs are welcome to solve this issue! labels Oct 30, 2022
@drwpow
Copy link
Contributor

drwpow commented Oct 30, 2022

Well, I have bad news for you—openapiTS does ship Prettier as one of its dependencies, so as of now, you’ll still have to use the prettierrc config file to customize the formatting.

I can see 2 possible additions that would be welcome to this library, but I’d need someone to open the PR:

  1. Allow prettier options in the Node.js API: this is the simplest solution. I’m not opposed to this. But only reason it wasn’t added initially was because Prettier still relies on filesystem config files for a lot of options and plugin loading, and so this felt like a mini-rabbit hole that would be a little bit of work.
  2. Allow the formatter to be swappable. Rome is pretty cool! I’ve experimented with it, and I’m not quite ready to switch projects over to it but I’d love to when it’s more stable. But there may be a way to make openAPI’s formatter more pluggable/swappable, which would also necessitate more inline config options as a default.

Last thought: I’ve always tried to keep this library as lightweight and dependency-free as possible, but a formatter just seemed like a required part because code generation almost always needs formatting, and Prettier is still (love it or hate it) the most widely-used option. But I’m not married to anything, so long as people can customize their output however they want.

@drwpow
Copy link
Contributor

drwpow commented Nov 4, 2022

So update: unless this changes before the v6 release, this library won’t ship any formatter at all! So feature granted…kinda? Overall you raised some good points—formatting is outside the concern for this library, and should be managed by the user. Which will also be good news that this no longer ships Prettier, so that won’t be in projects that aren’t using it anyway.

@drwpow drwpow closed this as completed Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PRs welcome PRs are welcome to solve this issue!
Projects
None yet
Development

No branches or pull requests

2 participants