C# Client Generation - Dynamic Namespace Usages #4157
Unanswered
jasontaylordev
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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