Skip to content

Commit c326d76

Browse files
committed
Make the security schemes relative in the static OpenAPI spec
1 parent dc2ff76 commit c326d76

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

crates/handlers/src/admin/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,13 @@ fn oauth_security_scheme(url_builder: Option<&UrlBuilder>) -> SecurityScheme {
102102
url_builder.oauth_token_endpoint().to_string(),
103103
)
104104
} else {
105+
// This is a dirty fix for Swagger UI: when it joins the URLs with the
106+
// base URL, if the path starts with a slash, it will go to the root of
107+
// the domain instead of the API root.
108+
// It works if we make it explicitly relative
105109
(
106-
OAuth2AuthorizationEndpoint::PATH.to_owned(),
107-
OAuth2TokenEndpoint::PATH.to_owned(),
110+
format!(".{}", OAuth2AuthorizationEndpoint::PATH),
111+
format!(".{}", OAuth2TokenEndpoint::PATH),
108112
)
109113
};
110114

docs/api/spec.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,16 +2527,16 @@
25272527
"type": "oauth2",
25282528
"flows": {
25292529
"clientCredentials": {
2530-
"refreshUrl": "/oauth2/token",
2531-
"tokenUrl": "/oauth2/token",
2530+
"refreshUrl": "./oauth2/token",
2531+
"tokenUrl": "./oauth2/token",
25322532
"scopes": {
25332533
"urn:mas:admin": "Grant access to the admin API"
25342534
}
25352535
},
25362536
"authorizationCode": {
2537-
"authorizationUrl": "/authorize",
2538-
"tokenUrl": "/oauth2/token",
2539-
"refreshUrl": "/oauth2/token",
2537+
"authorizationUrl": "./authorize",
2538+
"tokenUrl": "./oauth2/token",
2539+
"refreshUrl": "./oauth2/token",
25402540
"scopes": {
25412541
"urn:mas:admin": "Grant access to the admin API"
25422542
}

0 commit comments

Comments
 (0)