[typescript-fetch] handle uniqueItems correctly in model and api#8695
Conversation
|
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
uniqueItems produces Set instead of Array as type, but the corresponding code did not treat Set correctly use `Array.from` and `new Set` to convert from Set to Array and vice versa, if uniqueItems is true. related to OpenAPITools#8258, but only fixes typescript-fetch
b202b3c to
531a852
Compare
|
@t-h-e thanks for your contribution. please follow the steps described in https://github.com/OpenAPITools/openapi-generator/blob/master/.github/PULL_REQUEST_TEMPLATE.md |
|
@macjohnny Thanks for the hint. I updated the samples. As @macjohnny mentioned correctly, this change will break setups, where type-mapping has been used. I think I found another issue, unless I'm mistaken. Pet.ts in samples/client/petstore/typescript-fetch/builds/default-3.0/models may not work correctly in line 94 and 112, as photoUrls of type Set is treated as primitive. This worked when photoUrls was of type Array, but not with Set. |
|
For other generators, we do not consider it as a breaking change as we're making a correction to the output. Let's see if any TS users have a different opinion on this. |
|
@t-h-e thanks for the PR, which has been included in the v5.1.0 release: https://twitter.com/oas_generator/status/1373636654024380423 |
uniqueItems produces Set instead of Array as type, but the corresponding code did not treat Set correctly
use
Array.fromandnew Setto convert from Set to Array and vice versa, if uniqueItems is true.related to #8258, but only fixes typescript-fetch