Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 9, 2025

Overview

This PR implements the missing encoding, itemEncoding, and prefixEncoding fields for the OpenApiEncoding class as specified in the OpenAPI 3.2.0 specification.

Problem

The OpenApiEncoding class was missing several fields from the OpenAPI 3.2.0 specification:

  • encoding: A dictionary that allows encoding objects to have their own nested encoding specifications, creating a recursive structure similar to how the OpenApiMediaType class has an encoding dictionary
  • itemEncoding: Encoding object for array items
  • prefixEncoding: Encoding objects for tuple-style arrays

According to the OpenAPI 3.2.0 spec, the Encoding Object should support these nested encoding configurations to handle complex data structures.

Solution

Added support for all three fields with the following changes:

  1. Model: Added three new properties to OpenApiEncoding class:
    • Encoding as IDictionary<string, OpenApiEncoding>?
    • ItemEncoding as OpenApiEncoding?
    • PrefixEncoding as IList<OpenApiEncoding>?
  2. Copy Constructor: Implemented deep copy logic for all new properties to ensure proper object cloning
  3. Version-Aware Serialization:
    • For OpenAPI 3.2+: Serializes as native fields (encoding, itemEncoding, prefixEncoding)
    • For OpenAPI 3.1 and earlier: Serializes as extension fields (x-oai-encoding, x-oai-itemEncoding, x-oai-prefixEncoding)
  4. Deserialization: Added V32 deserializer support to parse all three fields from YAML/JSON documents
  5. Tests: Added comprehensive tests for both deserialization and serialization in JSON and YAML formats, including backward compatibility tests

Example Usage

contentType: application/json
encoding:
  nestedField:
    contentType: application/xml
    style: form
    explode: true
  anotherField:
    contentType: text/plain
itemEncoding:
  contentType: application/xml
  style: form
prefixEncoding:
  - contentType: text/plain
    style: simple
  - contentType: application/octet-stream

Testing

  • ✅ All 1457 tests pass (398 in Readers.Tests, 1005 in Tests, 54 in Hidi.Tests)
  • ✅ Added 5 new tests covering deserialization and serialization scenarios for all new fields
  • ✅ Added backward compatibility test confirming v3.1 serialization uses x-oai-* extensions
  • ✅ CodeQL security scan: 0 vulnerabilities
  • ✅ Updated public API approval file

Breaking Changes

None. This is a backward-compatible addition that only affects OpenAPI 3.2 documents with nested encoding structures. For older versions, the new fields are automatically serialized as extensions to maintain compatibility.

Fixes #51

Original prompt

This section details on the original issue you should resolve

<issue_title>Encoding Object is missing fields</issue_title>
<issue_description>In 3.2.0 the encoding object also has:

  • encoding Dictionary<string, Encoding>
  • prefixEncoding Encoding[]
  • itemEncoding Encoding

We need to add the fields, serialization, deserialization and corresponding unit tests.</issue_description>

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

Fixes #51


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

@Copilot Copilot AI changed the title [WIP] Add missing fields to encoding object Add encoding Dictionary field to OpenApiEncoding class for OpenAPI 3.2.0 support Oct 9, 2025
@Copilot Copilot AI requested a review from baywet October 9, 2025 18:23
Copilot finished work on behalf of baywet October 9, 2025 18:23
@baywet
Copy link

baywet commented Oct 9, 2025

@copilot implement the requested changes

Copy link
Author

Copilot AI commented Oct 9, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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

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

@Copilot Copilot AI changed the title Add encoding Dictionary field to OpenApiEncoding class for OpenAPI 3.2.0 support Add encoding, itemEncoding, and prefixEncoding fields to OpenApiEncoding class for OpenAPI 3.2.0 support Oct 9, 2025
@Copilot Copilot AI requested a review from baywet October 9, 2025 19:22
Copilot finished work on behalf of baywet October 9, 2025 19:22
@baywet baywet marked this pull request as ready for review October 9, 2025 23:22
@baywet baywet enabled auto-merge October 9, 2025 23:22
@baywet
Copy link

baywet commented Oct 10, 2025

@copilot run the following commands and commit the changed performance reports, do nothing else

cd performance/benchmark
dotnet run -c Release

@Copilot Copilot AI requested a review from baywet October 10, 2025 01:06
Copilot finished work on behalf of baywet October 10, 2025 01:06
@baywet baywet merged commit aae50eb into feat/oai-3-2-support Oct 10, 2025
8 checks passed
@baywet baywet deleted the copilot/add-encoding-object-fields branch October 10, 2025 12:32
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.

Encoding Object is missing fields

3 participants