OpenAPI: Context.GetOrCreateSchemaAsync does not take CircularReferences into count.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
When you write a SchemaTransformer which unwraps an object (e.g. OptionalValues) the first thing someone would use is `Context.GetOrCreateSchemaAsync` with the underlying type as it generates the schema for you and will give a schema which will be either inlined or nested depending on it's metadata. The inner schema which is genrated also goes to it's transformers. This is the cause of this issue.
A references B
B references A
What will happen with Circular references
- Transformer transforms A which wraps B
- Context.GetOrCreateSchemaAsync(B)
- B has a property of type A
- Transformer transforms A which wraps B
- Context.GetOrCreateSchemaAsync(B)
- B has a property of type A
- Transformer transforms A which wraps B
- etc
See for a repro/workaround https://github.com/desjoerd/OptionalValues/pull/22
### Expected Behavior
It should track that it's generating or transforming a type. And give a reference to it instead of going for the "Unresolved" schema.
### Steps To Reproduce
See https://github.com/desjoerd/OptionalValues/pull/22
It's hard to create a explainable reproduce.
### Exceptions (if any)
_No response_
### .NET Version
.NET 10 RC2
### Anything else?
I would like to have a design session around Unresolved Schemas, resolved schemas and schema reference handling if possible, to squash this once and for all! 😊
Contributor guide
Assessment
This issue has not been assessed yet.