Skip to content

http-client-java, option for allowing null value passed in property - #8097

Merged
Weidong Xu (weidongxu-microsoft) merged 7 commits into
microsoft:mainfrom
weidongxu-microsoft:http-client-java_allow-null-property
Aug 5, 2025
Merged

http-client-java, option for allowing null value passed in property#8097
Weidong Xu (weidongxu-microsoft) merged 7 commits into
microsoft:mainfrom
weidongxu-microsoft:http-client-java_allow-null-property

Conversation

@weidongxu-microsoft

Copy link
Copy Markdown
Contributor

@microsoft-github-policy-servicemicrosoft-github-policy-serviceBot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Aug 5, 2025
@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

@azure-sdk

Azure SDK Bot (azure-sdk) commented Aug 5, 2025

Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground🌐 Website🛝 VSCode Extension

@weidongxu-microsoftWeidong Xu (weidongxu-microsoft) changed the title http-client-java, option for allow null value passed in propertyhttp-client-java, option for allowing null value passed in propertyAug 5, 2025
@weidongxu-microsoft
Weidong Xu (weidongxu-microsoft) marked this pull request as ready for review August 5, 2025 06:21

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for allowing null values to be passed to specific model properties and serialized as explicit null fields in JSON output. The feature addresses issue #3102 by implementing a property-include-always option that forces serialization of null values for specified properties instead of omitting them entirely.

Key changes:

  • Added a new configuration option property-include-always to control which properties should always be serialized even when null
  • Modified the JSON serialization logic to explicitly write null fields for specified properties
  • Added test coverage to verify the behavior works correctly

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
EmitterOptions.javaAdded propertyIncludeAlways field and JSON parsing support for the new option
TypeSpecFluentPlugin.javaAdded configuration mapping to pass the new option to the generator settings
FluentJavaSettings.javaAdded documentation for the property names that should always be serialized
FluentStreamStyleSerializationModelTemplate.javaImplemented custom serialization logic to handle null value serialization for specified properties
StreamSerializationModelTemplate.javaRefactored serialization methods to be extensible and support custom behavior
FunctionConfiguration.javaGenerated test model with explicit null field serialization for the input property
StreamStyleSerializationTests.javaAdded test to verify null values are properly serialized for specified properties
Generate.ps1Added test configuration to enable the new feature for FunctionConfiguration.input

Merged via the queue into microsoft:main with commit 74d1b5aAug 5, 2025
26 checks passed
@weidongxu-microsoft
Weidong Xu (weidongxu-microsoft) deleted the http-client-java_allow-null-property branch August 5, 2025 08:42
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:javaIssue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsp, handle "property-include-always" setting

5 participants

@weidongxu-microsoft@azure-sdk@haolingdong-msft@XiaofeiCao