This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.36k
stars
2k
forks
source link
Regenerate SDKs to Use Stream Style Serialization #35082
Steps to onboard stream style serialization workflow for SDK's
NOTE:Only JSON-based SDKs can be migrated at this time
Add azure-json as a runtime dependency in your pom.xml and add requires transitive com.azure.json to your module-info.java.
Add stream-style-serialization: true to Code generation settings in respective swagger/autorest.md. This will result in generated model types implementing JsonSerializable<T> and will remove Jackson Databind annotations.
If your SDK uses custom Jackson Databind handling replace it with custom azure-json handling. azure-json works similarly to Jackson's JsonGenerator and JsonParser by handling JSON payloads using a streaming API. This includes removing all JacksonAdapter usage in handwritten code, any usage of JacksonAdapter in generated code will be removed by updates to Autorest Java in the future.
If your SDK interacts with customer types remove usage of JacksonAdapter from azure-core and replace it with JacksonAdapter from azure-core-serializer-json-jackson for the short term. Long term this should be replaced by JsonSerializer being loaded from the classpath with a default of azure-core-serializer-json-jackson's JsonSerializer implementation.
Once migrated run local testing to verify before opening a PR. Once the PR is opened run live testing as final validation.
For SDKs that have extensive handwritten layers that transform to the generated code, leave the handwritten layer as is, aside from removing usage of Jackson Databind. This will make the migration easier for now, long term it should be investigated to use Autorest Java code customizations to reduce the size of the transformation layer, reducing maintenance costs for the SDK.
If any issues are found in the code generated by Autorest Java please file an issue in https://github.com/Azure/autorest.java and assign it to alzimmermsft tagged with v4.
Steps to onboard stream style serialization workflow for SDK's
NOTE: Only JSON-based SDKs can be migrated at this time
Add
azure-json
as a runtime dependency in yourpom.xml
and addrequires transitive com.azure.json
to yourmodule-info.java
.Add
stream-style-serialization: true
toCode generation settings
in respective swagger/autorest.md. This will result in generated model types implementingJsonSerializable<T>
and will remove Jackson Databind annotations.If your SDK uses custom Jackson Databind handling replace it with custom
azure-json
handling.azure-json
works similarly to Jackson'sJsonGenerator
andJsonParser
by handling JSON payloads using a streaming API. This includes removing allJacksonAdapter
usage in handwritten code, any usage ofJacksonAdapter
in generated code will be removed by updates to Autorest Java in the future.JacksonAdapter
fromazure-core
and replace it withJacksonAdapter
fromazure-core-serializer-json-jackson
for the short term. Long term this should be replaced byJsonSerializer
being loaded from the classpath with a default ofazure-core-serializer-json-jackson
'sJsonSerializer
implementation.azure-json
can be found in the App Configuration onboarding PR: https://github.com/Azure/azure-sdk-for-java/pull/34231/files#diff-c08e6bf37404f06230edfd264fb858fe3f83d7b72f4d489555559932e6cdaebfR42Once migrated run local testing to verify before opening a PR. Once the PR is opened run live testing as final validation.
For SDKs that have extensive handwritten layers that transform to the generated code, leave the handwritten layer as is, aside from removing usage of Jackson Databind. This will make the migration easier for now, long term it should be investigated to use Autorest Java code customizations to reduce the size of the transformation layer, reducing maintenance costs for the SDK.
If any issues are found in the code generated by Autorest Java please file an issue in https://github.com/Azure/autorest.java and assign it to
alzimmermsft
tagged withv4
.