Open Evangelinexx opened 4 years ago
+1
This is one of many weird limitations I've seen with NSwag's failure to implement properties set by the OpenAPI specification. Others include responding with appropriate status codes, verifying required properties correctly, and differentiating between the source of an input (e.g. path, header, body).
Anyone know of any client generation tools that support the scenario of multiple content types for the request body?
I have a dotnetcore 3.1 project running which generates MVC controllers based on my documentation.
I also have a request which consumes both
application/json
andapplication/x-www-form-urlencoded
.This is my swagger:
Here is the code I needed it to generate:
In the meantime I have solved it by customising my liquid template, however it would be good to have this solved in general. The nswag generator needs to loop through each content type that the request accepts and generate a new method for each of them.
Worth noting that in my case both methods call the same implementation as they both use the same model, but one pulls it from the body, and the other pulls it from the form. The proper implementation would have a different method for both, as there is no guarantee that the schema will be the same for these.