All Projects → washingtonpost → ans-schema

washingtonpost / ans-schema

Licence: MIT license
JSON schema definition and supporting example/validation code for The Washington Post's ANS specification

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ans-schema

php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (-60.87%)
Mutual labels:  json-schema, schema-files
jackson-json-reference
JSON Reference for Java with Jackson.
Stars: ✭ 21 (-77.17%)
Mutual labels:  json-schema
Vue Form Json Schema
Create forms using JSON schema. Bring your components!
Stars: ✭ 253 (+175%)
Mutual labels:  json-schema
restish
Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
Stars: ✭ 453 (+392.39%)
Mutual labels:  json-schema
OpenAPI-Delphi
The Delphi-OpenAPI library is an OpenAPI 3.0 document generator and parser for Delphi
Stars: ✭ 79 (-14.13%)
Mutual labels:  json-schema
django-jsonform
A better, user-friendly JSON editing form field for Django admin. Also supports Postgres ArrayField.
Stars: ✭ 151 (+64.13%)
Mutual labels:  json-schema
Form Render
🚴‍♀️ 阿里飞猪 - 很易用的中后台「表单 / 表格 / 图表」解决方案
Stars: ✭ 3,881 (+4118.48%)
Mutual labels:  json-schema
MOSP
A collaborative platform for creating, editing and sharing JSON objects.
Stars: ✭ 72 (-21.74%)
Mutual labels:  json-schema
finspec-spec
Multi-protocol, machine-readable specifications for financial services
Stars: ✭ 18 (-80.43%)
Mutual labels:  json-schema
angular-schema-form-bootstrap
Bootstrap decorator for Angular Schema Form
Stars: ✭ 50 (-45.65%)
Mutual labels:  json-schema
another-json-schema
Another JSON Schema validator, simple & flexible & intuitive.
Stars: ✭ 48 (-47.83%)
Mutual labels:  json-schema
json-kotlin-schema-codegen
Code generation for JSON Schema (Draft 07)
Stars: ✭ 52 (-43.48%)
Mutual labels:  json-schema
magnet
A JSON/BSON schema generator
Stars: ✭ 16 (-82.61%)
Mutual labels:  json-schema
Rxdb
🔄 A client side, offline-first, reactive database for JavaScript Applications
Stars: ✭ 16,670 (+18019.57%)
Mutual labels:  json-schema
libgltf
glTF 2.0 parser/loader for C++11, supports many extensions likes `KHR_draco_mesh_compression`, `KHR_lights_punctual`, `KHR_materials_clearcoat`, and more.
Stars: ✭ 55 (-40.22%)
Mutual labels:  json-schema
Full Stack Fastapi Couchbase
Full stack, modern web application generator. Using FastAPI, Couchbase as database, Docker, automatic HTTPS and more.
Stars: ✭ 243 (+164.13%)
Mutual labels:  json-schema
openshift-json-schema
A set of JSON schemas for various OpenShift versions, extracted from the OpenAPI definitions
Stars: ✭ 23 (-75%)
Mutual labels:  json-schema
json-schema
JSON schema validation
Stars: ✭ 20 (-78.26%)
Mutual labels:  json-schema
joyce
Joyce is a highly scalable event-driven Cloud Native Data Hub.
Stars: ✭ 37 (-59.78%)
Mutual labels:  json-schema
jest-json-schema
✨ JSON schema matcher for Jest
Stars: ✭ 152 (+65.22%)
Mutual labels:  json-schema

ans-schema

JSON schema definition and supporting example/validation code for The Washington Post's ANS specification

NOTE This schema is in development and subject to change.

Overview

ANS ("Arc Native Specification") is the collection of schema documents that comprise the Washington Post's definition of "content", in so far as content is passed back and forth between systems in the Arc ecosystem of applications.

The current production version of ANS is 0.10.8

The current development version of ANS is 0.10.9

Schema files

ANS Schema files are defined with the JSON Schema specification. Schemas are defined in individual files under the src/main/resrouces/schema/ans/version/ directory.

Small, self-contained, attributes such as "had copyright" or "had unique id" are modeled as traits, which are combined together or applied directly to more complicated schema objects for the purpose of re-usability. The "content.json" schema, for example, composes the traits "credit", "locale", "location", and "copyright".

One can use a variety of third party tools to validate their content against the schema files hosted here on github publicly, such as Ajv.

Examples

A few examples are provided of content documents that validate against the Washington Post ANS schema:

  1. An Example Story
  2. An Example Video
  3. An Example Image

Contributing

See the contributing documentation for information about how to suggest changes to the ANS schema.

Validating Locally

This project contains a node library that can be used to validate ANS documents locally. It is the same validator used in the ANS Service: http://ans.arc2.nile.works/validate/0.9.0

You can run the validator on the command line from the project directory to validate an ANS document:

npm install
npm run-script ans -- --ansdata='{"type":"story", "version":"0.8.1"}' --version=0.10.3 validate

[
  {
    "keyword": "enum",
    "dataPath": ".version",
    "schemaPath": "https://raw.githubusercontent.com/washingtonpost/ans-schema/master/src/main/resources/schema/ans/0.10.3/traits/trait_version.json/enum",
    "params": {},
    "message": "should be equal to one of values"
  }
]

A file can also be used as input:

npm run-script ans -- --ansfile=test.json --version=0.10.3 validate

You can also load the validator as a library in your node project:

var ans = require('@washingtonpost/ans-schema');

ans.getValidatorForVersion('0.10.3', function(err, validator) {
  var errors = validator.validate({"type":"story", "version":"0.5.8"});

  if (errors.length > 0) {
    console.log("There were some errors: " + JSON.stringify(errors));
  }
  else {
    console.log("It's valid!");
  }
});

Other Commands

upvert

Converts a valid document in an old version of ANS to newer version.

npm run-script ans -- --ansdata='{"type":"story", "version":"0.5.0", "content_elements":[{"type":"text", "content": "Foo!", "additonal_properties": { "foo":"bar"}}], "taxonomy":{"sections":[{ "type": "section", "version":"0.5.0"}]}}' upvert

{
  "type": "story",
  "version": "0.10.3",
  "content_elements": [
    {
      "type": "text",
      "content": "Foo!",
      "additional_properties": {
        "foo": "bar"
      }
    }
  ],
  "taxonomy": {
    "sites": [
      {
        "additional_properties": {
          "type": "section"
        },
        "version": "0.10.3",
        "type": "site",
        "name": "(unnamed)",
        "primary": false
      }
    ],
    "tags": []
  }
}

sync

Fixes an invalid document composed of valid sub-documents of differing ANS versions. Essentially this converts a very specific kind of invalid document to a valid one by selective upverting.

npm run-script ans -- --ansdata='{"type":"story", "version":"0.10.3", "content_elements":[{"type":"gallery", "version":"0.8.1", "content_elements":[ {"type":"image", "version":"0.8.1", "url":"http://foo.com/img.jpg"}]}]}' sync

{
  "type": "story",
  "version": "0.10.3",
  "content_elements": [
    {
      "type": "gallery",
      "version": "0.10.3",
      "content_elements": [
        {
          "type": "image",
          "version": "0.10.3",
          "url": "http://foo.com/img.jpg"
        }
      ]
    }
  ]
}

Creating a new ANS version

The script to create a new version: npm run-script ans -- --version=x.xx.x create

After running this, if you've created a new major or minor version, you'll need to update line 19 in this file so that the validate endpoint will work: lib/validator.js.

Make sure to also add a test file here: tests/fixtures/schema/. You can copy over the previous test file (schema-tests-xx.js) and rename it with your version number. When people open PRs for new schema changes, they can add tests to that file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].