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

Schema overhaul #140

Merged
merged 65 commits into from
May 9, 2022
Merged

Schema overhaul #140

merged 65 commits into from
May 9, 2022

Conversation

Baccata
Copy link
Contributor

@Baccata Baccata commented Mar 15, 2022

This is an overhaul of the "schema/schematic" abstraction to make use of a GADT. We're trading off extensibility for ease of implementation for interpreters. In particular, having a GADT at hand allows us to peek into the structure of a schema (and the hints carried at each layer), several layers down, without a need for ad-hoc constructs such as Hinted and such.

It also allows interpreters to delegate to other interpreters when convenient.

@kubukoz
Copy link
Member

kubukoz commented Mar 16, 2022

random notes found while playing with this:

  • withHints is now probably redundant (?) since addHints is available directly on Schema
  • how about a Primitive#schema that takes ShapeId as a parameter?

kubukoz and others added 27 commits April 8, 2022 19:48
* Adds `checked` methods on Schema and Field
* Adds some black-magic to shoe-horn refinements into fields
* Fix some tests in the json module
Best effort parsing happens if:

* no errorTypeHeader is found to discriminate
* status code matches multiple error type or no error type

In this case, the following logic happens:

* we try to decode for every union alternative
* first success wins
* order is "smart" (see below)

Ordering of the alternatives depends on the status code. If status
is in the 4xx, then generic client error are placed first, otherwise
it's server ++ client ++ the rest.

See https://awslabs.github.io/smithy/1.0/spec/core/http-traits.html#httperror-trait

Note: if one of the alternative has only optional event, chances
are that parsing will be successful
Better error handling on the client
@Baccata Baccata merged commit 1132fef into main May 9, 2022
@Baccata Baccata deleted the schema-overhaul branch May 9, 2022 07:22
Baccata added a commit that referenced this pull request May 10, 2022
This is an overhaul of the "schema/schematic" abstraction to make use of a GADT. We're trading off extensibility for ease of implementation for interpreters. In particular, having a GADT at hand allows us to peek into the structure of a schema (and the hints carried at each layer), several layers down, without a need for ad-hoc constructs such as `Hinted` and such. 

It also allows interpreters to delegate to other interpreters when convenient. 

It also adds the notion of `surjection` in the schema, which allow to capture transformations that work only on a subset of the type of the schema. The usefulness of it has to do with making it easier for downstream implementors to incorporate validation concerns within the decoders. 

Additionally, traits that imply validation of the incoming data (range/length/pattern) are now receiving specific treatment during codegen in order for the schemas containing them to leverage the surjection. 

Co-authored-by: Jakub Kozłowski <kubukoz@gmail.com>
Co-authored-by: David Francoeur <dfrancoeur04@gmail.com>
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.

3 participants