maxveldink / sorbet-schema Goto Github PK
View Code? Open in Web Editor NEWExtendable serialization and deserialization to various formats for Sorbet T::Structs
License: MIT License
Extendable serialization and deserialization to various formats for Sorbet T::Structs
License: MIT License
We have support for adding a serializer to a field to change its serialization behavior; it would be nice to be able to set a serializer based on a type that would be used for any matching type in a schema.
Allow for arrays to be defined as types in fields
When we ApplyValidators
, we should check the field type against the given value. For now, we won't do any coercion and simply return validation issues that we see.
While running the test suite, we see the following warnings a few times:
(eval at /Users/maxveldink/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11284/lib/types/props/has_lazily_specialized_methods.rb:65):1: warning: method redefined; discarding old __t_props_generated_deserialize
/Users/maxveldink/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11284/lib/types/props/has_lazily_specialized_methods.rb:91: warning: previous definition of __t_props_generated_deserialize was here
I'm not quite sure why we're redefining methods, but we should try and suppress this warning.
For our first foray into type coercion, we should choose simple types. We also need to return errors during coercion.
Conventionally, we expect a Struct
to define a .schema
class method for it's schema (a default is implemented on all of them via struct_ext.rb
.) We should defer to this when we're doing struct serialization as well
these errors are not obvious to debug:
Failed to deserialize response: Typed::Coercion::CoercionNotSupportedError
Adding the field name, source and destination types, and what was the value that was used
We should allow Fields
to receive a coercion proc that can be used instead of our default coercion behavior.
If we have a custom type that we'd like to support for fields, we need to give consumers a way to register a type coercion setting.
Right now, you'll get a hard Sorbet type error if you try to create a Schema from a Struct with a T::Boolean
field. We should support these and handle coercion.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.