{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google-firebase/json-schema/google-firebase-test-ruleset-request-schema.json",
  "title": "TestRulesetRequest",
  "description": "The request for FirebaseRulesService.TestRuleset.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-firebase-firebaserules-projects-api-openapi.yml#/components/schemas/TestRulesetRequest",
  "properties": {
    "testSuite": {
      "$ref": "#/$defs/TestSuite",
      "description": "Required. The tests to execute against the `Source`. When `Source` is provided inline, the test cases will only be run if the `Source` is syntactically and semantically valid. Inline `TestSuite` to run."
    },
    "source": {
      "$ref": "#/$defs/Source",
      "description": "Optional. Optional `Source` to be checked for correctness. This field must not be set when the resource name refers to a `Ruleset`."
    }
  },
  "type": "object",
  "$defs": {
    "Arg": {
      "description": "Arg matchers for the mock function.",
      "type": "object",
      "properties": {
        "exactValue": {
          "description": "Argument exactly matches value provided."
        },
        "anyValue": {
          "$ref": "#/$defs/Empty",
          "description": "Argument matches any value provided."
        }
      }
    },
    "Empty": {
      "properties": {},
      "description": "A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }",
      "type": "object"
    },
    "File": {
      "properties": {
        "fingerprint": {
          "format": "byte",
          "type": "string",
          "description": "Fingerprint (e.g. github sha) associated with the `File`."
        },
        "name": {
          "description": "Required. File name.",
          "type": "string"
        },
        "content": {
          "description": "Required. Textual Content.",
          "type": "string"
        }
      },
      "description": "`File` containing source content.",
      "type": "object"
    },
    "FunctionMock": {
      "description": "Mock function definition. Mocks must refer to a function declared by the target service. The type of the function args and result will be inferred at test time. If either the arg or result values are not compatible with function type declaration, the request will be considered invalid. More than one `FunctionMock` may be provided for a given function name so long as the `Arg` matchers are distinct. There may be only one function for a given overload where all `Arg` values are `Arg.any_value`.",
      "properties": {
        "args": {
          "items": {
            "$ref": "#/$defs/Arg"
          },
          "description": "The list of `Arg` values to match. The order in which the arguments are provided is the order in which they must appear in the function invocation.",
          "type": "array"
        },
        "result": {
          "$ref": "#/$defs/Result",
          "description": "The mock result of the function call."
        },
        "function": {
          "description": "The name of the function. The function name must match one provided by a service declaration.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "Result": {
      "type": "object",
      "properties": {
        "undefined": {
          "$ref": "#/$defs/Empty",
          "description": "The result is undefined, meaning the result could not be computed."
        },
        "value": {
          "description": "The result is an actual value. The type of the value must match that of the type declared by the service."
        }
      },
      "description": "Possible result values from the function mock invocation."
    },
    "Source": {
      "description": "`Source` is one or more `File` messages comprising a logical set of rules.",
      "type": "object",
      "properties": {
        "files": {
          "description": "Required. `File` set constituting the `Source` bundle.",
          "items": {
            "$ref": "#/$defs/File"
          },
          "type": "array"
        }
      }
    },
    "TestCase": {
      "description": "`TestCase` messages provide the request context and an expectation as to whether the given context will be allowed or denied. Test cases may specify the `request`, `resource`, and `function_mocks` to mock a function call to a service-provided function. The `request` object represents context present at request-time. The `resource` is the value of the target resource as it appears in persistent storage before the request is executed.",
      "properties": {
        "expectation": {
          "description": "Test expectation.",
          "type": "string",
          "enum": [
            "EXPECTATION_UNSPECIFIED",
            "ALLOW",
            "DENY"
          ]
        },
        "expressionReportLevel": {
          "type": "string",
          "enum": [
            "LEVEL_UNSPECIFIED",
            "NONE",
            "FULL",
            "VISITED"
          ],
          "description": "Specifies what should be included in the response."
        },
        "resource": {
          "description": "Optional resource value as it appears in persistent storage before the request is fulfilled. The resource type depends on the `request.path` value."
        },
        "functionMocks": {
          "type": "array",
          "description": "Optional function mocks for service-defined functions. If not set, any service defined function is expected to return an error, which may or may not influence the test outcome.",
          "items": {
            "$ref": "#/$defs/FunctionMock"
          }
        },
        "request": {
          "description": "Request context. The exact format of the request context is service-dependent. See the appropriate service documentation for information about the supported fields and types on the request. Minimally, all services support the following fields and types: Request field | Type ---------------|----------------- auth.uid | `string` auth.token | `map` headers | `map` method | `string` params | `map` path | `string` time | `google.protobuf.Timestamp` If the request value is not well-formed for the service, the request will be rejected as an invalid argument."
        },
        "pathEncoding": {
          "description": "Specifies whether paths (such as request.path) are encoded and how.",
          "type": "string",
          "enum": [
            "ENCODING_UNSPECIFIED",
            "URL_ENCODED",
            "PLAIN"
          ]
        }
      },
      "type": "object"
    },
    "TestSuite": {
      "properties": {
        "testCases": {
          "description": "Collection of test cases associated with the `TestSuite`.",
          "items": {
            "$ref": "#/$defs/TestCase"
          },
          "type": "array"
        }
      },
      "type": "object",
      "description": "`TestSuite` is a collection of `TestCase` instances that validate the logical correctness of a `Ruleset`. The `TestSuite` may be referenced in-line within a `TestRuleset` invocation or as part of a `Release` object as a pre-release check."
    }
  }
}