Open GauravQ opened 3 years ago
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
@GauravQ we are facing the same problem. Did you find an (automated) workaround for this? Maybe some mustache template?
@GauravQ can you please submit a PR with the suggested change and we'll review accordingly?
@wing328 Sure, I'll try to spend some time on it. Maybe this weekend.
@GauravQ @pkunze : Did you find any workaround for this?
For info, we have a fix for that for the csharp-netcore variant, we're going to submit a PR in the coming weeks.
[Post] Action methods as default conversion from Post Body (JSON) to Class Object requires a parameter less constructor (a default constructor).
The issue here is not clear to me. It sounds like there is JSON that is not deserializing.
@devhl-labs The functionality like TypeAdapter.Adapt that allows you to easily cast one identical model object to another identical model object requires a default constructor, which is currently only created if you specify one or more of the model properties as required (which seems like strange behavior but I don't understand all the in and outs). Was there any progress on adding a default constructor or providing an option to?
EDIT the problem actually turned out to be (in my case) how the generator generated code differently for property named 'SOME_THING' and 'some_thing'. So would not be fixed by a parameterless constructor.
I've been using openapi-generator-cli for generating APIClient Nugets to be used in .Net Framework, .Net Core Web Apps.
But I'm not able to use generated models as parameter in a [Post] Action methods as default conversion from Post Body (JSON) to Class Object requires a parameter less constructor (a default constructor). But the generated models only have a parameterized constructor, which then results in an error.
Probable solution
Adding a default constructor in all Model classes will be very helpful.
As of now the only solution is to create similar Model classes in Web App itself and when calling an API convert that Web App's Model To APIClient's Model (generated model).
Here's how its being generated using v4.3.1
And here's how it could be generated to resolve the issue. having a default constructor with another parameterized constructor
Not sure how much work is needed here, but i would really appreciate if we can have this added.