Skip to content

feat: add contains/minContains/maxContains members#2876

Merged
baywet merged 6 commits into
microsoft:mainfrom
Poltuu:main
Jun 9, 2026
Merged

feat: add contains/minContains/maxContains members#2876
baywet merged 6 commits into
microsoft:mainfrom
Poltuu:main

Conversation

@Poltuu

@Poltuu Poltuu commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Description

Adds the JSON Schema 2020-12 array keywords contains, maxContains, and minContains to the Schema Object, as required by the OpenAPI 3.1/3.2 specifications.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • 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)

Closes #2875 #2875

Changes Made

  • Added Contains (IOpenApiSchema?), MaxContains (int?), and MinContains (int?) members to IOpenApiSchema, OpenApiSchema, and OpenApiSchemaReference, plus contains/maxContains/minContains constants in OpenApiConstants.
  • Added deserialization in the V3.1 and V3.2 schema readers and serialization in WriteJsonSchemaKeywords (emitted for OpenAPI 3.1+ only; dropped on 3.0/2.0 downcast, consistent with dependentRequired).
  • Updated PublicAPI.Unshipped.txt with the new public surface.

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: this PR
  • 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

@baywet baywet left a comment

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.

Thanks for the contribution!
Left a couple of comments to help get this merged.
Also realized that a couple of other properties were missing:

Comment thread src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs Outdated
Comment thread src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs Outdated
Comment thread src/Microsoft.OpenApi/Models/Interfaces/IOpenApiSchema.cs Outdated

@baywet baywet left a comment

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.

Thank you for making the changes!

Added a couple more comments

Comment thread src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs Outdated
Comment thread src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs
@baywet baywet self-assigned this Jun 9, 2026
@github-code-quality

github-code-quality Bot commented Jun 9, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the branch remains at 88%, unchanged from the branch.

Show a code coverage summary of the most impacted files.
File 21488c6 b635242 +/-
/home/runner/wo...penApiWalker.cs 80% 80% 0%
/home/runner/wo...emaReference.cs 93% 93% 0%
/home/runner/wo...penApiSchema.cs 99% 99% 0%
/home/runner/wo...ApiWorkspace.cs 89% 89% 0%
/home/runner/wo...Deserializer.cs 87% 90% +3%
/home/runner/wo...Deserializer.cs 87% 90% +3%
/home/runner/wo...Deserializer.cs 81% 86% +5%

Updated June 09, 2026 18:40 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

baywet and others added 4 commits June 9, 2026 14:46
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
baywet
baywet previously approved these changes Jun 9, 2026
@baywet baywet enabled auto-merge June 9, 2026 19:06
@baywet baywet disabled auto-merge June 9, 2026 19:10
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@baywet baywet merged commit 78475e3 into microsoft:main Jun 9, 2026
12 checks passed
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.

min/max contains schema property are missing 3.1+

3 participants