-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add ability to render Typescript template in Pascal Case #813
Comments
This would only be for generated models. I would expect method names to follow normal camel case conventions |
Can you provide some samples |
Here's a basic example of a generated swagger doc.
|
Ok... If you use the gen in c# you can provide a custom PropertxNameGenerator so that the names are upper camel case... |
Do you mean generate a c# client first and then convert that to typescript? The swagger doc is correct. The properties created from NSwag are cased incorrectly for my case |
You have to write your own cmd line tool and use the nswag libraries. This way you can customize the names. This is currently not possible via nswag.exe or nswagstudio.. |
Hi @cwoolum , did you solve your problem? |
A custom generator cannot be used in nswagstudio or cli, you need to write your own cmd app |
Related: #924 |
I spent the majority of my morning today trying to make this happen... digging around trying to figure out how NSwag was working... realizing it was calling over to @RSuter 's other project https://github.com/RSuter/NJsonSchema to generate the actual DTO classes... and I couldn't figure out if the resolvers over there could take an option for property formatting.... and then I gave up and resigned to the fact that I must use camelCase property names FYI for anyone reading this... https://github.com/OpenAPITools/openapi-generator gives you the options to control property name generation: camelCase, PascalCase, or original (what's in the spec).... but that project is a whole other animal (I like that NSwag generates a single file) |
For c# and ts generation, a custom property name generator is the way to go: If you want to change the casing in the serialized properties/the spec, you need to provide a custom SerializerSettings with a “special” contract resolver |
I'm not seeing any field or anything in the documentation about how to use/implement a custom property name generator. Can you elaborate a bit more? (I'm also not seeing an option in NSwagStudio for this) I'm REALLY just looking for the casing on my properties to match the casing of my C# properties 1:1, as this would make it a lot easier to jump around between code files AND would let me eliminate all of the transformation code from my generated code. (which would in turn let me reduce the size of the generated file by a lot) |
I am currently trying to use NSWAG to generate clients for a legacy API I am working with. The problem is that there are a bunch of existing clients who already work with these services so I cannot change the serialization. Additionally, we have some OData API's that our users consume outside of swagger so the users would expect the casing to be the same as our standard API's. Is it possible to render the client using the formatting that the API outputs?
The text was updated successfully, but these errors were encountered: