{"id":13777973,"url":"https://github.com/api7/jsonschema","last_synced_at":"2026-04-29T11:00:58.992Z","repository":{"id":40471226,"uuid":"217244910","full_name":"api7/jsonschema","owner":"api7","description":"Pure Lua JSON schema validator for Lua/LuaJIT","archived":false,"fork":false,"pushed_at":"2026-04-29T09:04:08.000Z","size":186,"stargazers_count":134,"open_issues_count":20,"forks_count":30,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-04-29T09:31:08.065Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.apiseven.com/","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/api7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-10-24T08:04:03.000Z","updated_at":"2026-04-29T09:03:35.000Z","dependencies_parsed_at":"2024-01-13T11:12:52.242Z","dependency_job_id":"7ff37eee-489a-4413-99c3-7981d5dffd46","html_url":"https://github.com/api7/jsonschema","commit_stats":{"total_commits":128,"total_committers":18,"mean_commits":7.111111111111111,"dds":0.5859375,"last_synced_commit":"faa202f721c36f14525bef5b6c512bd5aabc7752"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/api7/jsonschema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Fjsonschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Fjsonschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Fjsonschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Fjsonschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/api7","download_url":"https://codeload.github.com/api7/jsonschema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api7%2Fjsonschema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32422532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:00:50.201Z","updated_at":"2026-04-29T11:00:58.949Z","avatar_url":"https://github.com/api7.png","language":"Lua","funding_links":[],"categories":["Libraries","Lua"],"sub_categories":[],"readme":"# jsonschema\n\nA pure Lua JSON Schema validator library for Lua/LuaJIT.\n\nValidation is neither bound nor limited to JSON and can be used to validate other key-value data formats like [Lua tables](https://www.lua.org/pil/2.5.html), [msgpack](https://msgpack.org/index.html), and [bencode](https://en.wikipedia.org/wiki/Bencode).\n\nThe library is designed to validate incoming HTTP requests and is quite performant. Underneath, the library transforms the given schema to a pure Lua function on-the-fly.\n\nWe are currently improving the library to be as JIT-friendly as possible.\n\nThanks to [Julien Desgats](https://github.com/jdesgats) for his work on [ljsonschema](https://github.com/jdesgats/ljsonschema) on top which this project is built upon. This project is a reimplementation that makes it much faster in OpenResty environments by using specific optimization methods.\n\n## Supported versions\n\n| Specification version                                               | Supported? |\n| ------------------------------------------------------------------- | ---------- |\n| \u003c Draft 4                                                           | ❌         |\n| [Draft 4](https://json-schema.org/specification-links.html#draft-4) | ✅         |\n| Draft 5                                                             | ❌         |\n| [Draft 6](https://json-schema.org/specification-links.html#draft-6) | ✅         |\n| [Draft 7](https://json-schema.org/specification-links.html#draft-7) | ✅         |\n\n## Installation\n\nThis library supports Lua versions 5.2 and 5.3, and LuaJIT version 2.1 beta.\n\nTo install the library via LuaRocks:\n\n```shell\nluarocks install jsonschema\n```\n\n\u003e [!NOTE]\n\u003e This library references the PCRE regex library.\n\u003e\n\u003e If you use the LuaJIT of OpenResty, it will automatically use the built in `ngx.re.find` function. But if you use Lua versions 5.2, 5.3 or LuaJIT version 2.1 beta, it will use the function `lrexlib-pcre` instead.\n\u003e\n\u003e This library also relies on [net-url](https://luarocks.org/modules/golgote/net-url) library and it should be installed.\n\n## Development\n\nTo build this library locally and run the tests:\n\n```shell\ngit submodule update --init --recursive\nmake dev\nmake test\n```\n\n## Usage\n\n```lua\nlocal jsonschema = require 'jsonschema'\n\n-- Note: Cache the result of the schema compilation as this is quite expensive\nlocal myvalidator = jsonschema.generate_validator {\n  type = 'object',\n  properties = {\n    foo = { type = 'string' },\n    bar = { type = 'number' },\n  },\n}\n\nprint(myvalidator{ foo='hello', bar=42 })\n```\n\n### Advanced usage\n\nSome advanced features of JSON Schema cannot be implemented using the standard library and requires third-party libraries to work.\n\nIn order to not bloat this library for simple usage, extension points are provided. The `generate_validator` takes in a table argument that can be used to customize the generated parser:\n\n```lua\nlocal v = jsonschema.generate_validator(schema, {\n    -- A value used to check null elements in the validated documents\n    -- Defaults to `cjson.null` (if available) or `nil`\n    null = null_token,\n\n    -- Function called to match patterns, defaults to `ngx.re.find` in OpenResty\n    -- or `rex.find` from lrexlib-pcre on other occassions\n    -- The pattern given here will follow the ECMA-262 specification\n    match_pattern = function(string, patt)\n        return ... -- boolean value\n    end,\n\n    -- Function called to resolve external schemas\n    -- Called with the full URL to fetch (without the fragment part) and must return the corresponding schema as a Lua table\n    -- No default implementation: this function must be provided if resolving external schemas is required\n    external_resolver = function(url)\n        return ... -- Lua table\n    end,\n\n    -- Name when generating the validator function\n    -- Might ease debugging as it will appear in stack traces\n    name = \"myschema\",\n})\n```\n\n## Differences with JSONSchema\n\nDue to the limitations of Lua, supporting the JSON Schema specification completely is difficult. Some of these limitations can be overcome using the extension points mentioned above while some limitations still exist:\n\n- Empty tables and empty arrays are the same for Lua.\n\nOn the other hand, some extra features are supported:\n\n- The type `table` can be used to match arrays or objects. It is much faster than `array` or `object` as it does not involve walking the table to find out if it's a sequence or a hash.\n- The type `function` can be used to check for functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapi7%2Fjsonschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapi7%2Fjsonschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapi7%2Fjsonschema/lists"}