fix(client): builders take a body that declares variants whole - #92
Merged
Merged
Conversation
An object that declares variants beside its properties is generated as a struct with a required `variant` field, so it has neither `Default` nor a constructor from its required properties. The builder planned the body from its properties alone and called whichever applied: `Default::default()` with no required property, `Body::new(..)` with some, and neither compiled. The builder now takes such a body as an argument, as it does a body that is all required properties. Its optional properties keep their setters. The corpus doesn't change: it's generated without builders. Fixes gpu-cli#86
|
@iamralch is attempting to deploy a commit to the lbl-rd Team on Vercel. A member of the Team first needs to authorize it. |
# Conflicts: # CHANGELOG.md
This file contains hidden or 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
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.
Fixes #86.
What was wrong
An object that declares variants beside its properties is generated as a struct with a required
variantfield:It has neither
Defaultnor a constructor from its required properties.body_model_planplanned the builder's body from the properties alone, ignoringvariant, and so called whichever constructor applied:request: Default::default()when no property is required:the trait bound RenderRequest: Default is not satisfied;request: CreateAppRequest::new(name)when some are, beside optional ones:no function or associated item named new.The change
An object with
variant: Some(_)isRequiredBodyConstruction::Whole: the builder takes the body as an argument, as it already does a body that is all required properties. Its optional properties keep their setters:Tests
builders_take_a_body_that_declares_variants_wholeintests/operation_builder_test.rs, beside the OpenAI composition case and in the same style: both shapes above generate builders that take the body, and a crate calling them, including a body field setter,cargo checks. It fails before this change.cargo test --all-features: 719 passed, none failed.This and #90/#91 all add a
Fixedentry under[Unreleased]inCHANGELOG.md; I'll rebase whichever merges later.