def fix_security_scheme(openapi_schema: Dict[str, Any]) -> Dict[str, Any]:
    """Fix the security scheme definition to handle authentication properly.

    We'll completely replace the existing Auth0HTTPBearer security scheme with
    just the ApiKeyAuth scheme, ensuring the SDK only requires an API key.

    This function thoroughly removes any duplicated authentication parameters
    to avoid the "duplicate parameter" error in generated SDKs.
    """
    if "components" in openapi_schema and "securitySchemes" in openapi_schema["components"]:
        # Replace the security scheme to use only apiKey with header
        openapi_schema["components"]["securitySchemes"] = {
            "ApiKeyAuth": {
                "type": "apiKey",
                "in": "header",
                "name": "x-api-key",
                "description": "API key for authentication",
            }
        }

        # Process all paths to fix authentication
        for path, path_item in openapi_schema["paths"].items():
            for method, operation in path_item.items():
                if method.lower() in ["get", "post", "put", "delete", "patch"]:
                    # Replace any existing security with just the API key
                    operation["security"] = [{"ApiKeyAuth": []}]

                    # Remove all auth-related parameters from operations
                    # This is critical to avoid duplication with the security scheme
                    if "parameters" in operation:
                        operation["parameters"] = [
                            param
                            for param in operation["parameters"]
                            if not (
                                (
                                    param.get("name") == "Authorization"
                                    and param.get("in") == "header"
                                )
                                or (
                                    param.get("name") == "x-api-key" and param.get("in") == "header"
                                )
                            )
                        ]

    # Remove any global security definitions if they exist
    if "security" in openapi_schema:
        openapi_schema["security"] = [{"ApiKeyAuth": []}]

    return openapi_schema
Fix the security scheme definition to handle authentication properly.

    We'll completely replace the existing Auth0HTTPBearer security scheme with
    just the ApiKeyAuth scheme, ensuring the SDK only requires an API key.

    This function thoroughly removes any duplicated authentication parameters
    to avoid the "duplicate parameter" error in generated SDKs.
    
fern/scripts/generate_openapi.py