HavenDV / H.NSwag.Generator

C# Source Generator for NSwag.
MIT License
20 stars 3 forks source link

Custom hook in the `GenerateAsync` #4

Closed trejjam closed 1 year ago

trejjam commented 1 year ago

Hello @HavenDV I am trying to use your source generator to generate c# client for this openapi document in this project. The issue is that there are some incompatibilities, like "enum": ["V1", "v1"] which is then translated to c# as enum { V1, V1 }. I would like to hook into the process here with a custom code (in my project). But I have no idea what will be the best way how to design that hook mechanism. Would you happen to have any recommendations? Are you open to a PR to support such a hook?

Thank you, Jan

HavenDV commented 1 year ago

Hi Jan, Since the code is executed at the IDE level, I don't see an easy way to do this. First, I would try to look if it is possible to bypass this somehow with the NSwag settings If it doesn't work and it's a bug in NSwag, then in my experience, the process of accepting a PR and releasing a new version is very long for them. So in that case, the best option is to send a PR to them, and send a PR to me to fix a specific problem in the generator until they accept the fix in the original library. But it's quite time consuming I think.

trejjam commented 1 year ago

I am aware of in which context is source-generator executed :/ I am afraid that the issue I am having is not really an issue of NSwag but the particular OpenAPI document. I will try to solve it with a workaround. Thank you for your ideas

trejjam commented 1 year ago

Finally, I managed it using another source generator that transposes source openapi document.