feat(api): show only production URL in API reference playground

This commit is contained in:
Andoni A.
2025-11-12 09:30:26 +01:00
parent 6a876a3205
commit 60350794da
2 changed files with 8 additions and 36 deletions
+7 -33
View File
@@ -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
+1 -3
View File
@@ -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