Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 27, 2025

This PR implements support for the new summary field in response objects as defined in OpenAPI Specification 3.2.0.

Changes Made

Core Implementation

  • Added Summary property to OpenApiResponse class implementing IOpenApiSummarizedElement
  • Updated IOpenApiResponse interface to derive from IOpenApiSummarizedElement making Summary part of the interface contract
  • Updated OpenApiResponseReference to properly delegate the Summary property to its target
  • Modified response copy constructors to handle the new Summary field

Version-Specific Serialization

The implementation follows the specification requirements for backward compatibility:

OpenAPI 3.2+: Summary is serialized as a standard field

{
  "summary": "Successful response",
  "description": "A detailed description"
}

OpenAPI 3.1 and earlier: Summary is serialized as an extension field using the x-oai- prefix

{
  "description": "A detailed description", 
  "x-oai-summary": "Successful response"
}

Deserialization Support

  • V3.2 deserializer: Handles direct "summary" field parsing
  • V3.1 & V3.0 deserializers: Handles "x-oai-summary" extension field parsing with fallback to regular extensions

Testing

  • Added comprehensive serialization tests for all OpenAPI versions
  • Added deserialization tests with sample YAML documents
  • Updated existing reference tests to handle the new Summary property
  • All 67 existing response-related tests continue to pass

Usage Example

// Summary is now part of the IOpenApiResponse interface contract
IOpenApiResponse response = new OpenApiResponse 
{
    Summary = "Operation completed successfully",
    Description = "The requested operation has been completed",
    Content = new Dictionary<string, OpenApiMediaType>
    {
        ["application/json"] = new OpenApiMediaType 
        { 
            Schema = new OpenApiSchema { Type = JsonSchemaType.Object } 
        }
    }
};

// Access Summary directly through the interface
Console.WriteLine($"Summary: {response.Summary}");

// Works with all OpenAPI versions with appropriate serialization
var v32Json = await response.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_2);
var v31Json = await response.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_1);

This implementation maintains full backward compatibility while enabling the new summary functionality for OpenAPI 3.2.0 documents. The interface hierarchy now properly expresses that all response objects have a Summary property.

Fixes #17

Original prompt

This section details on the original issue you should resolve

<issue_title>add support for response summary</issue_title>
<issue_description>OAS 3.2.0 defines a new summary field

We should add the new field to the model, implement serialization/deserialization for it.

When serializing to OAS 3.10, the property should be using an x-oai- prefix to make it an extension</issue_description>

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

Fixes #17

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] add support for response summary Add support for response summary in OpenAPI 3.2.0 Sep 27, 2025
@Copilot Copilot AI requested a review from baywet September 27, 2025 12:11
Copilot finished work on behalf of baywet September 27, 2025 12:11
@baywet
Copy link

baywet commented Sep 27, 2025

@copilot also update the IOpenAPIResponse interface to derive from ISummarizedElement

Copy link
Author

Copilot AI commented Sep 27, 2025

@copilot also update the IOpenAPIResponse interface to derive from ISummarizedElement

Updated the IOpenApiResponse interface to derive from IOpenApiSummarizedElement. This makes the Summary property part of the interface contract for all response objects. The implementation has been simplified accordingly, and all tests continue to pass. (commit 8f5c5cb)

Copilot finished work on behalf of baywet September 27, 2025 21:08
@baywet baywet marked this pull request as ready for review September 29, 2025 16:01
@baywet baywet enabled auto-merge (squash) September 29, 2025 16:02
@baywet baywet merged commit 2e2c3cf into feat/oai-3-2-support Sep 29, 2025
4 of 6 checks passed
@baywet baywet deleted the copilot/fix-55e26a3a-d7a0-498c-be08-65c41726cec3 branch September 29, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

add support for response summary

3 participants