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

Allow setting root document uri in SchemaLoader #333

Closed
wants to merge 1 commit into from
Closed

Allow setting root document uri in SchemaLoader #333

wants to merge 1 commit into from

Conversation

tmarsteel
Copy link

@tmarsteel tmarsteel commented Oct 11, 2019

I need an absolute path to all schemas i load; Setting it afterwards doesn't cut it because it won't apply to nested schemas.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 91.574% when pulling c2011ff on tmarsteel:root-document-uri into 120bf51 on everit-org:master.

Copy link
Contributor

@erosb erosb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, it does the same as SchemaLoader#resolutionScope() doesn't it?

@tmarsteel
Copy link
Author

Hi :)

I use this code to load the schemas:

val loader = SchemaLoader.builder()
                        .resolutionScope("file:${schemaPath.parent}/")
                        .schemaJson(schemaJson)
                        .build()
val schema = loader.load().build()

With that, schema.getLocation() does have rootDocumentURI == null. Did i miss something?

@erosb
Copy link
Contributor

erosb commented Oct 14, 2019

Hello, this problem makes sense, though probably we need an other approach to fix it. So currently we already have 2 ways for setting the location of a schema: SchemaLoader#resolutionScope() and SchemaLoader#pointerToCurrentObj() which is used internally by the library. I don't want to add a third builder method which does something similar. I think the best solution would be changing SchemaLoader#resolutionScope(URI) to set both this.id and this.pointerToCurrentObj in the builder method. Do you want to give it a go?

@erosb
Copy link
Contributor

erosb commented Oct 14, 2019

Nevermind, I fixed it in 993c3f7
Closing this PR. Please let me know if you have any further questions.

@erosb erosb closed this Oct 14, 2019
@tmarsteel tmarsteel deleted the root-document-uri branch October 14, 2019 18:19
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

Successfully merging this pull request may close these issues.

3 participants