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

JSON-Schema-Validator Modul compatible at least with JSON-Schema v7 #443

Closed
TobiasNx opened this issue Mar 21, 2022 · 6 comments · Fixed by #468
Closed

JSON-Schema-Validator Modul compatible at least with JSON-Schema v7 #443

TobiasNx opened this issue Mar 21, 2022 · 6 comments · Fixed by #468
Assignees

Comments

@TobiasNx
Copy link
Contributor

TobiasNx commented Mar 21, 2022

In context of OERSI we have a JSON-Schema-Validator but it only supports v4.
Will be needed in lobid and in RPB too.

Option/features should be:

  • halting or not halting invalid files
  • sending invalid files to separate file
  • supporting web schemas and local schemas
  • supporting modular schemas
@fsteeg
Copy link
Member

fsteeg commented Mar 21, 2022

Implementation should probably start in OERSI, following up on https://gitlab.com/oersi/oersi-etl/-/issues/96#note_679435293 and then moving the working implementation here.

@fsteeg
Copy link
Member

fsteeg commented Sep 20, 2022

Implemented in #468, assigning @TobiasNx for functional review.

Usage e.g. validate-json("/schemas/schema.json", schemaRoot="/schemas/")

(The schemaRoot is for resolving sub-schemas as we have in our setup in OERSI.)

@fsteeg fsteeg assigned TobiasNx and unassigned fsteeg Sep 20, 2022
@fsteeg fsteeg moved this from Backlog to Review in Metafacture alt Sep 20, 2022
TobiasNx added a commit to TobiasNx/notWorkingFlux that referenced this issue Sep 29, 2022
TobiasNx added a commit to TobiasNx/notWorkingFlux that referenced this issue Sep 29, 2022
@TobiasNx
Copy link
Contributor Author

I'm trying to test this: https://github.com/TobiasNx/notWorkingFlux/blob/a59fa2193ca5045a8f5f50b1f47387e4d8ffcb39/jsonValidator

Seems not to work yet, what did I do wrong?

@TobiasNx TobiasNx assigned fsteeg and unassigned TobiasNx Sep 29, 2022
@fsteeg
Copy link
Member

fsteeg commented Sep 29, 2022

Ah, right, passing a URL as the main schema is not supported yet. When we talked about URLs in this context, I was thinking of sub-schemas referenced in the main schema, where URLs work (this is handled by the validator library).

Supporting URLs for the main schema does make sense and from your test, seems to be the obvious use case. It's no problem to support in principle, but brings in some additional aspects to consider (like caching to avoid an HTTP request for every document, testing without introducing remote requests in the test). So I'm moving this to backlog for now.

BTW this is a good example for the issue we recently discussed in a meeting, that moving a custom Metafacture module into core is much more than just moving it, and therefore should only happen if there is actual demand for the generic module (which is the case here, but maybe not for #469).

@fsteeg fsteeg moved this from Review to Backlog in Metafacture alt Sep 29, 2022
fsteeg added a commit that referenced this issue Feb 1, 2023
Remove schemaRoot config, resolutionScope is now set to base path
@fsteeg
Copy link
Member

fsteeg commented Feb 2, 2023

Supporting URLs for the main schema [...] brings in some additional aspects to consider (like caching to avoid an HTTP request for every document, testing without introducing remote requests in the test).

I've added support for loading the main schema and relative refs from URLs and mocks for serving the test schemas. Instead of adding explicit caching, I've moved the loading of the schema into the constructor (was possible after removal of schemaRoot). This should avoid reloading the schema on each validation.

@TobiasNx Your validation test should now work.

@fsteeg fsteeg assigned TobiasNx and fsteeg and unassigned fsteeg Feb 2, 2023
@fsteeg fsteeg removed their assignment Feb 3, 2023
@TobiasNx
Copy link
Contributor Author

I tested it. Seems to run smoothly now! Great :)

@TobiasNx TobiasNx assigned fsteeg and unassigned TobiasNx Feb 15, 2023
Metafacture alt automation moved this from Backlog to Done Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants
@fsteeg @TobiasNx and others