def test_parse_spec_with_global_auth_scheme(openapi_spec_generator):
  """Test parsing with a global security scheme."""
  openapi_spec = create_minimal_openapi_spec()
  openapi_spec["security"] = [{"api_key": []}]
  openapi_spec["components"] = {
      "securitySchemes": {
          "api_key": {"type": "apiKey", "in": "header", "name": "X-API-Key"}
      }
  }

  parsed_operations = openapi_spec_generator.parse(openapi_spec)
  op = parsed_operations[0]

  assert len(parsed_operations) == 1
  assert op.auth_scheme is not None
  assert op.auth_scheme.type_.value == "apiKey"
Test parsing with a global security scheme.
tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py