Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 1, 2025

Summary

This PR implements support for the itemEncoding and prefixEncoding fields in OpenApiMediaType as defined in the OpenAPI 3.2.0 specification.

Changes

New Properties

  • itemEncoding (OpenApiEncoding?): An encoding object for items in an array schema
  • prefixEncoding (IList<OpenApiEncoding>?): An array of encoding objects for prefixItems in an array schema

Version-Specific Serialization

Following the pattern established for other 3.2.0 fields:

OpenAPI 3.2.0+: Fields are serialized as native properties

{
  "itemEncoding": {
    "contentType": "text/plain"
  },
  "prefixEncoding": [
    {
      "contentType": "application/json"
    }
  ]
}

OpenAPI 3.1 and earlier: Fields are serialized as x-oai- prefixed extensions

{
  "x-oai-itemEncoding": {
    "contentType": "text/plain"
  },
  "x-oai-prefixEncoding": [
    {
      "contentType": "application/json"
    }
  ]
}

Implementation Details

  1. Constants: Added ItemEncoding and PrefixEncoding to OpenApiConstants
  2. Model: Added properties to OpenApiMediaType with proper copy constructor support
  3. Serialization: Updated SerializeInternal to handle version-specific output
  4. Deserialization: Updated all version deserializers (v3.0, v3.1, v3.2) to read the fields
  5. Tests: Added comprehensive serialization tests for both v3.2 (native) and v3.1 (extension) formats
  6. Public API: Updated PublicApi.approved.txt to reflect the new public surface

Testing

All existing tests pass, plus 4 new tests covering:

  • itemEncoding serialization in v3.2 (native)
  • itemEncoding serialization in v3.1 (extension)
  • prefixEncoding serialization in v3.2 (native)
  • prefixEncoding serialization in v3.1 (extension)

Fixes

Resolves the issue by providing full support for these OAI 3.2.0 media type fields with backward compatibility for earlier versions.

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 33553 --endpoint 127.0.0.1:033553 --role client --parentprocessid 6047 --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 38053 --endpoint 127.0.0.1:038053 --role client --parentprocessid 11070 --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>add support for the mediaType itemEncoding and prefixEncoding fields</issue_title>
<issue_description>OAI 3.2.0 defines two new fields for media type.

  • itemEncoding (OpenAPIEncoding?)
  • prefixEncoding (OpenAPIEncoding[]?)

In both cases the fields need to be added to the model and serialization/deserialization should be updated.

When serializing to OAI 3.1.0 or lower, those properties should be prefixed with x-oai- so they are stored as extensions</issue_description>

<agent_instructions>make sure you also update the public api export</agent_instructions>

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

Fixes #10

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

Copilot AI and others added 2 commits October 1, 2025 18:05
…lization support

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] add support for the mediaType itemEncoding and prefixEncoding fields Add support for itemEncoding and prefixEncoding fields in OpenApiMediaType Oct 1, 2025
@Copilot Copilot AI requested a review from baywet October 1, 2025 18:14
Copilot finished work on behalf of baywet October 1, 2025 18:14
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.

add support for the mediaType itemEncoding and prefixEncoding fields
2 participants