-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Generated c# client methods return voids #3996
Comments
Could be related to #3912 |
@fairking yes I think this is related. This happens because your swagger json doesn't define the content for the response types, it only seems to have examples (there should be a content property under the 200) e.g: "responses": {
"200": {
"description": "OK",
"examples": {
"application/json": {
"schema": {
"example": {
"Message": "Callback URL cleared."
},
"type": "string"
}
},
"application/xml": "<GeneralAcknowledgement\n xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n <Message>Callback URL cleared.</Message>\n</GeneralAcknowledgement>"
}
}
}, See spec for more info https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responses-object-example |
@crackalak Thank you for the response. So the issue is related to the missing api docs. Closing the issue. |
The OpenAPI specs do not require a content definition. And even if it did, NSwag should not generate invalid C# code. This issue should be reopened. |
agreed. There is no excuse for returning the broken code. If it comes down to errors in the specification (which is not the case according to @tmatous in this particular scenario), then the nswag should at least show some warnings or even an error during the code generation process.. Just stumbled upon the same issue.. |
I understand there could be an issue with api docs, or with nswag, but can we at least explain users what is wrong? Currently people spend hours to understand what is going on. Or show some warning or error, or fix the way how the code is being generated. |
NSwag v13.15.10.0 (NJsonSchema v10.6.10.0 (Newtonsoft.Json v11.0.0.0))
Windows 10
.Net6
Visual Studio 2022 Preview 6.0
I was trying to do that via VS (Add Service Reference -> OpenAPI) but it wasn't working. So I simply run the command bellow in powershell (
C:\Users\Admin\.nuget\packages\nswag.msbuild\13.15.10\tools\Win\NSwag.exe
).The command:
The swagger scheme: https://eazycollectservices.github.io/EazyCollectAPIv3/swagger.json
The above example generates not compilable client code:
The text was updated successfully, but these errors were encountered: