Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 2, 2025

Description

This PR fixes a typo in the OpenAPI encoding deserializers where the field name was incorrectly set to "allowedReserved" instead of "allowReserved" (note the extra "d"). This bug prevented the allowReserved property from being properly deserialized from OpenAPI v3.0 and v3.1 documents.

According to the OpenAPI 3.0 specification and OpenAPI 3.1 specification, the correct field name is allowReserved (without the "d").

Changes

Fixed Deserializers

  • V3: src/Microsoft.OpenApi/Reader/V3/OpenApiEncodingDeserializer.cs - Changed "allowedReserved" to "allowReserved" (line 47)
  • V31: src/Microsoft.OpenApi/Reader/V31/OpenApiEncodingDeserializer.cs - Changed "allowedReserved" to "allowReserved" (line 46)

Added Regression Tests

To prevent future regressions, this PR adds unit tests that specifically verify the allowReserved field is correctly deserialized:

  • test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs - Added ParseEncodingWithAllowReservedShouldSucceed test
  • test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiEncodingTests.cs - Created new test file with ParseEncodingWithAllowReservedShouldSucceed test
  • Sample YAML files demonstrating the allowReserved field for both V3 and V31

Example

Before this fix, the following OpenAPI document would fail to deserialize the allowReserved property:

openapi: 3.0.0
paths:
  /upload:
    post:
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
            encoding:
              id:
                contentType: application/x-www-form-urlencoded
                allowReserved: true  # This was ignored due to the typo

After this fix, the AllowReserved property is correctly set to true on the deserialized OpenApiEncoding object.

Testing

  • All existing tests pass (1,177 tests total)
  • New tests specifically validate allowReserved deserialization for both V3 and V31

Fixes #[issue_number]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.org926f4f21-88e7-4dc5-bf88-6c529bb77844
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/OpenAPI.NET/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/bin/Debug/net8.0/Microsoft.OpenApi.Hidi.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/OpenAPI.NET/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/bin/Debug/net8.0/Microsoft.OpenApi.Hidi.Tests.deps.json /home/REDACTED/work/OpenAPI.NET/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/bin/Debug/net8.0/testhost.dll --port 43161 --endpoint 127.0.0.1:043161 --role client --parentprocessid 4655 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/OpenAPI.NET/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/bin/Debug/net8.0/Microsoft.OpenApi.Hidi.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/OpenAPI.NET/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/bin/Debug/net8.0/Microsoft.OpenApi.Hidi.Tests.deps.json /home/REDACTED/work/OpenAPI.NET/OpenAPI.NET/test/Microsoft.OpenApi.Hidi.Tests/bin/Debug/net8.0/testhost.dll --port 46779 --endpoint 127.0.0.1:046779 --role client --parentprocessid 9482 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>OpenAPIEncoding property is wrongly "allowedReserved" instead of "allowReserved" in v3 and V31 deserialization</issue_title>
<issue_description>Describe the bug

The deserialization key for the property "allowReserved" is "allowedReserved" which is a typo in v3 and v31. It should be "allowReserved" instead.

Also make sure to add unit test to prevent any further regression.
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #2517

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…egression tests

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] OpenAPIEncoding property is wrongly "allowedReserved" instead of "allowReserved" in v3 and V31 deserialization Fix allowReserved typo in OpenAPIEncoding deserializers for v3 and v31 Oct 2, 2025
@Copilot Copilot AI requested a review from baywet October 2, 2025 16:51
Copilot finished work on behalf of baywet October 2, 2025 16:51
@baywet baywet marked this pull request as ready for review October 2, 2025 16:57
@baywet baywet requested a review from a team as a code owner October 2, 2025 16:57
@baywet baywet enabled auto-merge October 2, 2025 16:57
Copy link

sonarqubecloud bot commented Oct 2, 2025

Copy link
Member

@MIchaelMainer MIchaelMainer left a comment

Choose a reason for hiding this comment

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

LGTM

@baywet baywet disabled auto-merge October 2, 2025 18:28
@baywet baywet enabled auto-merge October 2, 2025 18:29
@baywet baywet disabled auto-merge October 2, 2025 18:30
@baywet baywet enabled auto-merge October 2, 2025 18:33
@baywet baywet merged commit 43282ec into main Oct 2, 2025
24 checks passed
@baywet baywet deleted the copilot/fix-71c49c13-7554-4ca2-abbe-930e2c52f2c2 branch October 2, 2025 18:44
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.

OpenAPIEncoding property is wrongly "allowedReserved" instead of "allowReserved" in v3 and V31 deserialization

4 participants