skohub-io / skohub-editor

Apache License 2.0
5 stars 4 forks source link

Problem with schema including `$ref` to other schema in GH pages #39

Closed acka47 closed 4 years ago

acka47 commented 4 years ago

(Background: I started to split up the default JSON schema following the approach in https://json-schema.org/learn/getting-started-step-by-step.html#references (see the branch at https://github.com/dini-ag-kim/lrmi-profile/tree/splitUpSchema). Before merging this into master I wanted to try out whether this approach actually works with SkoHub editor.)

So I tried it out at https://github.com/acka47/lrmi-profile with only one reference and the same GH pages setup. The resulting schema is at https://acka47.github.io/lrmi-profile/draft/schemas/schema.json (see the creator property with the reference to https://acka47.github.io/lrmi-profile/draft/schemas/creator.json.

However, loading this schema in https://skohub.io/editor/ does not work, see https://skohub.io/editor/?schema=https://acka47.github.io/lrmi-profile/draft/schemas/schema.json

In the console, there are for one several CORS-related errors ("Cross-Origin Request Blocked") and another error: "Error: Invalid JSON pointer: ttps://acka47.github.io/lrmi-profile/draft/schemas/creator.json index.js:209:36" (Strangely, the "h" in "https" is omitted there.)

Re. CORS and GitHub pages, this has been supported for some time now (see https://stackoverflow.com/questions/26416727/cross-origin-resource-sharing-on-github-pages), so I wonder what is the problem there.

acka47 commented 4 years ago

Just chatted with @sroertgen who is doing very similar stuff with controlled vocabularies and JSON-LD metadata for the school sector like we are doing in OERSI/OER-metadatengruppe for higher ed. I thought about uncluding the school standards in KIM efforts and we discussed how we could create one generic, modular profile/schema that could be referenced and extended for the respective use cases.

This modular approach with a split-up schema makes a lot of sense for implementing this: Both the school and higher-ed schemas could reference/import the generic parts (like metametadata, creator etc.) and add their specific module for their uses cases (e.g. for about/subject where different SKOS vocabs are used).

dr0i commented 4 years ago

Deployed, closed.

stefandesu commented 3 years ago

I have an issue that seems to be related to this one. Our JSON Schemas for JSKOS are split up and reference each other. However, we are using relative URLs instead of absolute. For example, https://gbv.github.io/jskos/scheme.schema.json references several other schemas, like resource.schema.json. In SkoHub Editor, these don't get resolved properly. It uses the URL where the editor is hosted as the base URL instead of the id.

In the JSON Schema documentation, it says:

The $id property is a URI-reference that serves two purposes:

  • It declares a unique identifier for the schema.
  • It declares a base URI against which $ref URI-references are resolved.

So as far as I understand, if I reference resource.schema.json in a schema with the ID https://gbv.github.io/jskos/scheme.schema.json, it should be resolved as https://gbv.github.io/jskos/resource.schema.json.

Maybe I misunderstand it, so any input would be appreciated!

acka47 commented 3 years ago

Thanks for the report, @stefandesu. I think you are interpreting this right. As your case differs from the problem in this issue (where $ref with an absolute URL wouldn't work), I opened a separate issue (#63). (Feel free to open a PR if you have an idea how to handle this. ;-)