Skip to content

fix(v2): map OpenAPI 2.0 response schema type file to binary format - #3150

Merged
Vincent Biret (baywet) merged 5 commits into
microsoft:mainfrom
hardikkaurani:fix/v2-schema-type-file-binary-format
Oct 27, 2026
Merged

Vincent Biret (baywet) merged 5 commits into
microsoft:mainfrom
hardikkaurani:fix/v2-schema-type-file-binary-format

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Summary of Changes

Resolves #3149.

In OpenAPI 2.0, the Response Object specifies:

"As an extension to the Schema Object, its root type value may also be "file". This SHOULD be accompanied by a relevant produces mime-type."

While OpenApiParameterDeserializer already maps type: file to Type = JsonSchemaType.String and Format = "binary", OpenApiSchemaDeserializer previously omitted setting Format = "binary" when type: file was encountered. As a result, OpenAPI 2.0 response schemas returning files were deserialized into plain strings without format metadata.

This PR adds:

  1. Format = "binary" assignment when type equals "file" (case-insensitive) in OpenApiSchemaDeserializer, matching OpenApiParameterDeserializer.
  2. Unit tests in OpenApiSchemaTests.cs verifying both direct schema parsing and response object schema resolution for type: file.

Verification

  • Tested schema deserialization mapping type: file -> JsonSchemaType.String with Format = "binary".
  • Tested response object deserialization ensuring content schema format is "binary".

@hardikkaurani
Hardik K (hardikkaurani) requested a review from a team as a code owner October 27, 2026 08:47
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet),

This PR addresses #3149 by bringing schema deserialization in OpenAPI 2.0 into alignment with parameter deserialization:

  1. OpenAPI 2.0 Response Schema type: file: Per the OpenAPI 2.0 Response Object specification, the schema root type may be "file". In OpenApiParameterDeserializer, type: file was already mapped to type: string with format: "binary", but OpenApiSchemaDeserializer previously omitted setting Format = "binary".
  2. Parity: Added the case-insensitive "file" check in OpenApiSchemaDeserializer to set Format = "binary".
  3. Tests: Added unit tests in OpenApiSchemaTests.cs validating direct schema parsing as well as end-to-end response schema loading (IOpenApiResponse).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new response test bypasses media-type processing, leaving Content null and causing its assertion to fail.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 27, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet),

I've pushed an update addressing the failing response schema test in CI.

In OpenAPI 2.0, response content media types are synthesized during operation- or document-level parsing via ProcessProduces matching against produces. The previous integration test was invoking LoadResponse in isolation, leaving response.Content unpopulated. The test now parses an enclosing operation with an explicit produces: ["application/octet-stream"], validating that ProcessProduces correctly populates response.Content and assigns Type = JsonSchemaType.String with Format = "binary".

Ready for your review when you have a moment.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the change preserving binary format metadata in OpenAPI 2.0 file response schemas.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@baywet
Vincent Biret (baywet) merged commit e41f0e8 into microsoft:main Oct 27, 2026
9 checks passed
Vincent Biret (baywet) added a commit that referenced this pull request Oct 28, 2026
…3150) (#3151)

* test(v2): add unit test for OpenAPI 2.0 schema type file mapping to binary format

* fix(v2): set format binary when reading OpenAPI 2.0 schema with type file

* test(v2): add response schema integration test for type file

* docs(v2): document OpenAPI 2.0 file type to binary format mapping in schema deserializer

* test(v2): parse enclosing operation with produces to populate response content schema

Co-authored-by: Hardik K <hardikkaurani1@gmail.com>
This was referenced Nov 30, 2026
Sebastian Paul Boghiu (ThorSPB) pushed a commit to CampusPulse-ro/api that referenced this pull request Nov 30, 2026
Updated
[coverlet.collector](https://github.com/coverlet-coverage/coverlet) from
10.1.0 to 10.1.1.

<details>
<summary>Release notes</summary>

_Sourced from [coverlet.collector's
releases](https://github.com/coverlet-coverage/coverlet/releases)._

## 10.1.1

### Improvements

- Add `IsReachable` to branch points, computed from the method's
control-flow graph, and exclude unreachable branches from
branch-coverage totals and from branch details in Cobertura, LCOV and
OpenCover reports
[#​2056](coverlet-coverage/coverlet#2056) by
@​pcshrosbree
- coverlet.MTP: Narrow Dynamic Exclude Filters for Loaded Assemblies
[#​2069](coverlet-coverage/coverlet#2069)

### Fixed

- Fix Regression Prevent invalid IL from branch trampolines
[#​2067](coverlet-coverage/coverlet#2067)
- Fix Regression coverlet.MTP does not instrument local functions
[#​2046](coverlet-coverage/coverlet#2046)

## Maintenance

- Update NuGet package versions
[#​2050](coverlet-coverage/coverlet#2050)

[Diff between 10.1.0 and
10.1.1](coverlet-coverage/coverlet@v10.1.0...v10.1.1)

Commits viewable in [compare
view](coverlet-coverage/coverlet@v10.1.0...v10.1.1).
</details>

Updated
[Microsoft.AspNetCore.Authentication.JwtBearer](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.Authentication.JwtBearer's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.AspNetCore.Mvc.Testing](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.Mvc.Testing's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated [Microsoft.AspNetCore.OpenApi](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.AspNetCore.OpenApi's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Pinned [Microsoft.EntityFrameworkCore](https://github.com/dotnet/dotnet)
at 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.EntityFrameworkCore's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.EntityFrameworkCore.Design](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.EntityFrameworkCore.Design's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.EntityFrameworkCore.Relational](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.EntityFrameworkCore.Relational's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated
[Microsoft.Extensions.ApiDescription.Server](https://github.com/dotnet/dotnet)
from 10.0.14 to 10.0.15.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Extensions.ApiDescription.Server's
releases](https://github.com/dotnet/dotnet/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/dotnet/dotnet/commits).
</details>

Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest)
from 18.11.0 to 18.12.0.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.NET.Test.Sdk's
releases](https://github.com/microsoft/vstest/releases)._

## 18.12.0

## Security fix

This release includes the fix for CVE-2026-105544, an elevation of
privilege vulnerability in the VSTest artifact post-processor. The
post-processor could consume a forged `executionComplete.json` written
by another local user, and then run attacker-controlled output handling.

Affected: `Microsoft.TestPlatform.CLI` 18.11.0 and earlier. Every
version from 18.11.1 on is fixed, including 18.12.0.

`Microsoft.TestPlatform.CLI` is the VSTest build that we ship into the
.NET SDK. The recommended way to get this fix is to update your .NET SDK
to the latest patched version, see the advisory for the SDK versions.

The fix is also released in the `Microsoft.TestPlatform.CLI` package,
for completeness. That package is rarely used directly. It is not a
dependency of `Microsoft.NET.Test.Sdk` or `Microsoft.TestPlatform`, so
those packages do not bring it in.

Details: microsoft/vstest#16654 and
dotnet/announcements#517

Using custom Docker images or Nano Server? See
microsoft/vstest#16652

## What's Changed
* Fix TestCaseStart/Stop events dropped for data-driven tests with
shared TestCase.Id by @​nohwnd in
microsoft/vstest#16033
* Stop the discovery manager factory from shadowing discoveryCriteria by
@​nohwnd in microsoft/vstest#16391
* Gate the HTTP link checker on a fingerprint of the broken links by
@​nohwnd in microsoft/vstest#16413
* Quote boolean conditions in shipped Microsoft.TestPlatform.targets by
@​nohwnd in microsoft/vstest#16404
* Obsolete API hygiene: the compatibility-safe changes by @​azat-msft in
microsoft/vstest#16420
* Add xxHash128 test ids, available but not default by @​azat-msft in
microsoft/vstest#16378
* Isolate attachment manager test temporary files by @​mmitche in
microsoft/vstest#16463
* Test ids report logger by @​azat-msft in
microsoft/vstest#16443
* Isolate code coverage files in published output by @​azat-msft in
microsoft/vstest#16483
* Preserve OutputType for Android test projects by @​jonathanpeppers in
microsoft/vstest#16496
* Fix dotnet host resolution under proot (ARM64/Termux) by @​azat-msft
in microsoft/vstest#16462
* Mark the xxHash128 test id API as experimental by @​azat-msft in
microsoft/vstest#16465
* Ship Microsoft.Diagnostics.NETCore.Client in Microsoft.TestPlatform
and Portable packages by @​nohwnd in
microsoft/vstest#16633
* Fix localized resource paths in CLI source-build/non-Windows packages
by @​nohwnd in microsoft/vstest#16644


**Full Changelog**:
microsoft/vstest@v18.11.0...v18.12.0



## 18.11.1

## Security fix

This release fixes CVE-2026-105544, an elevation of privilege
vulnerability in the VSTest artifact post-processor. The post-processor
could consume a forged `executionComplete.json` written by another local
user, and then run attacker-controlled output handling.

Affected: `Microsoft.TestPlatform.CLI` 18.11.0.
Fixed in: `Microsoft.TestPlatform.CLI` 18.11.1.

`Microsoft.TestPlatform.CLI` is the VSTest build that we ship into the
.NET SDK. The recommended way to get this fix is to update your .NET SDK
to the latest patched version, see the advisory for the SDK versions.

The fix is also released in the `Microsoft.TestPlatform.CLI` package,
for completeness. That package is rarely used directly. It is not a
dependency of `Microsoft.NET.Test.Sdk` or `Microsoft.TestPlatform`, so
those packages do not bring it in.

Details: microsoft/vstest#16654 and
dotnet/announcements#517

Using custom Docker images or Nano Server? See
microsoft/vstest#16652

## What's Changed
* Security fix for CVE-2026-105544, see
microsoft/vstest#16654
* Ship Microsoft.Diagnostics.NETCore.Client in Microsoft.TestPlatform
and Portable packages by @​nohwnd in
microsoft/vstest#16632
* Fix localized resource paths in CLI source-build packages by @​nohwnd
in microsoft/vstest#16643

**Full Changelog**:
microsoft/vstest@v18.11.0...v18.11.1

Commits viewable in [compare
view](microsoft/vstest@v18.11.0...v18.12.0).
</details>

Updated [Microsoft.OpenApi](https://github.com/Microsoft/OpenAPI.NET)
from 2.13.0 to 2.13.1.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.OpenApi's
releases](https://github.com/Microsoft/OpenAPI.NET/releases)._

## 2.13.1

##
[2.13.1](microsoft/OpenAPI.NET@v2.13.0...v2.13.1)
(2026-11-16)


### Bug Fixes

* **models:** preserve specification extensions in OpenApiPaths and
OpenApiResponses copy constructors
([#​3162](microsoft/OpenAPI.NET#3162))
([#​3163](microsoft/OpenAPI.NET#3163))
([3301ba7](microsoft/OpenAPI.NET@3301ba7))
* **models:** preserve tag collection types and comparers in copy
constructors
([#​3141](microsoft/OpenAPI.NET#3141))
([#​3145](microsoft/OpenAPI.NET#3145))
([aa5e2b5](microsoft/OpenAPI.NET@aa5e2b5))
* **models:** preserve tag collection types and comparers in
OpenApiDocument copy constructor
([aa5e2b5](microsoft/OpenAPI.NET@aa5e2b5))
* **reader:** backport external reference file loading to v2
([#​3174](microsoft/OpenAPI.NET#3174))
([cb3003a](microsoft/OpenAPI.NET@cb3003a))
* **reader:** backport external reference loading to v2
([cb3003a](microsoft/OpenAPI.NET@cb3003a))
* Support custom tag ordering and null assignment in
OpenApiOperation.Tags
([#​3128](microsoft/OpenAPI.NET#3128))
([#​3133](microsoft/OpenAPI.NET#3133))
([295c89c](microsoft/OpenAPI.NET@295c89c))
* support reinitializing OpenApiOperation.Tags to null and custom
comparers
([#​3116](microsoft/OpenAPI.NET#3116))
([#​3142](microsoft/OpenAPI.NET#3142))
([9cfcdd2](microsoft/OpenAPI.NET@9cfcdd2))
* **v2:** map OpenAPI 2.0 response schema type file to binary format
([#​3150](microsoft/OpenAPI.NET#3150))
([#​3151](microsoft/OpenAPI.NET#3151))
([4cf52e1](microsoft/OpenAPI.NET@4cf52e1))
* **v3:** retain full JSON pointer path on OpenAPI 3.0 schema references
([#​3155](microsoft/OpenAPI.NET#3155))
([#​3170](microsoft/OpenAPI.NET#3170))
([16969bc](microsoft/OpenAPI.NET@16969bc))

Commits viewable in [compare
view](microsoft/OpenAPI.NET@v2.13.0...v2.13.1).
</details>

Pinned
[Npgsql.EntityFrameworkCore.PostgreSQL](https://github.com/npgsql/efcore.pg)
at 10.0.4.

<details>
<summary>Release notes</summary>

_Sourced from [Npgsql.EntityFrameworkCore.PostgreSQL's
releases](https://github.com/npgsql/efcore.pg/releases)._

## 10.0.4

[Milestone
issue](https://github.com/npgsql/efcore.pg/milestone/79?closed=1)

## What's Changed
* [10.0] Backport regex operand parentheses fix by @​roji in
npgsql/efcore.pg#3928
* [10.0] Remove unused SSL setup from Windows CI by @​roji in
npgsql/efcore.pg#3931
* [10.0] Backport unnest type mapping inference fix by @​roji in
npgsql/efcore.pg#3945
* [10.0] Truncate sub-microsecond ticks when formatting TimeSpan as
interval by @​roji in npgsql/efcore.pg#3947
* [10.0] Preserve row value type mappings when rewriting expressions by
@​roji in npgsql/efcore.pg#3954
* [10.0] Fix Last() on primitive collections returning the first array
element by @​roji in npgsql/efcore.pg#3956
* [10.0] Configure row value regression tuple mapping locally by @​roji
in npgsql/efcore.pg#3960
* [10.0] Update EF Core and other dependencies by @​roji in
npgsql/efcore.pg#3963
* [10.0] Fix collection conversion with nullable element converters
(#​3965) by @​roji in npgsql/efcore.pg#3967
* [10.0] Fix Contains on an object collection over a value-converted
column (#​3961) by @​roji in
npgsql/efcore.pg#3970
* [10.0] Fix tsvector metadata cast for IReadOnlyList by @​roji in
npgsql/efcore.pg#3986
* [10.0] Fix explicit column types for owned JSON collections by @​roji
in npgsql/efcore.pg#3989
* [10.0] Prevent PadLeft/PadRight from truncating shorter target widths
by @​roji in npgsql/efcore.pg#3993
* [10.0] Fix array type inference for mixed collection types by @​roji
in npgsql/efcore.pg#3996
* [10.0] Fix null checks on unbounded NodaTime Interval bounds by @​roji
in npgsql/efcore.pg#4002
* [10.0] Backport fix for null propagation in date/time intervals by
@​roji in npgsql/efcore.pg#4015
* [10.0] Support System.Text.Json serialization of LTree by @​roji in
npgsql/efcore.pg#4010
* [10.0] Preserve array element converters with explicit column types by
@​roji in npgsql/efcore.pg#4011
* [10.0] Fix repeated seed-data updates for list properties by @​roji in
npgsql/efcore.pg#4029
* [10.0] Fix BCE NodaTime SQL literal formatting by @​roji in
npgsql/efcore.pg#4027
* [10.0] Preserve inherited HiLo sequences in model snapshots by @​roji
in npgsql/efcore.pg#4032
* [10.0] Fix date/time mapping round-tripping and cloning by @​roji in
npgsql/efcore.pg#4037
* [10.0] Fix Regex.Replace to replace all matches by @​roji in
npgsql/efcore.pg#4041
* [10.0] Restore raw JSON byte array mapping by @​roji in
npgsql/efcore.pg#4044
* [10.0] Translate ToString() on string expressions by @​roji in
npgsql/efcore.pg#4050
* [10.0] Own newly cloned connections by @​roji in
npgsql/efcore.pg#4056
* [10.0] Fix type mapping for derived tsquery parameters by @​roji in
npgsql/efcore.pg#4060
* [10.0] Fix precision-only numeric migration snapshot churn by @​roji
in npgsql/efcore.pg#4070
* [10.0] Fix byte-array projections from JSON collections by @​roji in
npgsql/efcore.pg#4073
* [10.0] Fix tsvector columns over JSON-mapped navigations/complex
properties by @​roji in npgsql/efcore.pg#4076
* [10.0] Fix hstore SQL literal generation for null and escaped values
by @​roji in npgsql/efcore.pg#4106
* [10.0] Fix TimeOnly.IsBetween for midnight-spanning ranges by @​roji
in npgsql/efcore.pg#4131
* [10.0] Parenthesize the item of ANY/ALL when its precedence requires
it by @​roji in npgsql/efcore.pg#4132
* [10.0] Format storage parameter values with the invariant culture by
@​roji in npgsql/efcore.pg#4133


**Full Changelog**:
npgsql/efcore.pg@v10.0.3...v10.0.4

Commits viewable in [compare
view](npgsql/efcore.pg@v10.0.3...v10.0.4).
</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

OpenAPI 2.0 response schema type: file is read as a plain string (format: binary is set only for parameters)

3 participants