Skip to content

Commit

Permalink
[IMP] base_rest: base_rest: Define the oauth2 redirect url into swagg…
Browse files Browse the repository at this point in the history
…er ui

Add support for oauth2 security scheme in the Swagger UI. If your openapi
specification contains a security scheme of type oauth2, the Swagger UI will
display a login button in the top right corner. In order to finalize the
login process, a redirect URL must be provided when initializing the Swagger
UI. The Swagger UI is now initialized with a `oauth2RedirectUrl` option that
references a oauth2-redirect.html file provided by the swagger-ui lib and served
by the current addon.
  • Loading branch information
lmignon committed Oct 7, 2023
1 parent 23dabc9 commit df102d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Empty file.
7 changes: 7 additions & 0 deletions base_rest/readme/newsfragments/379.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Add support for oauth2 security scheme in the Swagger UI. If your openapi
specification contains a security scheme of type oauth2, the Swagger UI will
display a login button in the top right corner. In order to finalize the
login process, a redirect URL must be provided when initializing the Swagger
UI. The Swagger UI is now initialized with a `oauth2RedirectUrl` option that
references a oauth2-redirect.html file provided by the swagger-ui lib and served
by the current addon.
3 changes: 3 additions & 0 deletions base_rest/static/src/js/swagger_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ odoo.define("base_rest.swagger_ui", function (require) {
$(".topbar").prepend(this.web_btn);
}
},
oauth2RedirectUrl:
window.location.origin +
"/base_rest/static/lib/swagger-ui-3.51.1/oauth2-redirect.html",
};
const config = this.$el.data("settings");
return Object.assign({}, defaults, config);
Expand Down

0 comments on commit df102d1

Please sign in to comment.