-
Notifications
You must be signed in to change notification settings - Fork 530
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
Schema#getDefaultValue() throws NoSyncValidationException if it is a RefSchema #1816
Schema#getDefaultValue() throws NoSyncValidationException if it is a RefSchema #1816
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the problem, however I have 2 concerns with this solution:
- You're introducing a breaking change, I would prefer to come out from this without breaking changes.
- Your solution doesn't deep solve the schema, you would need something like this method https://github.com/eclipse-vertx/vertx-json-schema/blob/master/src/main/java/io/vertx/json/schema/common/SchemaRouterImpl.java#L179 (which is not public in the
SchemaRouter
because I don't feel is stable enough)
I think we need to find another solution to the problem, I'll try to come up with something soon
if (s.isSync()) { | ||
return Future.succeededFuture(s.getDefaultValue()); | ||
} | ||
return s.validateAsync(null) // validate a dummy to trigger syncing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one doesn't deep solve the references
well its kind of a quick-fix. From my point of view Tthis breaking change within the web-validation i would consider acceptable because it should have been a Future in the first place - wouldnt you agree? |
I do agree.
Besides this module is in tech preview mode.
…On Mon, Dec 14, 2020 at 10:03 AM DemonicTutor ***@***.***> wrote:
@slinkydeveloper <https://github.com/slinkydeveloper>
well its kind of a quick-fix.
From my point of view getDefaultValue() in Schema should have been async
equally to validate but that would have been a more involved change.
Tthis breaking change within the web-validation i would consider
acceptable because it should have been a Future in the first place -
wouldnt you agree?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1816 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABXDCXRKHRFRZZB5MYW3NDSUXIGRANCNFSM4UXANPLQ>
.
|
@vietj you agree with my assesment regarding @slinkydeveloper as far as i understood the vertx-schema implementation triggering a validation by i.e. |
yes I do agree with the proposal.
…On Mon, Dec 14, 2020 at 6:44 PM DemonicTutor ***@***.***> wrote:
@vietj <https://github.com/vietj> you agree with my assesment regarding Future<>
getDefaultValue() ?
@slinkydeveloper <https://github.com/slinkydeveloper> as far as i
understood the vertx-schema implementation triggering a validation by i.e.
s.validateAsync(null) does resolve the RefSchema - what did i miss here?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1816 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABXDCRMTLWKJTGCLEB6XHTSUZFJRANCNFSM4UXANPLQ>
.
|
It does, but not deeply. Which means that if you have a ref schema, which references to another schema that contains the In fact, that One idea I have to fix it is to convert these functions in vertx-json-schema async: https://github.com/eclipse-vertx/vertx-json-schema/blob/master/src/main/java/io/vertx/json/schema/Schema.java#L88 |
hmm... if i remember correctly this therefore my change of actually calling it makes the difference that it solves the If i would go for a "correct fix" i would try to only provide async methods from vertx-schema but that would really break the API - on the other hand i would argue that having sync/async if sync just works in "some specific cases" is a confusing API and leads to more headaches in the long term than breaking it. |
That's the issue, a 2 nested schema won't be fixed by this PR.
Yeah I agree, the whole default thing is weird and maybe it should be properly get done in vertx-json-schema first, and then benefit here |
Hey! Do you have any update on this issue? For our own needs ill apply my patch again so we are not blocked currently :) |
@DemonicTutor not yet unfortunately, I'll try to work on it asap from the vertx-json-schema side |
@DemonicTutor Can you check this PR? eclipse-vertx/vertx-json-schema#34 Also check out the added test, which should check your use case |
@slinkydeveloper Thanks! i will have a look ASAP and let you know |
…is a RefSchema Initialize the RefSchema by calling #validateAsync(null) first which causes it to internally resolve the schema Signed-off-by: Markus Spika <markus.spika@gmail.com>
Signed-off-by: Markus Spika <markus.spika@gmail.com>
@slinkydeveloper finally found the time to try it and it worked for me (with this update) updated my PR to accomodate your changes - thats how it should look right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've merged the PR in json schema, let's wait for the snapshot to build and i'll retrigger tests here
@DemonicTutor thank you so much for your help! |
@slinkydeveloper awesome ! :) |
given a yaml:
using
io.vertx.ext.web.openapi.RouterBuilder
and sendingGET /tryout
the schemaValidation will blow up with the noted exception becausenamespace
isnull
and callinggetDefaultValue()
on the schema before any validation fails because its aRefSchema
and has not been resolved yet.