{"modulePath":"github.com/Github/git-lfs","version":"v1.5.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package schema\n\nschema provides a testing utility for testing API types against a predefined JSON schema.\n\nThe core philosophy for this package is as follows: when a new API is accepted, JSON Schema files should be added to document the types that are exchanged over this new API. Those files are placed in the \\`/api/schema\\` directory, and are used by the schema.Validate function to test that particular instances of these types as represented in Go match the predefined schema that was proposed as a part of the API.\n\nFor ease of use, this file defines several constants, one for each schema file's name, to easily pass around during tests.\n\nAs briefly described above, to validate that a Go type matches the schema for a particular API call, one should use the schema.Validate() function.\n\n## Constants\n\n```go\nconst (\n\tLockListSchema       = \"lock_list_schema.json\"\n\tLockRequestSchema    = \"lock_request_schema.json\"\n\tLockResponseSchema   = \"lock_response_schema.json\"\n\tUnlockRequestSchema  = \"unlock_request_schema.json\"\n\tUnlockResponseSchema = \"unlock_response_schema.json\"\n)\n```\n\n## Functions\n\n```go\nfunc Refute(t *testing.T, schemaName string, got interface{})\n```\nRefute ensures that a particular Go object does not validate the JSON schema given.\n\nIf validation against the schema is successful, then the test will fail after logging.\n\n```go\nfunc Validate(t *testing.T, schemaName string, got interface{})\n```\nValidate validates a Go object against JSON schema in a testing environment. If the validation fails, then the test will fail after logging all of the validation errors experienced by the validator.\n\n## Types\n\n```go\ntype SchemaValidator struct {\n\t// Schema is the JSON schema to validate against.\n\t//\n\t// Subject is the instance of Go type that will be validated.\n\tSchema, Subject gojsonschema.JSONLoader\n}\n```\nSchemaValidator uses the gojsonschema library to validate the JSON encoding of Go objects against a pre-defined JSON schema.\n\n```go\nfunc NewSchemaValidator(t *testing.T, schemaName string, got interface{}) *SchemaValidator\n```\n\n```go\nfunc (v *SchemaValidator) Assert(t *testing.T)\n```\nAssert preforms the validation assertion against the given \\*testing.T.\n\n```go\nfunc (v *SchemaValidator) Refute(t *testing.T)\n```\nRefute refutes that the given subject will validate against a particular schema.\n\n","path":"github.com/Github/git-lfs/api/schema","name":"schema","synopsis":"schema provides a testing utility for testing API types against a predefined JSON schema.","isRedistributable":true}
