Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 14, 2025

Adds an extension method to configure OpenAPI schema reference IDs using full type names (namespace + class name) instead of just the class name, resolving naming collisions when multiple types share the same name across different namespaces.

Changes

  • OpenApiExtensions.cs: Added UseFullTypeNameSchemaIds() extension method that configures CreateSchemaReferenceId to use Type.FullName, with + replaced by . for nested types
  • README.md: Added usage documentation with collision scenario example
  • Sample application: Added commented usage example

Usage

builder.Services.AddOpenApi(options =>
{
    options.UseFullTypeNameSchemaIds();
});

Without this extension, both MyApp.Models.User and MyApp.DTOs.User would generate a schema named "User", potentially causing conflicts. With the extension, they generate "MyApp.Models.User" and "MyApp.DTOs.User" respectively.

Notes

  • Opt-in extension method, maintains backward compatibility
  • Available for .NET 9.0+ only (within existing #if NET9_0_OR_GREATER block)
  • No test infrastructure exists for AspNetCore extensions
Original prompt

This section details on the original issue you should resolve

<issue_title>Add extension method to OpenApiOptions to use full type name in schema reference ID</issue_title>
<issue_description>### Summary

Add an extension method to OpenApiOptions in the TinyHelpers.AspNetCore package to allow using the full type name in schema reference IDs, improving schema uniqueness and resolving issues when multiple types have the same name.

Motivation

As suggested in dotnet/aspnetcore#64325 (comment), using full type names in OpenAPI schema references helps to avoid naming collisions and is especially useful for complex APIs with overlapping type names.

Proposed Solution

  • Implement an extension method for OpenApiOptions that configures the schema ID generation using the full type name (namespace + class).
  • Add usage documentation and an example.

References

Acceptance Criteria

  • Extension method implemented and unit tested
  • Example usage in the documentation
  • Backward compatibility verified
    </issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add extension method to OpenApiOptions for full type name in schema ID Add UseFullTypeNameSchemaIds extension for OpenAPI schema reference IDs Nov 14, 2025
Copilot AI requested a review from marcominerva November 14, 2025 11:44
@marcominerva marcominerva marked this pull request as ready for review November 20, 2025 15:35
@marcominerva marcominerva merged commit d83a64f into develop Dec 10, 2025
6 checks passed
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.

2 participants