Skip to content

feat: Add OpenApiJsonWriterSettings parameter to SerializeAsJsonAsync to be able to serialize json to compact format using Terse parameter#2799

Open
rmijacques wants to merge 2 commits intomicrosoft:mainfrom
rmijacques:serialize-json-with-writer-settings
Open

feat: Add OpenApiJsonWriterSettings parameter to SerializeAsJsonAsync to be able to serialize json to compact format using Terse parameter#2799
rmijacques wants to merge 2 commits intomicrosoft:mainfrom
rmijacques:serialize-json-with-writer-settings

Conversation

@rmijacques
Copy link
Copy Markdown

Pull Request

Description

Added a setting parameter to SerializeAsJsonAsync to be able to serialize JSON to compact format out of the box.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • [x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Related Issue(s)

Fixes #2798

Changes Made

  • Added OpenApiJsonWriterSettings settings parameter to SerializeAsJosnAsync method and passed it down the chain to SerializeAsync

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Versions applicability

  • My change applies to the version 1.X of the library, if so PR link:
  • My change applies to the version 2.X of the library, if so PR link:
  • My change applies to the version 3.X of the library, if so PR link:
  • I have evaluated the applicability of my change against the other versions above.

See the contributing guidelines for more information about how patches are applied across multiple versions.

Additional Notes

…to be able to serialize json to compact format using Terse parameter
@rmijacques rmijacques requested a review from a team as a code owner March 26, 2026 10:16
@rmijacques
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Lucca"

@rmijacques rmijacques changed the title feat: Add OpenApiJsonWriterSettings paramter to SerializeAsJsonAsync to be able to serialize json to compact format using Terse parameter feat: Add OpenApiJsonWriterSettings parameter to SerializeAsJsonAsync to be able to serialize json to compact format using Terse parameter Mar 26, 2026
Copy link
Copy Markdown
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

I believe we'll need to carefully iterate on the changes to maintain the binary and source compatibility here.

/// <param name="specVersion">Version of the specification the output should conform to</param>
/// <param name="cancellationToken">The cancellation token.</param>
public static Task SerializeAsync<T>(this T element, IOpenApiWriter writer, OpenApiSpecVersion specVersion, CancellationToken cancellationToken = default)
public static Task SerializeAsync<T>(this T element, IOpenApiWriter writer, OpenApiSpecVersion specVersion, CancellationToken cancellationToken)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This breaks source and binary compatibility. The cancellationToken is now mandatory for a bunch of the overloads as we can see in the API export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ability to return compact JSON format when calling SerializeAsJsonAsync

2 participants