-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Accessing State
in OpenApiFromRequest
Similar to FromRequest
#151
Comments
Hey, sorry for the late reply. But the I see your MR got merged. So if this issue is no longer needed, you can close it. |
Hey @ralpha thx for your response yes the PR got merged, but the issue is still here So the way to go would be to use the Rocket Config file or something simmilar that can be accesed via the Compile time if i am right? |
You can do something during run time too, but although a bunch is done during compile time. But what exactly do you want to do? You want to change the OpenApi file depending on the okapi/examples/custom_schema/src/main.rs Line 50 in 5614a85
But you can even replace the mount_endpoints_and_merged_docs! to get even more control.Line 170 in 5614a85
Line 164-168 creates all endpoint links. Line 170-173 merges everything into 1 spec. Line 175-182 mount so the openapi.json file is added to Rocket.
So if you want change any of that you can just create your own macro. But if you describe your problem a bit more, I might be able to point you to exactly to what you can do. |
Also does the https://github.com/GREsau/okapi/tree/master/examples/secure_request_guard example not describe what you want to do? |
Hello
rocket_okapi
team,I'm currently working on the
zitadel-rust
project and generating OpenAPI documentation using theOpenApiFromRequest
trait. You can find the relevant PR here: smartive/zitadel-rust#559.In this project, I need to configure the
SecurityScheme
for OpenID Connect, and the authority URL for this configuration is stored in Rocket'sState
.In a typical request guard implementation using
FromRequest
, I can access therequest
object and retrieve the configuration fromState
like this:However, when working within the
OpenApiFromRequest
trait, I haven't found a way to similarly access therequest
object orState
to retrieve the configuration data. Currently, I'm usingfigment
to extract the configuration, like this:But I would prefer to directly access the
State
via therequest
, similar to how it's done inFromRequest
, to keep consistency and avoid duplicating configuration extraction logic.My Question:
Is it possible to access the
request
object withinOpenApiFromRequest
, or is there another recommended way to retrieve theState
while generating OpenAPI documentation withrocket_okapi
?Thank you for your assistance!
The text was updated successfully, but these errors were encountered: