-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add support for @nullable trait in order to support MergePatch usecases #1408
Commits on Feb 20, 2024
-
Add nullable support to JSON parsing
The JSON codec will now check for a Nullable hint on the schema it is parsing and not immediately parse fields as None if present. Note that getting this to work with a new Nullable type does require adjusting the code checking whether a Schema is for an Option a little so that it can also include bijections from an option type.
Configuration menu - View commit details
-
Copy full SHA for 65e5ed1 - Browse repository at this point
Copy the full SHA 65e5ed1View commit details -
Adjust codegen code to handle Nullable
This involves totally reworking the Field.Modifier logic, as the addition of Nullable makes the number of cases too complex to keep track of in an enum alone: the modifier logic now depends on * whether there is a @required annotation present * whether there is a @nullable annotation present * whether there is a default value present, and (for nullable) whether this value is null or a concrete value making for a total of ten theoretical cases resulting in four possible types in the Scala code. We model this in a case class and attempt to shift some of the logic, such as ordering or working out the wrapped type, to the class itself in order to avoid other parts of the code needing to work with its internals.
Configuration menu - View commit details
-
Copy full SHA for 87ca4c9 - Browse repository at this point
Copy the full SHA 87ca4c9View commit details -
Add nullable sample spec and smoke tests
There is a mild tension here: on the one hand, we really want to test all the edge cases of different field modifier combinations to make sure the generation code works as wel expect. On the other, these combinations generally have only an extremely limited use or are just overly convoluted ways to specify the default behaviour, and so they shouldn't be in the sample specs people use to check usage. We handle this by providing two test cases: Patchable, which handles the merge patch behaviour this whole change is meant to support, and PatchableEdgeCases which is explicitly described as only there for testing purposes.
Configuration menu - View commit details
-
Copy full SHA for 8a64977 - Browse repository at this point
Copy the full SHA 8a64977View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8edf430 - Browse repository at this point
Copy the full SHA 8edf430View commit details -
Configuration menu - View commit details
-
Copy full SHA for 62e4ca8 - Browse repository at this point
Copy the full SHA 62e4ca8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2e177fe - Browse repository at this point
Copy the full SHA 2e177feView commit details -
Configuration menu - View commit details
-
Copy full SHA for 388b45e - Browse repository at this point
Copy the full SHA 388b45eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 67c06bc - Browse repository at this point
Copy the full SHA 67c06bcView commit details
Commits on Feb 21, 2024
-
Update modules/core/src/smithy4s/Nullable.scala
Co-authored-by: Olivier Mélois <baccata64@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 41fb310 - Browse repository at this point
Copy the full SHA 41fb310View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5062108 - Browse repository at this point
Copy the full SHA 5062108View commit details -
The error message rendering code for custom error message fields is different for every type modification and also for custom vs primitive types - we add a test case for every combination to be absolutely sure they're being rendered correctly.
Configuration menu - View commit details
-
Copy full SHA for 8b42288 - Browse repository at this point
Copy the full SHA 8b42288View commit details -
Revert "Inexplicable hint reorderings that happened on compilation"
This reverts commit 8edf430.
Configuration menu - View commit details
-
Copy full SHA for e4b86e9 - Browse repository at this point
Copy the full SHA e4b86e9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 119aabf - Browse repository at this point
Copy the full SHA 119aabfView commit details -
Although technically the FieldTN representations aren't correct, this part of the code should never use the @nullable annotation and it's considered acceptable to leave as is.
Configuration menu - View commit details
-
Copy full SHA for 092eab6 - Browse repository at this point
Copy the full SHA 092eab6View commit details -
Add cats instances for Nullable
This does not include every type class satisfied by Option but just the ones we think are most likely to be needed by a consumer.
Configuration menu - View commit details
-
Copy full SHA for e387b94 - Browse repository at this point
Copy the full SHA e387b94View commit details -
Add test and refactor for getUnlessDefault
We refactor foreachUnlessDefault so the logic is not duplicated across two methods, and add some tests to confirm that it works as expected on a nullable field.
Configuration menu - View commit details
-
Copy full SHA for ef98fc2 - Browse repository at this point
Copy the full SHA ef98fc2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 388c1fc - Browse repository at this point
Copy the full SHA 388c1fcView commit details -
Configuration menu - View commit details
-
Copy full SHA for eacf966 - Browse repository at this point
Copy the full SHA eacf966View commit details -
Configuration menu - View commit details
-
Copy full SHA for 95abbc4 - Browse repository at this point
Copy the full SHA 95abbc4View commit details -
Configuration menu - View commit details
-
Copy full SHA for ee44174 - Browse repository at this point
Copy the full SHA ee44174View commit details
Commits on Feb 22, 2024
-
Add support for Nullable in dynamic module
Including tests to make sure all traits and schemas behave as expected - this does unfortunately require trying to figure out whether a schema is Nullable at runtime, which is an awkward process.
Configuration menu - View commit details
-
Copy full SHA for c6be356 - Browse repository at this point
Copy the full SHA c6be356View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2dbb0bb - Browse repository at this point
Copy the full SHA 2dbb0bbView commit details -
Fix trait reference in dynamic module
Not 100% sure why this compiled locally, but it looks like this should fix it?
Configuration menu - View commit details
-
Copy full SHA for d0926e8 - Browse repository at this point
Copy the full SHA d0926e8View commit details -
Revert extra handling of default in dynamic module
It's acceptable for fields with a default value to be wrapped in Option in the dynamically generated code, and trying to align it with the static codegen behaviour is causing problems in the compliance tests. We remove that change and any tests that relied on it.
Configuration menu - View commit details
-
Copy full SHA for 8344e40 - Browse repository at this point
Copy the full SHA 8344e40View commit details -
Configuration menu - View commit details
-
Copy full SHA for b2ae9d7 - Browse repository at this point
Copy the full SHA b2ae9d7View commit details
Commits on Feb 23, 2024
-
Apparently 2.13 is more picky about line length for scalafmt than the other Scala versions, and I hadn't formatted the test files right - this should fix it.
Configuration menu - View commit details
-
Copy full SHA for 67ae7ba - Browse repository at this point
Copy the full SHA 67ae7baView commit details -
Configuration menu - View commit details
-
Copy full SHA for b3f7996 - Browse repository at this point
Copy the full SHA b3f7996View commit details -
Configuration menu - View commit details
-
Copy full SHA for 85da837 - Browse repository at this point
Copy the full SHA 85da837View commit details -
Configuration menu - View commit details
-
Copy full SHA for c268f7c - Browse repository at this point
Copy the full SHA c268f7cView commit details
Commits on Feb 26, 2024
-
Update modules/docs/markdown/04-codegen/01-customisation/13-nullable-…
…values.md Co-authored-by: Olivier Mélois <baccata64@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 7c44617 - Browse repository at this point
Copy the full SHA 7c44617View commit details