[HackWeek] Add default values for (select) primitives and enums to the IR compiler #1615
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.
Before this PR
Services using Conjure that wish to remain backwards-compatible while expanding their storage types must declare all new types as
Optional
s in order to avoid breaking Conjure's deserialization. This requires defaults to be declared in the implementation layer rather than in the API layer, in addition to creating a large number of useless box objects that bloat memory, and confusing the API spec with optional objects that are not actually optional. I personally have encountered bugs where a value was accidentally omitted from a "for backwards-compatibility only" in a storage type, causing developer hours to be wasted on something that should have been caught by the type system.After this PR
FieldDefinitions in YAML now support a
default
parameter which accepts a value to supplied when null or empty values of this field are deserialized instead of throwing an error. Currently all primitive types (barring bearertokens andANY
) and enum values are supported. More complex types would work too, but the demand is small and I want to constrain the scope of this project.==COMMIT_MSG==
Add default values for primitives and enums to the IR compiler
==COMMIT_MSG==