Skip to content

Access OpenAPI description in handler #1064

Answered by juhaku
bachp asked this question in Q&A
Discussion options

You must be logged in to vote

There are 2 ways around this.

  1. Pass around the OpenApi type by some means. E.g. via global state or whatever state mechanism your framework will support.
  2. The #[utoipa::path(...)] macro will create a meta struct called __path_get_hello for the annotated function. In general in form of __path_{function_name}. Thus you could directly call this struct with __path_get_hello::operation() to get the generated operation schema to access it's content. However there is no way to change this content here.

Only way to change the content is to access via OpenApi directly or registered Modify trait.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bachp
Comment options

@juhaku
Comment options

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