RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.76k stars 1.29k forks source link

NSwag deserialization Error #3490

Open MikeGHUK opened 3 years ago

MikeGHUK commented 3 years ago

Using NSwag.ApiDescription.Client version 13.11.1 against https://developer.sage.com/api/accounting/files/swagger.banking.json

The client is generated as part of MSBuild, but a call to .GetBankAccountsAsync fails with a:

Could not deserialize the response body stream as System.Collections.Generic.ICollection1[[SageApi.BankAccount`

A fiddler capture reveals a JSON response ok:

{"$total":2,"$page":1,"$next":null,"$back":null,"$itemsPerPage":20,"$items":[{"id":"d241c306f6a34390a7f59af34acd250e","displayed_as":"Bank Account (1200)","$path":"/bank_accounts/d241c306f6a34390a7f59af34acd250e"},{"id":"185ad5e870a1475e8d13778e44e958a4","displayed_as":"Cash (1210)","$path":"/bank_accounts/185ad5e870a1475e8d13778e44e958a4"}]}

It looks like its trying to desrialize the whole obejct not just the $items?

I'm running on the built-in options for this.

MikeGHUK commented 3 years ago

Looks like this is due to Sage's pagination layer that isn't in the swagger - https://developer.sage.com/api/accounting/guides/pagination/ - is there a way of hooking the response to just process the items?

RicoSuter commented 3 years ago

So it's an incomplete swagger spec?

MikeGHUK commented 3 years ago

It appears so, I can wrap the nswag generated type in a generic to provide the rest and it works.


From: Rico Suter @.> Sent: Tuesday, June 1, 2021 12:10:16 PM To: RicoSuter/NSwag @.> Cc: Mike Hudgell @.>; Author @.> Subject: Re: [RicoSuter/NSwag] NSwag deserialization Error (#3490)

So it's an incomplete swagger spec?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/RicoSuter/NSwag/issues/3490#issuecomment-852038874, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATUAT6RVGRYDAGSON3A4233TQS5ZRANCNFSM45273ZMA.