Repository navigation
Fix OpenAPI schema ID collisions for duplicate type names - #66937
Bellambharath wants to merge 1 commit into
Conversation
Fixes dotnet#64325 When two different types resolve to the same schema ID (e.g. same class name in different namespaces), both end up registered under the same key in the OpenAPI components section — last one wins and the schema for the first type just disappears silently. This adds a ConcurrentDictionary<string, Type> (_schemaIdToType) that tracks which type owns each schema ID. If a new type comes in with a colliding ID, we append a numeric suffix (2, 3, ...) until we find a slot that's free. Same type always gets the same ID back, so repeated calls are stable.
|
Thanks for your PR, @Bellambharath. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
why does this PR removes a lot of existing comments @Bellambharath ? or is that diff only visible until rebased ? |
| }, | ||
| }; | ||
|
|
||
| // Using JsonArray inline causes the compile to pick the generic Add<T>() overload |
There was a problem hiding this comment.
Consider reverting the removal of comments.
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
|
@Youssef1313 the removal of duplicate created a serious bug for teams that needs to expose an openapi schema with similar names for sub entity |
Summary
Testing
otnet test src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Microsoft.AspNetCore.OpenApi.Tests.csproj --filter "FullyQualifiedName~CreateSchemaReferenceIdTests" -p:UseIsNativeAssets=false
Fixes #64325