Replies: 1 comment 4 replies
-
Feel free to update the templates to your liking: https://github.com/RicoSuter/NSwag/tree/master/src/NSwag.CodeGeneration.TypeScript/Templates |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When I generate a TS client of our API using NSwag, the resulting code seems wildly overcomplicated. Is our NSwag or API misconfigured?
Generated code for a single HTTP POST (excluding generated DTOs, which are fine)
Note that the generated options are seemingly wrong and to facilitate that they're cast to
any
.Content-Type
andAccept
header values should not be changed from the defaults.responseType
shouldn't be 'blob' but 'json' (the default).What I expected it to generate (excluding generated DTOs, which are fine)
Have I done something wrong in my configuration? Can I configure NSwag to generate less convoluted code?
I figured that at least something that goes wrong has to do with the error handling. We added
exceptionClass: "ApiException"
to the nswag configuration. However apparently it constructs its own class for exception handling and names it ApiException. We addedApiException
because theApiException
class defined in the swagger.json is always the type of the body data that our API returns if a request is not successful (not 200 or 204).Beta Was this translation helpful? Give feedback.
All reactions