Skip to content

Named schemas#1339

Merged
adamw merged 9 commits intomasterfrom
named-schemas
Jun 29, 2021
Merged

Named schemas#1339
adamw merged 9 commits intomasterfrom
named-schemas

Conversation

@adamw
Copy link
Copy Markdown
Member

@adamw adamw commented Jun 24, 2021

Closes #1300

To do:

  • add Option[SName] to each schema type; when this is present, the schema is considered to be a reusable component.
  • replace usages of SchemaType.SObjectInfo with SName
  • remove SchemaType.SObject as an abstraction. Just have SProduct and SCoproduct as regular implementations of SchemaType
  • make SCoproduct more generic so that child schemas can be arbitrary (not just objects)
  • add a default schema for Either (mirroring what eitherDecoder does)

adamw added 7 commits June 24, 2021 19:14
Replace object info for products/coproducts, with an optional schema name. If a schema has a name, it will be rendered as a component in docs.
Coproducts now contain simply a list of child schemas, without the requirements for the schemas to be named
*/
implicit def eitherRight[L, A, B, CF <: CodecFormat](implicit c1: Codec[L, A, CF], c2: Codec[L, B, CF]): Codec[L, Either[A, B], CF] = {
Codec
.id[L, CF](c1.format, Schema.binary)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you use the Schema.binary here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to use some schema, but it's overriden later, so what's chosen here doesn't matter. I'll add a comment.

List(${Varargs(instances)}: _*).asInstanceOf[List[T]],
None,
${info}
${name}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm I'm not sure if Validator should contain an instance of SName which is defined in Schema. What do youI think about defining SName a separate file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm well that's the name of the schema. I think it belongs to Schema.

@adamw adamw merged commit 68a358e into master Jun 29, 2021
@mergify mergify Bot deleted the named-schemas branch June 29, 2021 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Either type in the model

2 participants