You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using this approach the DTOs are not generated, since the existing C# DTOs can be used by the front end and back end, and referenced by the generated C# clients. The only problem is that the DTOs will typically be contained within numerous namespaces. If I manually set the namespace usages then everything works well. However, it would be much easier if I could do it dynamically.
An example solution would be to scan the Shared project, collect all namespaces for the contained types, and then dynamically add those namespace usages to the generated C# client.
I am happy to modify the template;
src/NSwag.CodeGeneration.CSharp/Templates/File.liquid
But I am not sure if there is some extension point to provide the dynamic namespace usages.
Please let me know if anything is unclear. Appreciate any suggestions.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello! I would like to figure out an approach to have dynamic namespaces (possibly based on reflection) for C# client generation.
I am currently using NSwag with Blazon WebAssembly. I use the following approach; https://jasontaylor.dev/implement-openapi-support-for-blazor-webassembly/.
Using this approach the DTOs are not generated, since the existing C# DTOs can be used by the front end and back end, and referenced by the generated C# clients. The only problem is that the DTOs will typically be contained within numerous namespaces. If I manually set the namespace usages then everything works well. However, it would be much easier if I could do it dynamically.
An example solution would be to scan the Shared project, collect all namespaces for the contained types, and then dynamically add those namespace usages to the generated C# client.
I am happy to modify the template;
src/NSwag.CodeGeneration.CSharp/Templates/File.liquid
But I am not sure if there is some extension point to provide the dynamic namespace usages.
Please let me know if anything is unclear. Appreciate any suggestions.
Beta Was this translation helpful? Give feedback.
All reactions