How to handle JSON schema validation #173
Replies: 2 comments 4 replies
-
Another option that would be sane, imo, is putting this under api.gsd.id e.g.
etc |
Beta Was this translation helpful? Give feedback.
-
So here's the thing:
which logically leads to:
which then leads to "how exactly"? Hosting it ourselves with correct content type means we don't have to fix any software. That's a huge bonus. Hosting it with the full path, prepended with scha.gsd.id or api.gsd.id or whatever means we don't lose any data, and we can change it easily without having to worry (e.g. multiple things can map to https://api.gsd.id/v1/schemas/cve/v5 but only https://schema.gsd.id/raw.githubusercontent.com/ossf/osv-schema/v1.4.0/validation/schema.json maps to https://raw.githubusercontent.com/ossf/osv-schema/v1.4.0/validation/schema.json |
Beta Was this translation helpful? Give feedback.
-
So we want to validate our JSON data where possible. Many (e.g. OSV) have schemas. However in order to properly use $ref links in schema (essentially you can point at other schemas from within a schema) the schema data needs to be served as "application/schema+json" so for example we can't just point at the GitHub "raw" links because they get served as "text/plain"
So we have two main options as I see it:
Ideally each schema we rely upon (OSV, CVE. NIST, etc.) would have an endpoint that works, most (all?) do not.
This also doesn't address longer ter issues like projects using the OSV data format but in YAML files for example.
I'd like to propose (conceptually) we have something like "schemas.gsd.id" that serves various schemas (JSON, YAML, etc.). Long term it could even provide an API that validates data. We would need to harvest up all the schemas and versions we use and serve them, or maybe simply provide a "passthrough" API that has an allow list of things to serve and takes a request like:
https://schema.gsd.id/raw.githubusercontent.com/ossf/osv-schema/v1.4.0/validation/schema.json
and goes and gets https://raw.githubusercontent.com/ossf/osv-schema/v1.4.0/validation/schema.json and then serves it with "application/schema+json"
we would then need to change lines like:
"$ref": "https://raw.githubusercontent.com/ossf/osv-schema/v1.4.0/validation/schema.json"
to
"$ref": "https://schema.gsd.id/raw.githubusercontent.com/ossf/osv-schema/v1.4.0/validation/schema.json"
and it would work. Thoughts/comments?
Beta Was this translation helpful? Give feedback.
All reactions