Add an encoded discriminator value attribute for coproducts, use it to render const constraints#3955
Merged
Merged
Conversation
…o render const constraints
kamilkloch
reviewed
Jul 25, 2024
| val Attribute: AttributeKey[Tuple] = new AttributeKey[Tuple]("sttp.tapir.Schema.Tuple") | ||
| } | ||
|
|
||
| /** For coproduct schemas, when there's a discriminator field, used to attach the encoded value of the discriminator field. Such value is |
Contributor
There was a problem hiding this comment.
Coproduct may be also rendererd without a discriminator field (Json object nesting). We need to make sure this case is covered as well.
Member
Author
There was a problem hiding this comment.
Yes, this applies only to discriminators. I think if there's no discriminator, then we don't have to do anything, that is we shouldn't add any constraints?
Member
Author
|
You can see how this is rendered in the OpenAPI yamls in the tests - let me know if that's what you were after |
Contributor
|
Thank you, will do! |
|
@adamw thank you! I will test this with my setup |
Contributor
|
Please take a look at test that illustrates issue with async api: |
Contributor
Member
Author
|
@zorba128 I've added your test, take a look |
Contributor
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

An alternative approach to #3763
cc @kamilkloch @zorba128 @seveneves
Closes #3909