Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend describing templates/generic types using $dynamicRef #3601

Closed
handrews opened this issue Feb 22, 2024 · 4 comments
Closed

Recommend describing templates/generic types using $dynamicRef #3601

handrews opened this issue Feb 22, 2024 · 4 comments
Assignees
Milestone

Comments

@handrews
Copy link
Member

handrews commented Feb 22, 2024

During the recent issue backlog tidying effort, I closed at least six issues by pointing to @gregsdennis's Using Dynamic References to Support Generic Types blog post:

But there are several problems with pointing folks to this technique:

  1. It's not mentioned in the OAS spec, so many people, including code generation tool developers, are not aware of it
  2. It's not even mentioned in the JSON Schema spec as it wasn't how I was thinking about it when I wrote those sections
  3. $dynamicAnchor and $dynamicRef are among the most likely features to be hiding in the asterisk on many tools' "Supports OAS 3.1*" claims (it's basically taken discriminator's place as the keyword that is left until the end to even attempt)

We already have a large section on supporting polymorphic types. We should add a brief section on generic types, at least enough to make it clear what keywords can be used. We should definitely do this in 3.2.0, and maybe even 3.1.1 as it does not add any new requirements. In 3.2.0, I suppose we could add requirements to support the idiom but I'd settle for making people aware of it. If there's demand for it, tools will add support, but first folks have to know about it.

I don't think we need to go into a lot of detail on how it works. That can be offloaded to the Learn site.

@gregsdennis
Copy link

In the context of OAS 3.1, I think I'd defer to the OAS vocab's discriminator keyword. That post is really more of a "pure JSON Schema" approach.

@handrews
Copy link
Member Author

@gregsdennis discriminator doesn't support generics, so I'm a bit confused about your comment.

@gregsdennis
Copy link

Oh I'm thinking polymorphism. Please disregard.

@handrews
Copy link
Member Author

All PRs merged, closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants