Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit: decide on a schema #2643

Open
oliver-sanders opened this issue Nov 22, 2022 · 4 comments
Open

edit: decide on a schema #2643

oliver-sanders opened this issue Nov 22, 2022 · 4 comments
Assignees
Milestone

Comments

@oliver-sanders
Copy link
Member

We are currently considering JSON Schema, however, we should have a quick look around to make sure this is the best choice.

Points in favour of JSON Schema:

  • It is used by Jedi.
  • There is good tooling around it.
  • It may be easier to integrate with text editors via existing JSON Schema plugins.
  • JSON Schema Form extends JSON Schema into form layout/control.
@oliver-sanders oliver-sanders added this to the 2.gui milestone Nov 22, 2022
@aenglyst aenglyst self-assigned this Jan 6, 2023
@aenglyst
Copy link

aenglyst commented Feb 1, 2023

Assessment of JSON Schema

The current version is 2020-12

Specification links can be found here:

Specification Links | JSON Schema (json-schema.org)

@aenglyst
Copy link

aenglyst commented Feb 1, 2023

Pros

Cons

  • Documentation - There are a few gaps in the documentation, e.g. Unevaluated Items, contentSchema

  • Flexibility - It may not be flexible enough for all metadata descriptions. Data types are limited to numbers, strings and lists.

  • Extendability - It is not clear how it can be extended for all metadata definitions

@aenglyst
Copy link

aenglyst commented Feb 1, 2023

Alternatives

Other JSON data validators exist, and these can be used alongside tools such as jsonlint, for validating JSON for the correct format rather than allowing for custom validation of JSON instances.

Other alternative architectures for API consideration include:

OpenAPI, AsyncAPI.

Some of the alternatives to JSON Schema are TypeSchema or JTD, that instead of focusing on validation, focus on the definition of data models. Although the addition of such an extra layer may just add unnecessary complexity.

TypeSchema

TypeSchema is a code generator friendly alternative to JsonSchema explained as:

For code generators it is difficult to work with JSON Schema since it is designed to validate JSON data. In JSON Schema you don't need to provide any keywords i.e. {} is a valid JSON Schema which basically allows every value and the defined keywords are applied based on the actual data. This means you can interpret a schema only if you have also the actual data. A code generator on the other hand needs to determine a concrete type of a schema without the actual data.

Because of this TypeSchema is designed in such a way that it is possible to determine a concrete type based on the used keywords. You can think: TypeSchema is to JsonSchema what TypeScript is to Javascript, a more type safe version which has also keywords for better inheritance, union/intersection and generic handling.

JTD - jtd (jsontypedef.github.io)

Validating JSON data in shell scripts with jtd-validate (jsontypedef.com)

JSON Type Definition, aka RFC 8927, is an easy-to-learn, standardized way to define a schema for JSON data. You can use JSON Typedef to portably validate data across programming languages, create dummy data, generate code, and more.

This jtd package is a JavaScript / TypeScript implementation of JSON Type Definition. It lets you validate input data against JSON Type Definition schemas. jtd works in Node.js and web browsers.

If you're looking to generate code from schemas, check out "Generating TypeScript from JSON Typedef schemas" in the JSON Typedef docs.

Other options:
Standards for describing JSON structures:

  • JSON Content Rules
  • JSON LD
  • RAML
    Consider in the context of API related technologies that specify own structures for JSON structures such as:
  • GraphQL
  • Falcor
  • OData

@aenglyst
Copy link

aenglyst commented Feb 1, 2023

Conclusion

In summary, although there are some limitations, json-schema seems to be a good fit for allowing validation of translated metadata and there are many implementations and pre-existing tooling to facilitate an end-to-end metadata configuration editor in a modern web driven context. This is a good technology solution, although some further work is needed to verify extensibility options and for enabling custom widget capabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants