Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 1, 2025

Successfully implemented support for the mediaType itemSchema property (OAI 3.2.0)

Summary of Changes

Core Implementation

  • ✅ Added IOpenApiSchema? ItemSchema property to OpenApiMediaType class
  • ✅ Added ItemSchema = "itemSchema" constant to OpenApiConstants
  • ✅ Updated SerializeInternal method to:
    • Write native itemSchema property for OpenAPI 3.2.0+
    • Write x-oai-itemSchema extension for OpenAPI 3.1.0 and 3.0.0 (backward compatibility)
  • ✅ Updated copy constructor to clone ItemSchema property

Deserialization Support

  • ✅ Updated V32 deserializer to read native itemSchema property
  • ✅ Updated V31 deserializer to read x-oai-itemSchema extension and map to ItemSchema property
  • ✅ Updated V3 deserializer to read x-oai-itemSchema extension and map to ItemSchema property

Testing

  • ✅ Added serialization tests for all OpenAPI versions (3.0, 3.1, 3.2)
  • ✅ Added deserialization tests for V31 and V32
  • ✅ Added copy constructor test for ItemSchema property
  • ✅ Created sample YAML files for test cases
  • ✅ Updated PublicApi.approved.txt to reflect new public API surface
  • ✅ Replaced FluentAssertions with Assert.Equivalent in reader tests
  • ✅ Using JsonNode.DeepEquals for JSON comparison in serialization tests

Test Results

  • ✅ All 908 tests passing in Microsoft.OpenApi.Tests
  • ✅ All 348 tests passing in Microsoft.OpenApi.Readers.Tests
  • ✅ All 54 tests passing in Microsoft.OpenApi.Hidi.Tests
  • Total: 1,310 tests passing, 0 failing

Code Review Feedback Addressed

  • ✅ Use WriteOptionalObject for x-oai-itemSchema serialization
  • ✅ Replace Should().BeEquivalentTo() with Assert.Equivalent() in V31 and V32 tests
  • ✅ Replace Assert.Equal() with JsonNode.DeepEquals() for JSON comparison

Files Modified (11 files)

  • src/Microsoft.OpenApi/Models/OpenApiConstants.cs - Added constant
  • src/Microsoft.OpenApi/Models/OpenApiMediaType.cs - Added property and serialization logic
  • src/Microsoft.OpenApi/Reader/V3/OpenApiMediaTypeDeserializer.cs - Added deserialization
  • src/Microsoft.OpenApi/Reader/V31/OpenApiMediaTypeDeserializer.cs - Added deserialization
  • src/Microsoft.OpenApi/Reader/V32/OpenApiMediaTypeDeserializer.cs - Added deserialization
  • test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs - Added tests
  • test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt - Updated public API
  • test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiMediaTypeTests.cs - Added test
  • test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiMediaType/mediaTypeWithXOaiItemSchema.yaml - Sample
  • test/Microsoft.OpenApi.Readers.Tests/V32Tests/OpenApiMediaTypeTests.cs - Added test
  • test/Microsoft.OpenApi.Readers.Tests/V32Tests/Samples/OpenApiMediaType/mediaTypeWithItemSchema.yaml - Sample

Implementation follows OAS 3.2.0 specification and maintains backward compatibility with earlier versions.

Original prompt

This section details on the original issue you should resolve

<issue_title>add support for the mediaType itemSchema property</issue_title>
<issue_description>OAI 3.2.0 defines a new itemSchema property on the media type object.

This property is of type IOpenAPISchema? and serialization/deserialization should be updates to account for this new field.

When serializing to version 3.1.0, the property name should be prefixed with x-oai- so it's treated as an extension.</issue_description>

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

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

Fixes #9

💬 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 support for the mediaType itemSchema property Add support for mediaType itemSchema property (OAS 3.2.0) Oct 1, 2025
@Copilot Copilot AI requested a review from baywet October 1, 2025 13:26
Copilot finished work on behalf of baywet October 1, 2025 13:26
@Copilot Copilot AI requested a review from baywet October 1, 2025 17:07
Copilot finished work on behalf of baywet October 1, 2025 17:07
@baywet baywet marked this pull request as ready for review October 1, 2025 17:54
@baywet baywet enabled auto-merge October 1, 2025 17:54
@baywet baywet merged commit ced60c9 into feat/oai-3-2-support Oct 1, 2025
6 checks passed
@baywet baywet deleted the copilot/fix-3c317057-370e-4d33-8171-b4b6862334fb branch October 1, 2025 20:46
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 itemSchema property

3 participants