{"id":28176112,"url":"https://github.com/sitrox/schemacop","last_synced_at":"2025-07-23T05:34:19.477Z","repository":{"id":47637117,"uuid":"60513356","full_name":"sitrox/schemacop","owner":"sitrox","description":"Validates ruby structures consisting of nested hashes and arrays against simple schema definitions and is able to generate JSON Schemas from it.","archived":false,"fork":false,"pushed_at":"2025-05-27T14:14:46.000Z","size":860,"stargazers_count":13,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-27T15:30:42.586Z","etag":null,"topics":["json-schema"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sitrox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2016-06-06T08:52:48.000Z","updated_at":"2025-05-27T14:14:49.000Z","dependencies_parsed_at":"2024-11-17T17:35:44.843Z","dependency_job_id":"81d28aa7-db75-4985-ae76-5f57278bfd4a","html_url":"https://github.com/sitrox/schemacop","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/sitrox/schemacop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitrox%2Fschemacop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitrox%2Fschemacop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitrox%2Fschemacop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitrox%2Fschemacop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sitrox","download_url":"https://codeload.github.com/sitrox/schemacop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sitrox%2Fschemacop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266624796,"owners_count":23958300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["json-schema"],"created_at":"2025-05-16T00:15:07.383Z","updated_at":"2025-07-23T05:34:19.448Z","avatar_url":"https://github.com/sitrox.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Ruby](https://github.com/sitrox/schemacop/actions/workflows/ruby.yml/badge.svg?branch=master)](https://github.com/sitrox/schemacop/actions/workflows/ruby.yml)\n[![Gem Version](https://badge.fury.io/rb/schemacop.svg)](https://badge.fury.io/rb/schemacop)\n\n# Schemacop\n\nSchemacop validates ruby structures consisting of nested hashes and arrays\nagainst schema definitions described by a simple DSL. It is also able to\ngenerate [JSON Schema](https://json-schema.org) compliant JSON output, i.e. for\nuse in conjunction with [OpenAPI](https://swagger.io/specification/).\n\n## Compatibility\n\nSchemacop is tested with the following ruby versions:\n\n* 2.6.2\n* 2.7.1\n* 3.0.1\n* 3.1.0\n* 3.2.0\n* 3.3.0\n* 3.4.0\n\nOther ruby versions might work but are not covered by our automated tests.\n\n## Basic example\n\n```ruby\nschema = Schemacop::Schema3.new :hash do\n  scm :group do\n    str! :name\n  end\n  str! :name\n  int? :age, minimum: 21\n  ary! :groups do\n    list :reference, path: :group\n  end\nend\n\nschema.validate!(\n  name: 'John Doe',\n  age: 42,\n  groups: [\n    { name: 'Group 1' },\n    { name: 'Group 2' }\n  ]\n)\n```\n\n## Installation\n\nTo install the **Schemacop** gem:\n\n```sh\n$ gem install schemacop\n```\n\nTo install it using `bundler` (recommended for any application), add it to your\n`Gemfile`:\n\n```ruby\ngem 'schemacop', '\u003e= 3.0.0'\n```\n\n## Schema specification\n\nThe actual schema definition depends on the schema version you're using.\nSchemacop 3 supports version 3 and also the legacy version 2 for backwards\ncompatibility. For version 1, you need to use the `1.x` versions of schemacop.\n\n* [Schema version 3](README_V3.md)\n* [Schema version 2](README_V2.md) (legacy)\n\n## JSON generation\n\nUsing the method `as_json` on any V3 schema will produce a JSON schema compliant\nto the JSON Schema standard.\n\n```ruby\nSchemacop::Schema3.new :hash do\n  str! :name\nend.as_json\n\n# Will result in\n{\n  type: :object,\n  properties: {\n    name: { type: :string }\n  },\n  additionalProperties: false,\n  required: [:name]\n}\n```\n\nOn the resulting data structure, you can use `to_json` to convert it into an\nactual JSON string.\n\n## Exceptions\n\nSchemacop will throw one of the following checked exceptions:\n\n* `Schemacop::Exceptions::InvalidSchemaError`\n\n  This exception is thrown when the given schema definition format is invalid.\n\n* `Schemacop::Exceptions::ValidationError`\n\n  This exception is thrown when the given data does not comply with the given\n  schema definition.\n\n## Development\n\nTo run tests:\n\n* Check out the source\n\n* Run `bundle install`\n\n* Run `bundle exec rake test` to run all tests\n\n* Run `bundle exec rake test TEST=test/unit/some/file.rb` to run a single test\n  file\n\n## Copyright\n\nCopyright © 2016 - 2025 Sitrox. See `LICENSE` for further details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitrox%2Fschemacop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsitrox%2Fschemacop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitrox%2Fschemacop/lists"}