-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add openapi extensions "x-tokenName" (#763)
* add token_name to Oauth2 struct Setting x-tokenname makes it possible to choose which token to use * let the user choose what extension to enable * add extensions in all places required by spec Example of how to add extensions for oauth configuration. ```rs #[derive(Clone)] struct SecurityAddon; impl Modify for SecurityAddon { fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) { if let Some(components) = openapi.components.as_mut() { let mut oauth = OAuth2::new([Flow::AuthorizationCode(AuthorizationCode::new( "https://accounts.google.com/o/oauth2/auth", "https://oauth2.googleapis.com/token", Scopes::from_iter([("email", "use your email address"), ("openid", "openid")]), ))]); oauth.extensions = Some(HashMap::from_iter([( "x-tokenName".to_string(), Value::String("id_token".to_string()), )])); components.add_security_scheme("token", SecurityScheme::OAuth2(oauth)); } } } ```
- Loading branch information
1 parent
50db1b0
commit f43efc7
Showing
5 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters