swagger-codegen
swagger-codegen copied to clipboard
[C#] Use fully-qualified name for models
Similar to Task (System.Threading.Tasks.Task) a year ago and then Stream (System.IO.Stream), we want to use fully-qualified name for models.
Related discussion: #2589
If anyone wants to work on this, please reply to let us know.
@wing328 I seem to recall you had started work on this? Am I remembering incorrectly? If you had any work in progress, would you mind sharing it?
I think this issue could easily be fixed by an option that appends the full model namespace to client generated models. This way users who don't like fully qualified names throughout code and have no issue with collisions can continue generating as normal.
@jimschubert yes it's on my plate. I was able to update model with fully-qualified names but one remaining issue I found was that the documentation looks very ugly using fully-qualified name. I'll probably go with your suggestion to use a CLI option (similar to fullJavaUtil
)
I recently started using fully qualified definitions in my spec file because of some DTOs that shared class names (in different namespaces). So the definitions
section of my spec file has property named ClientPortal.Api.Model.PunchReport.Contract.SchedulePunchesRow
(was simply SchedulePunchesRow
before).
This has resulted in a class once called SchedulePunchesRow
to be named ClientPortalApiModelPunchReportContractSchedulePunchesRow
. I tried using --import-mappings
to effectively "bring my own model", and while the Model class no longer gets generated, the Api classes where it's used, still reference it a whole word (without the periods).
Is this task meant to resolve that or something similar? Is there another way around the problem I'm having? TIA!
@langdonx you could try the --model-name-prefix
: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java#L69
I don't recall exactly, but I think this doesn't do sanitization on the provided prefix.
I'm having this issue with C# code generayed from Amazon SP API models. Can this be addressed? --import-mappings did not help.