question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON Schema / IETF support

See original GitHub issue

So, apparently JSON Schema is an IETF standard (Informational), that is used in products like Swagger, and is some sort of alternative to node-simple-schema.

http://json-schema.org/ http://json-schema.org/documentation.html http://json-schema.org/latest/json-schema-core.html

Has there been any thought given to support json-schema objects and syntax? Perhaps through toSimpleJson() and fromSimpleJson() methods?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
awatson1978commented, Feb 26, 2020

Hi, I don’t have a horse in the race regarding how it’s package. The one thing I’ll say though, is don’t underestimate the value of having a well curated API.

// maybe export both the function as well as attaching it to the SimpleSchema object?  
// lodash and moment provide similar flexibility
import { buildSimpleSchemaFromJson, SimpleSchema} from "some-pkg";

// for people who want want to keep their namespaces flat
let PersonSimpleSchemaA = buildSimpleSchemaFromJson(personJsonSchema);

// for people who want curated API namespaces and Intellisense functionality in their editors 
let PersonSimpleSchemaB = SimpleSchema.buildSimpleSchemaFromJson(personJsonSchema);

As for MongoDB’s newish built-in JSONSchema validation - yes, I have! We’re very excited about the new functionality, and very much looking forward to using it.

However, maybe 80% or 90% of the work we do is with iOS apps and using Meteor as an application server. In the healthcare industry, there’s an industry wide initiative to enable standardized HTTP interfaces at all the hospitals and laboratories in the US. So we focus a lot of our time building client side apps that don’t actually use Mongo or DDP all that much. Rather, we tend use the Meteor build pipeline, and then fetch data from lots of different servers using HTTP. The hospital endpoints are suppose to be all the same, but there are implementation bugs, differences in interpretation, different versions of the standard, etc. So, we need the JSONSchemas on the client to do quality control.

We’re interested in someday landing on an NPM based simpl-schema + minimongo + ajv solution, and minimizing our overall usage of Atmosphere. But that’s probably a year away, and requires at least two more major refactors.

Until then, SimpleSchema/Minimongo is the isomorphic solution we know works. Better to use it to work the JSONSchemas over to the client. Then we can lock down some acceptance tests and integration tests, and then refactor to the NPM packages.

1reaction
aldeedcommented, Feb 25, 2020

@awatson1978 I agree with @coagmano that some sort of factory function is best, but I’d add that it should be a separate package with a dependency on simpl-schema. So rather than SimpleSchema.fromJsonSchema, it would be its own thing you import:

import buildSimpleSchemaFromJson from "some-pkg";

let PersonSimpleSchema = buildSimpleSchemaFromJson(personJsonSchema);

If nobody else is interested in creating and owning this package, I can do it. But I do think it’s best to keep all of that separate. (The existing package should already be broken into a few different packages, IMO.)

Out of curiosity, are you using MongoDB and have you looked into their newish built-in JSONSchema validation? If you attach those to the mongo collections directly in Mongo, then .attachSchema may not even be necessary, although you’d have to parse mongo errors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

draft-zyp-json-schema-04 - IETF Datatracker
JSON Schema : core definitions and terminology (Internet-Draft, 2013) ... schema authors SHALL NOT expect these additional keywords to be supported by peer ......
Read more >
Specification - JSON Schema
They are also available on the IETF main site: draft-bhutton-json-schema-01 ... The meta-schemas are schemas against which other schemas can be validated.
Read more >
json-schema-spec/2022-09-decouple-from-ietf.md at main
JSON Schema is an individual draft. That means it isn't on a standards track with IETF and IETF is not involved nor supports...
Read more >
RFC 8927: JSON Type Definition
This document describes a schema language for JSON [RFC8259] called JSON Type ... The principle of common patterns in JSON is why JTD...
Read more >
JSON Schema Examples Tutorial - MongoDB
JSON (JavaScript Object Notation) is a simple and lightweight text-based data format. JSON Schema is an IETF standard providing a format for what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found