-
Notifications
You must be signed in to change notification settings - Fork 591
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
The serialized JSON Example do not pass against the schema #332
Comments
Wow, good catch! What do you think about using a common scheme, e.g. In the @fabiojose Do you want to open a PR for this one? In case you don't, I'm willing to help out. |
One could also change the spec to say This would also be more inline with current implementations, e.g. https://docs.microsoft.com/en-us/azure/event-grid/cloudevents-schema#cloudevent-schema I think I'd prefer to force the full URI, though. In many cases, that would map to a URL that can be explored, whether it is a website, a REST API, ... |
@cneijenhuis, personally I'd prefer the full URI too. The problem with relatives references is that require some custom JSON Schema validator, this is common for browsers, but not so common in programming libraries. All of them treats I think the best choice is to do some improvements on that examples. I will open a PR! ps: nice initiative, CloudEvents! congratulations! |
I tend to prefer "URI-reference" instead because to me this is really nothing more than a string and we're just putting a little bit of structure around it by making it a URI to encourage a fairly consistent pattern - but still allows for a ton of freedom. In the end I suspect a lot of people will just do strcmp on it, but if they do need to break it apart then URI-reference still provides enough consistency/standardization to make it easy to automate it. |
Is there any particular reason we don't simply define source as a string rather then try to force some particular syntax? Shouldn't the structure (and interpretation) be publisher specific; surely Amazon should be able to use their ARN and Microsoft a '/' delimited path-like construct without constraint? |
@JemDay I think that standardizing the structure has an advantage for middlewares that want to allow routing based on the PS: ARN is a non-registered scheme, but is a valid URI, as far as I can see. And Microsoft is using valid relative URLs. |
@cneijenhuis - I get your point but i'm unsure as to whether we should couple what the If there is such a desire then the field should be formally defined to meet that need; i personally dislike the URI-Reference approach as it feels a bit kludgy. Agree that ARNs are private but they do follow the URN model (at least as i understand it) - in fact a URN might be more appropriate for a source if the structure needed to be formally defined. |
@duglin Sorry for missing the call yesterday. I listened to the recording - I'm not entirely sure if everyone got the implication that relative URLs are disallowed. At least I got it wrong in my implementation, and I guess Microsoft too (@clemensv can you confirm?). I think we should call this out in the release notes for 0.2, even though it is not a change - or have another PR to force a discussion. |
@cneijenhuis what do you think about changing the spec to allow for relative URIs? |
I'm a bit confused... the spec defines Section 4.1 of RFC3986 defines "URI-reference" as:
And
And to complete it we have:
So to me URI can be just |
🤦♂️ Yes, as I said here #332 (comment) , according to RFC 3986 §4.1, I wasn't aware that However, I feel that it is an easy mistake to make. Now that I've put the time into finding all of that out, let me make a quick PR... 😉 |
Then validation against the schema produces the following error:
This is because of
source
value is/mycontext
, that is an invalid URI.A valid URI must have this format:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
. Checkout here: https://www.ietf.org/rfc/rfc3986.txtAccording to RFC 3986, Section 3, the
scheme
andhier-part
are required.Then, to work properly against the schema validation, I suggest an edit in the serialized JSON example, in
source
value example, changing it tofrom:/mycontext
adding the schemefrom:
, as follows:Or an adjustment in JSON Schema in
source
definition, changing it to another type instead ofURI
.The text was updated successfully, but these errors were encountered: