devexperts / swagger-codegen-ts

Typesafe Swagger API generator for TypeScript
Mozilla Public License 2.0
80 stars 16 forks source link

anyOf support #179

Open Geksanit opened 11 months ago

Geksanit commented 11 months ago

I suggest adding support anyOf to codegen. the difference between anyOf and oneOf is discussed here: https://stackoverflow.com/a/56039838

kokovtsev commented 10 months ago

That SO answer might be incorrect about mixed element types in arrays.

It appears that the difference between oneOf/anyOf only affects the validation:

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.

kokovtsev commented 10 months ago

@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