-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: 0.2.0 #51
Merged
Merged
feat: 0.2.0 #51
Conversation
This file contains 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
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
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.
JsonValue
hierarchy for representing JSON primitives safelymodels.dart
/exceptions.dart
. Only types you've defined.lib/models/
andlib/exceptions/
folders for better organization of custom typesThis release also adds a new way to control serialization called "custom overrides".
There are times when you want to use a type from a third-party package in an API, but it is not serializable and Celest complains when you do so. Because you do not control the package, you cannot make it serializable and you are stuck. Other times, the opinionated way Celest serializes (e.g. by using
fromJson
/toJson
methods if available) doesn't align with how you've defined these APIs.In both of these situations, custom overrides allow you to reimagine the types so that they can be serialized with Celest.
Consider a type called
MyType
which hasfromJson/toJson
methods you cannot control and which are causing errors with Celest. The simplest override of this type would look like this (defined inlib/models/overrides.dart
):The
@override
annotation tells Celest to use this type instead of the originalMyType
when it encounters aMyType
value at any point. The override applies globally and affects all instances ofMyType
when passing from client<->server. And sinceMyTypeOverride
does not definefromJson
/toJson
methods, Celest will generate its own.Custom overrides can do a lot more than override
fromJson
/toJson
methods, though. They can redefine constructors, fields, and even field types. And custom overrides work for exception types too (define those inlib/exceptions/overrides.dart
)!Fixes
Deprecations
lib/models.dart
/lib/exceptions.dart
have been deprecated in favor oflib/models/
andlib/exceptions/
foldersBreaking Changes
@env.myEnvVar
->@Env.myEnvVar
)