ProductAsArray attribute added, alternative rendering of SProduct#3941
Conversation
…r than Object. Signed-off-by: Marcin Kielar <zorba128@interia.pl>
|
Alternative solution would be to introduce Or extend But both solutions seem like bigger undertakings compared to proposed in PR. |
| case TSchemaType.SBoolean() => ASchema(SchemaType.Boolean) | ||
| case TSchemaType.SString() => ASchema(SchemaType.String) | ||
| case TSchemaType.SProduct(fields) if schema.attribute(TSchema.ProductAsArray.Attribute).map(_.productAsArray).getOrElse(false) => | ||
| // TODO: Draft04 uses alternative form of `items` instead |
There was a problem hiding this comment.
I think Draft04 is only used here:
So maybe let's change it to 2020-12? That's what used by apispec
There was a problem hiding this comment.
I think already output of TapirSchemaToJsonSchema looks more like 2020-12 than Draft04. Few tests show schemas validate correctly (against meta schema). Can I push this change to this PR?
| val Attribute: AttributeKey[UniqueItems] = new AttributeKey[UniqueItems]("sttp.tapir.Schema.UniqueItems") | ||
| } | ||
|
|
||
| case class ProductAsArray(productAsArray: Boolean) |
There was a problem hiding this comment.
maybe we could add a comment here, explaining what is the purpose of this attribute, or at least linking to this issue number (#3941)?
|
Looks good, and I agree that's currently a better solution that is much less disruptive then trying to add a new Shouldn't we also add implicit schemas for tuples? Having their schemas generated as case classes is probably not what anybody wants. |
Signed-off-by: Marcin Kielar <zorba128@interia.pl>
Signed-off-by: Marcin Kielar <zorba128@interia.pl>
Definitely - maybe someone more familiar with tapir's schema generation macros could take a look? It would take a while to dig into it... |
Signed-off-by: Marcin Kielar <zorba128@interia.pl>
|
Thanks, I'll add the schemas in a separate PR |
Relates to #2604.
Looking at https://json-schema.org/understanding-json-schema/reference/array#tupleValidation it seems Array is natural representation for tuples (and this is what circe mentioned in the ticket does by default).
Draft04, which used slightly different way of representing array element type constraints (itemsinstead ofprefixItems).