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

What is registerSchemaByURI used for? #462

Closed
DominikSarnowski opened this issue Jul 21, 2022 · 6 comments
Closed

What is registerSchemaByURI used for? #462

DominikSarnowski opened this issue Jul 21, 2022 · 6 comments

Comments

@DominikSarnowski
Copy link

Hello.
Can I use it to register different schemas to validate different objects?
If yes, how to load those different schemas at runtime?

Or is it only to combine schemas that relates one to another?

Can you clarify it to me, please?

@erosb
Copy link
Contributor

erosb commented Jul 21, 2022

Can I use it to register different schemas to validate different objects?

No. This is for referencing other schema documents from your schema. Ie. if you register a schema with an URI like urn:uuid:57458a26-fc1e-42cb-9636-cff91c5ee807 then you can refer to it in your schema with "$ref": "urn:uuid:.urn:uuid:57458a26-fc1e-42cb-9636-cff91c5ee807#/definitions/Subschema`.

If you want to validate different objects against different schemas, then you have to build separate Schema instances and pick the appropriate schema for validation based on your object (it is up to you).

@DominikSarnowski
Copy link
Author

Thank you @erosb !

Can you anser this (#456 (comment)) concern of mine, please?

@DominikSarnowski
Copy link
Author

DominikSarnowski commented Jul 22, 2022

So this $ref is static in another file, or I can dynamically point to it in the app?
Can URI be made upon single word like name of the file?
@erosb I don't really get how to use those registered schemas programmatically from the code or is it just the linkage for the Visitor object to be able to traverse correctly?

@erosb
Copy link
Contributor

erosb commented Jul 22, 2022

I don't really get how to use those registered schemas programmatically

Can you please elaborate on your usecase? What do you want to achieve?

@DominikSarnowski
Copy link
Author

I just wanted to make sure if I correctly understand what is registerSchemaByURI used for.

I wanted to make prototype bean of schemas in SpringBoot application to be able to extract it to common library and based on properties create schemas. But at the same time if the application needs to use more than 1 schema at the same time I would need separate bean for the other needed schemas.

@erosb
Copy link
Contributor

erosb commented Jul 25, 2022 via email

@erosb erosb closed this as completed Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants