openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Confusion about discriminator test case

Open H01001000 opened this issue 2 years ago • 1 comments

Description Not sure if I understand correctly, for me it seems the discriminator should only exist on the parent schema, and not the child, where the discriminator mapping map the value it has to the child type/$ref. If I am interpreting correctly, it seems the test cases for discriminator are having some issues, eg discriminator > oneOf, the child having discriminator, discriminator > allOf the child having discriminator and point to the parent

may related to #1158

Name Version
openapi-typescript 7.0.0-next.0
Node.js 18.12.0
OS + version Windows 10

Checklist

H01001000 avatar Nov 21 '23 00:11 H01001000

Just so I’m clear, could you point to the specific test you’re referring to, and what you think the correct output types should be?

In general, though, there’s not really a “parent–child” relationship when it comes to composition. When you mark something as allOf you are really just extending that object. I don’t think it’s accurate to call it a “child” node because they’re both on the same level; you’re just saving yourself some typing. So I think you’re intentionally not redeclaring a discriminator when using composition.

But I may be off the mark / missing something. Happy to talk through a more specific example of what’s generated today vs. what you expect to happen if you provide one

drwpow avatar Nov 21 '23 15:11 drwpow

This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

github-actions[bot] avatar Aug 06 '24 12:08 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.

github-actions[bot] avatar Aug 14 '24 02:08 github-actions[bot]