mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 21:11:53 +00:00
feat(api): show only production URL in API reference playground
This commit is contained in:
@@ -156,45 +156,19 @@ def add_api_servers(result, generator, request, public): # noqa: F841
|
||||
"""
|
||||
Add servers configuration to OpenAPI spec for Mintlify API playground.
|
||||
This enables the "Try it out" feature in the documentation.
|
||||
Dynamically determines the server URL based on the request.
|
||||
Only adds the production URL to ensure consistent documentation.
|
||||
"""
|
||||
if not isinstance(result, dict):
|
||||
return result
|
||||
|
||||
# Add servers array if not already present
|
||||
if "servers" not in result:
|
||||
servers = []
|
||||
|
||||
# Try to get the current server URL from the request
|
||||
if request:
|
||||
scheme = request.scheme # http or https
|
||||
host = request.get_host() # e.g., localhost:8080 or api.prowler.com
|
||||
|
||||
# Determine description based on host
|
||||
if "localhost" in host or "127.0.0.1" in host:
|
||||
description = "Local Development Server"
|
||||
elif "dev" in host or "staging" in host:
|
||||
description = "Development/Staging API"
|
||||
else:
|
||||
description = "Prowler Cloud API"
|
||||
|
||||
servers.append(
|
||||
{
|
||||
"url": f"{scheme}://{host}",
|
||||
"description": description,
|
||||
}
|
||||
)
|
||||
|
||||
# Always add production as fallback/alternative
|
||||
if not servers or (request and "prowler.com" not in request.get_host()):
|
||||
servers.append(
|
||||
{
|
||||
"url": "https://api.prowler.com",
|
||||
"description": "Prowler Cloud API (Production)",
|
||||
}
|
||||
)
|
||||
|
||||
result["servers"] = servers
|
||||
result["servers"] = [
|
||||
{
|
||||
"url": "https://api.prowler.com",
|
||||
"description": "Prowler Cloud API",
|
||||
}
|
||||
]
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -19095,7 +19095,5 @@ tags:
|
||||
alternative to the Mutelist Processor if you need to mute specific findings across
|
||||
your tenant with a specific reason.
|
||||
servers:
|
||||
- url: http://localhost:8080
|
||||
description: Local Development Server
|
||||
- url: https://api.prowler.com
|
||||
description: Prowler Cloud API (Production)
|
||||
description: Prowler Cloud API
|
||||
|
||||
Reference in New Issue
Block a user