{"id":20028637,"url":"https://github.com/phase2/schemata","last_synced_at":"2025-05-05T03:32:17.264Z","repository":{"id":66226390,"uuid":"64179562","full_name":"phase2/schemata","owner":"phase2","description":"Facilitate generation of schema definitions of Drupal 8 data models as used by Drupal REST.","archived":false,"fork":false,"pushed_at":"2018-07-18T05:30:18.000Z","size":136,"stargazers_count":8,"open_issues_count":2,"forks_count":5,"subscribers_count":5,"default_branch":"8.x-1.x","last_synced_at":"2025-04-22T13:06:10.272Z","etag":null,"topics":["drupal","drupal-8","drupal-module","json-schema"],"latest_commit_sha":null,"homepage":"https://www.drupal.org/project/schemata","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phase2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-07-26T01:25:08.000Z","updated_at":"2019-05-03T11:59:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"aa5dd46d-efe3-4d5d-890f-d0f480f7628e","html_url":"https://github.com/phase2/schemata","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phase2%2Fschemata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phase2%2Fschemata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phase2%2Fschemata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phase2%2Fschemata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phase2","download_url":"https://codeload.github.com/phase2/schemata/tar.gz/refs/heads/8.x-1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252180008,"owners_count":21707120,"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","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":["drupal","drupal-8","drupal-module","json-schema"],"created_at":"2024-11-13T09:15:50.595Z","updated_at":"2025-05-05T03:32:17.238Z","avatar_url":"https://github.com/phase2.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Schemata\n\n\u003e Facilitate generation of schema definitions of Drupal 8 data models.\n\n[![GitHub tag](https://img.shields.io/github/tag/phase2/schemata.svg)](https://github.com/phase2/schemata) [![Website](https://img.shields.io/badge/website-drupal.org-blue.svg)](https://www.drupal.org/project/schemata) [![Build Status](https://travis-ci.org/phase2/schemata.svg?branch=8.x-1.x)](https://travis-ci.org/phase2/schemata)\n\nA schema is a declarative description of structured data that prescribes the\nrules for how that data can be created. Schemas are commonly used to provision\nrelational storage, to generate forms or other user interfaces, to generate\nclient library code, or to validate data.\n\nSchemata supports the creation of provider modules that create schemas to\ndescribe the different entities in a Drupal site (such as Nodes,\nTaxonomy Terms, and Users) as they are rendered in Drupal REST responses.\nThis project ensures your Drupal site is able to deliver self-documenting\nmachine descriptions of your API payloads, driven by the same configuration that\nDrupal uses to build forms and validate entities.\n\nIn addition to the more abstract developer module named \"Schemata\", there is\na reference implementation of a schema provider: Schemata JSON Schema, which\nprovides [JSON Schema](http://json-schema.org/) support to define entities\ndelivered in Drupal Core's JSON and HAL JSON REST formats, and the contrib\nmodule and format [JSON API](https://www.drupal.org/project/jsonapi).\n\n## What has a Schema?\n\nAll Content Entity Types and Bundles have a schema automatically via the\nSchemata module. Core support for this kind of structured description of\nconfiguration does not exist yet.\n\n## Where is the Schema?\n\nSchemata are accessed via regular routes. Once enabled, Schemata resources are\nfound at `/schemata/{entity_type}/{bundle?}`. These resources are dynamically\ngenerated based on your entity definitions, which means any change to fields on\nan Entity will automatically be reflected in the schema.\n\n## Requirements\n\nDrupal 8.3 is required for Schemata's generated schemas to validate your REST\nresponses.\n\nSchemata-the-module is a dependency for the sub-modules of the project:\n\n* **Schemata JSON Schema**: A serializer which processes Schemata schema objects\n  into [JSON Schema v4](http://json-schema.org). Describes the output of content\n  entities via the core JSON, HAL and JSON API serializers.\n\nFrom a \"product\" standpoint, JSON Schema is the value, and Schemata\nthe technical dependency. Only install Schemata if you plan to install a Schema\nprovider module that depends on it.\n\n## Architecture\n\nThe Schemata project contains the Schemata and Schemata JSON Schema modules.\nThe Schemata module provides routes to retrieve a serialized, machine-readable\nschema. The schemas are assembled dynamically leveraging the\n[Typed Data API](https://www.drupal.org/node/1794140) and other site configuration.\nThe schema for each entity type (and bundle) is exposed in the manner of a\nREST resource, accessible via GET requests designating the appropriate `_format`\nparameter to select a schema type and `_describes` to target a particular entity\nrepresentation format supported by Drupal REST.\n\nIn order to serialize the Schema object, the serializer must be able to support\nimplementations of the Drupal\\schemata\\Schema\\SchemaInterface class. At this\ntime, the only serializer support for Schemata is within this project, you can\nsee an example of this in the packaged submodule **Schemata JSON Schema**.\n\n## Usage\n\nYou can obtain the schema either making an HTTP request or by using the\nprogrammatic API.\n\nEach schema type format should be contained in its own module. Enable the\nmodule for the format that you need first. For instance:\n\n```\ndrush en -y schemata_json_schema\n```\n\nFinally you need to grant permission to access the data models to roles that\nneed it. (`access schemata data models`)\n\n### Request\n\nCreate a request against\n`/schemata/{entity_type}/{bundle}?_format={output_format}\u0026_describes={described_format}`\nFor instance:\n\n  * `/schemata/node/article?_format=schema_json\u0026_describes=hal_json`\n  * `/schemata/user?_format=schema_json\u0026_describes=api_json` (omit the bundle\n  if the entity type has no bundles).\n\n### Programmatically\n\n```php\n// Input variables.\n$entity_type_id = 'node';\n$bundle = 'article';\n$output_format = 'schema_json';\n$described_format = 'api_json';\n\n// Services.\n$schema_factory = \\Drupal::service('schemata.schema_factory');\n$serializer = \\Drupal::service('serializer');\n\n// Generate a Schema object.\n$schema = $schema_factory-\u003ecreate($entity_type_id, $bundle);\n\n// Render the schema as a string conforming to the selecting schema type.\n$format = $output_format . ':' . $described_format;\n$serializer-\u003eserialize($schema, $format);\n```\n\n### Related Projects\n\nUse the [Docson](https://www.drupal.org/project/docson) module to visualize\nthe JSON Schemas generated by the Schemata module.\n\nUse the [OpenAPI](https://www.drupal.org/project/openapi) module to generate\na Swagger v2 API definition specification, which can in turn be used by ecosystem\nof Swagger-based tools. For example, the [Swagger Tools page](https://swagger.io/tools/)\nand [ReDoc](https://rebilly.github.io/ReDoc/).\n\n## Contribute\n\n* Security reports should follow [Drupal.org security reporting procedures]\n(https://www.drupal.org/node/101494).\n* Other bugs and issues should be filed in the [Issue Queue](https://www.drupal.org/project/issues/schemata)\n* Code contributions should be submitted as a [Pull Request in Github](https://github.com/phase2/schemata)\n\n## URLs\n\n* [Homepage]()\n* [Development](https://github.com/phase2/schemata)\n\n## Maintainers\n\nAdam Ross a.k.a. Grayside\n\n## Contributors\n\nCreation of this module was sponsored by\n[Norwegian Cruise Line](https://www.drupal.org/norwegian-cruise-line).\n\nFubhy's work on [GraphQL](https://www.drupal.org/project/graphql) was a great\nhelp in early architecture of this project. Thank you to\n[Fubhy](https://www.drupal.org/u/fubhy) and the GraphQL sponsors.\n\n## F.A.Q.\n\n### Will there be a Drupal 7 backport?\n\nThis module can be summarized as follows:\n\nA Drupal 8 subsystem (routing) and a Symfony subsystem (Serialization) use a\ntouchy Drupal 8 subsystem (Typed Data) to describe the output of another\nDrupal 8 subsystem (Entity).\n\nIt gets worse--the use cases of this module are most applicable when said entity\noutput comes by way of the routing and Serialization systems.\n\nIt does not make sense to discuss a backport unless you first backport large\nswathes of Drupal 8.\n\n### Why not use some other module?\n\n[Self Documenting REST API](https://www.drupal.org/project/rest_api_doc)\nproduces webpage reports about REST resources on the site. This project might\neventually compete with that if it builds out support for the\n[Swagger specification](http://swagger.io/).\n\n[Field Report](https://www.drupal.org/project/field_report) enhances the core\nreports about fields and content types. This has some similarity with this\nproject, but the reports provided by Field Report are for people orienting on\na site. This project produces schemas that can be used for machine integrations\nor feeding into other report generation systems.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphase2%2Fschemata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphase2%2Fschemata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphase2%2Fschemata/lists"}