You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
InvalidOperationException when using GetOrCreateSchemaAsync with inner references #64252
While trying to use context.GetOrCreateSchemaAsync() I'm running into the following exception:
InvalidOperationException: The input schema must be an OpenApiSchema or OpenApiSchemaReference.
Microsoft.AspNetCore.OpenApi.OpenApiSchemaService.UnwrapOpenApiSchema(IOpenApiSchema sourceSchema)
This happens because it's trying to get the Target of a schema reference, but that returns null.
After some debugging I found that the target was null because OpenApiWorkspace._IOpenApiReferenceableRegistry had part of the schemas stored with keys with the base uri concatenated twice, for example: https://openapi.net/fa86ef4d-6f86-4937-9dee-98962f2eb26b#/components/schemas/https://openapi.net/fa86ef4d-6f86-4937-9dee-98962f2eb26b/components/schemas/SchemaX.
Open API document is generated correctly without errors.
Steps To Reproduce
Unfortunately (or fortunately) I am having a hard time reproducing this in a minimal project, but I think looking at the code the issue is clear.
Exceptions (if any)
InvalidOperationException: The input schema must be an OpenApiSchema or OpenApiSchemaReference.
Microsoft.AspNetCore.OpenApi.OpenApiSchemaService.UnwrapOpenApiSchema(IOpenApiSchema sourceSchema)
It looks like this is actually a duplicate of #63598 , which I hadn't found while creating this.
I will therefore close this and add more details to that one.
Activity
lauraneto commentedon Nov 6, 2025
It looks like this is actually a duplicate of #63598 , which I hadn't found while creating this.
I will therefore close this and add more details to that one.