Repository navigation
fix(codegen): preserve optional on scalar properties in Avro, GraphQL, Protobuf and Rust - #313
Closed
ItsAbir005 wants to merge 1 commit into
Closed
ItsAbir005 wants to merge 1 commit into
ItsAbir005 wants to merge 1 commit into
Conversation
…, Protobuf and Rust Field.getScalarField() builds a new field that copies name and array but not optional, so visitField treated `o SSN taxId optional` as required. Pass thing.isOptional() from visit() into visitField as an optional isOptional argument (defaulting to field.isOptional()), and use it wherever visitField checked optionality. Protobuf's concertoToProto3FieldRule gets the same optional argument. Also marks Function.responseType, Logic.stateType, Agreement.state, PdfConversionOptions.styles and TriggerResponse.result as optional in the APAP protocol Protobuf fixture, and regenerates the type declarations. Closes #306 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HLiXZ9jMJ2WD3FmLRKWnsi Signed-off-by: Abir Maity <abirmaity44@gmail.com>
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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.
Closes #306
Optional properties with a scalar type (for example
o SSN taxId optional) were generated as required in the Avro, GraphQL, Protobuf and Rust visitors. This PR fixes that, so they now match ano String taxId optionalproperty.Changes
Field.getScalarField()in concerto-core builds a new field that copiesnameandarraybut notoptional, sovisitFieldtreated scalar-typed properties as required.visit()now passesthing.isOptional()intovisitFieldas an optionalisOptionalargument. It defaults tofield.isOptional(), so other callers behave as before.concertoToProto3FieldRulegets the same optionalisOptionalargument.Function.responseType,Logic.stateType,Agreement.state,PdfConversionOptions.stylesandTriggerResponse.resultare nowoptional. They were alreadyoptionalinapapProtocol.cto.types/*.d.tsis regenerated, becauseconcertoToProto3FieldRuleis public and its signature changed.Generated output for
o SSN taxId optional:string taxId;union { null, string } taxId;taxId: String!taxId: Stringstring taxId = 3;optional string taxId = 3;pub tax_id: String,pub tax_id: Option<String>,withskip_serializing_ifFlags
visitFieldis also called with a plain{ name: '$class', type: 'String' }object, so its default isfield.isOptional?.(). Relationship handling in the Rust visitor is unchanged.npx eslint lib test(clean) and the full mocha suite (693 passing, 24 failing). The same 24 fail without this change, because they needprotoc,xmllint, avro-tools and network access that my environment lacks.protoc,cargo check).npm run test:updateSnapshotsproduced no snapshot changes.getScalarField(). TypeScript was fixed in fix(typescript): propagate optional modifier for scalar fields #195, and the C# and JSON Schema visitors already readisOptional()from the property.Screenshots or Video
N/A
Related Issues
Author Checklist
--signoffoption of git commit.mainfromfork:branchname🤖 Generated with Claude Code
https://claude.ai/code/session_01HLiXZ9jMJ2WD3FmLRKWnsi