Skip to content
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

Support for property name amendment #336

Closed
moltar opened this issue Apr 23, 2019 · 7 comments
Closed

Support for property name amendment #336

moltar opened this issue Apr 23, 2019 · 7 comments

Comments

@moltar
Copy link

moltar commented Apr 23, 2019

It'd be great to be able to filter the property names and rename them too.

Our API returns snake_case property names, but JS/TS world is mostly operating in camelCase.

I'd like to be able to convert these before output.

Thanks.

@horiuchi
Copy link
Owner

@moltar Thank you for using this!

That can convert type name to use the dtsgenerator as a library.
https://github.com/horiuchi/dtsgenerator#usage-for-library

@moltar
Copy link
Author

moltar commented Apr 23, 2019

Thank you for replying so quickly!

I saw that type renames are possible via library.

But my use case is to rename the property names, not types.

E.g.

Interface foo {
some_prop: string
}

To

Interface foo {
someProp: string
}

Sent with GitHawk

@horiuchi
Copy link
Owner

Oh sorry, I'm mistaken.

But in a normal case, we use it for converting the API response or request definition to TypeScript definition.
If it changes the property name, the TypeScript definition may not fit together API's JSON.

Do you want it in any situation?

@moltar
Copy link
Author

moltar commented Apr 26, 2019

It is not a problem that it will not match, because I will convert the responses too to match camelCase.

@adriengibrat
Copy link

Did you consider to align naming convention between API producer & consumer?
It would be a great move, IMHO ;)

@amoshydra
Copy link

Off-topic:

Did you consider to align naming convention between API producer & consumer?
It would be a great move, IMHO ;)

I am curious how is this usually done, especially when API producer and consumer are written in different languages that following different casing convention. Do you still try to set a casing convention between API producer and consumer?


In our situation producer (our API server) is written in ruby (which uses snake_case), whereas consumer uses JS/TS (camelCase). Trying to use a foreign casing will often trigger our linter.

Most of our consumer will do a snake_case --> camelCase in the response, and camelCase --> snake_case in the request.

@horiuchi
Copy link
Owner

It is now possible to convert property names using the plugin's post process.
Please consider it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants