Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions robyn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ def _add_openapi_routes(self, auth_required: bool = False):
logger.error("No openAPI")
return

if self.authentication_handler:
# self.authentication_handler.token_getter
self.openapi.add_global_security_scheme(name="bearerAuth", scheme={"type": "http", "scheme": "bearer"})

Comment on lines +269 to +272
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and what would be the other kinds of auth here?

self.router.prepare_routes_openapi(self.openapi, self.included_routers)

self.add_route(
Expand Down
10 changes: 10 additions & 0 deletions robyn/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,18 @@ def __post_init__(self):
"components": asdict(self.info.components),
"servers": [asdict(server) for server in self.info.servers],
"externalDocs": asdict(self.info.externalDocs) if self.info.externalDocs.url else None,
"security": [],
}

def add_global_security_scheme(self, name: str, scheme: dict):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where will this be called?

"""
Adds a security scheme to the OpenAPI spec.
@param name: str The name of the security scheme.
@param scheme: dict The security scheme object to be added.
"""
self.openapi_spec["components"]["securitySchemes"][name] = scheme
self.openapi_spec["security"].append({name: []})

def add_openapi_path_obj(self, route_type: str, endpoint: str, openapi_name: str, openapi_tags: List[str], handler: Callable):
"""
Adds the given path to openapi spec
Expand Down
Loading