Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How can I elide a Result<T> type in Microsoft.AspNetCore.OpenApi #63495

Answered by martincostello
slang25 asked this question in Q&A
Discussion options

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 🙂

You must be logged in to vote

The approach in #63473 (comment) (well, something based on it) might be want you want.

Replies: 1 comment 1 reply

Comment options

The approach in #63473 (comment) (well, something based on it) might be want you want.

You must be logged in to vote
1 reply
Comment options

@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!

Answer selected by slang25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /