Skip to content

[Request]Add prefix or suffix generated types #191

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
the-ult opened this issue Mar 3, 2021 · 6 comments · Fixed by #196
Closed

[Request]Add prefix or suffix generated types #191

the-ult opened this issue Mar 3, 2021 · 6 comments · Fixed by #196
Assignees
Labels
enhancement New feature or request next release

Comments

@the-ult
Copy link

the-ult commented Mar 3, 2021

Would it be possible to add an option to add a prefix or suffix to the generated types to prevent errors like:

import { Person } from './models/swagger-api.__generated__';
/// => Import declaration conflicts with local declaration of Person

E.g.:
npx swagger-typescript-api ... --suffix=model

Person => PersonModel

For example:
We are trying to use the generated types/interfaces with graphql-codegen, but the naming of the generated types conflict with the already existing (generated) graphql types.

@js2me
Copy link
Member

js2me commented Mar 3, 2021

Yeah, it's would be a good idea to add --type-prefix, --type-suffix as CLI options
I'll start working on this feature request.
Thanks for issue!

@js2me js2me added enhancement New feature or request next release labels Mar 3, 2021
@js2me js2me self-assigned this Mar 3, 2021
js2me added a commit that referenced this issue Mar 4, 2021
@js2me js2me mentioned this issue Mar 4, 2021
@js2me js2me linked a pull request Mar 4, 2021 that will close this issue
@the-ult
Copy link
Author

the-ult commented Mar 4, 2021

Thanks @js2me awesome work!

👍

@js2me js2me closed this as completed in #196 Mar 4, 2021
js2me added a commit that referenced this issue Mar 4, 2021
* feat: --type-suffix, --type-prefix options (issue #191, thanks @the-ult); feat: onFormatTypeName hook

* bump: up version to 6.3.0
@js2me
Copy link
Member

js2me commented Mar 4, 2021

@the-ult --type-prefix, --type-suffix options has been added in 6.3.0 version!
Thank you for a good feature request!

@paztis
Copy link

paztis commented Feb 2, 2022

My classic usage is to prefix all the interfaces with I, all the types with T and all the enums with E.
Here we've got a unique prefix for this.
Is it possible to enhance typePrefix a bit to support it ?

@Bargamut
Copy link

Bargamut commented Sep 13, 2022

My classic usage is to prefix all the interfaces with I, all the types with T and all the enums with E.
Here we've got a unique prefix for this.
Is it possible to enhance typePrefix a bit to support it ?

+1
Seems like it easy to add something like --type-meta-prefix for that. Just add new PR with tests. It may be interesting to make it. )

But it must compatible with prefixes options above.

@VladimirCores
Copy link

How could I restrict adding suffix only to interfaces and not enums?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants