swagger-codegen-ts
swagger-codegen-ts copied to clipboard
anyOf support
I suggest adding support anyOf
to codegen.
the difference between anyOf
and oneOf
is discussed here: https://stackoverflow.com/a/56039838
That SO answer might be incorrect about mixed element types in arrays.
It appears that the difference between oneOf
/anyOf
only affects the validation:
-
anyOf
allows inputs that conform to multipleanyOf
members; -
oneOf
requires that the input object matches exactly one union member. After a match is found, we should check that the input does not match any other options.
The generated type would be a union type in both cases.
In fact, we do not do this "exactly one" check, so our implementation of oneOf
actually behaves like anyOf
.
@Geksanit please review some work-in-progress in #181, if you're ok with the approach I will apply the same to OpenAPI 2.0 and AsyncAPI