Skip to content

Commit

Permalink
Merge pull request openwallet-foundation#43 from sktston/feature/expo…
Browse files Browse the repository at this point in the history
…se_swagger

Expose the swagger doc through the ingress
  • Loading branch information
airoasis authored Mar 8, 2021
2 parents 18d5a57 + cb1949f commit a650ca5
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions aries_cloudagent/admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def is_unprotected_path(path: str):
"/ws", # ws handler checks authentication
]
or path.startswith("/static/swagger/")
or path.startswith("/agent/swagger-ui")
)

# If admin_api_key is None, then admin_insecure_mode must be set so
Expand Down Expand Up @@ -406,9 +407,24 @@ async def setup_context(request: web.Request, handler):
agent_label = self.context.settings.get("default_label")
version_string = f"v{__version__}"

setup_aiohttp_apispec(
app=app, title=agent_label, version=version_string, swagger_path="/api/doc"
)
# if it is the agent in k8s behind the nginx ingress
if agent_label == "ACA-Py Agent (Multi-Tenant)":
setup_aiohttp_apispec(
app=app,
title=agent_label,
version=version_string,
swagger_path="/agent/swagger-ui",
static_path="/agent/swagger-ui/static/swagger",
url="/agent/swagger-ui/swagger.json",
basePath="/agent/api"
)
else:
setup_aiohttp_apispec(
app=app,
title=agent_label,
version=version_string,
swagger_path="/api/doc"
)
app.on_startup.append(self.on_startup)

# ensure we always have status values
Expand Down

0 comments on commit a650ca5

Please sign in to comment.