-
Notifications
You must be signed in to change notification settings - Fork 10.4k
How can I elide a Result<T>
type in Microsoft.AspNetCore.OpenApi
#63495
-
Can anyone help me find the best approach for the following problem with the newer OpenAPI document generation in aspnetcore.
We have a custom generic result type, Result<T>
, and we would like our endpoints to be documented, but automatically elide this type in the document schema, i.e. if I return a Result<Person>
from an endpoint, I'd like the document to say that the endpoint returns a Person
, not a Result<Person>
.
I have played about with implementations of IOpenApiOperationTransformer, IOpenApiSchemaTransformer, IOpenApiDocumentTransformer
, but cannot get this to work 😅 The closest I've got is correcting the endpoint return types in the document, but not removing the redundant Result<T>
schema definitions.
Can anyone help me or give me some pointers 🙂
Beta Was this translation helpful? Give feedback.
All reactions
The approach in #63473 (comment) (well, something based on it) might be want you want.
Replies: 1 comment 1 reply
-
The approach in #63473 (comment) (well, something based on it) might be want you want.
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1
-
@martincostello that's exactly what I'm after, and it answers a question I had when trying to build this which is - how can I get the underlying schema from the context, and the answer is wait for aspnetcore 10 which ships context.GetOrCreateSchemaAsync(underlyingType)
.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1