-
-
Notifications
You must be signed in to change notification settings - Fork 214
Added Python implementation fastjsonschema #253
Conversation
Thanks for your hard work on your library. This is non ideal, as it's non standard. |
It mutates the input data. I know it's not good, but it's faster then do the copy all the time. Usually this is not a problem so I decided to keep it fast and write it to the documentation. |
In that case, I'm afraid I don't feel I can add it to the listing. |
It is done when explicitly asked. When the default feature is not used, it does not modify the data. :-) |
When you say
Do you mean when the |
Yes, I mean when the default keyword is not in the schema. I know it's not OK. :-) The decision here is done to keep it fast. The copy of the input data would slow the validation down a lot. Usually it's not a problem with the input data, actually it could be even a feature because it's better to not work with the raw input data anyway. If someone wants to keep the input data, he or she can easily duplicate it before the validation. The information about this behaviour is documented. But if this is blocker to have this library listed, well, don't merge it then. I just thought it would be good to have it here when someone is looking for some fast implementation, because many people do. |
You've chosen to implement something not in the specification (mutating the input based on default) and claimed you don't want to remove it because it makes it faster. Mutating the input data should be considered harmful unless it's something the user explicity asks to happen, otherwise they may be in for a nasty supprise! You've made an assumption about the schema authors purpose for using an annotation of Do you see why this is likely to be a problem for many users? Let me know if you decide to amend your implementation to follow the specification. |
I think it is reasonable that we require implementations to at least offer a strictly compatible option. We do allow implementations that are incomplete, but not that contradict the spec. @horejsek if you were to offer an option to either write in or ignore the value of the |
Something here reads to me like a misunderstanding... @horejsek you're aware that default isn't supposed to do anything right? It's hard to be faster than "do nothing" :) and when you say:
It reads a lot like you've misunderstood -- the choice isn't "mutate or not" -- the overall process of validation neither mutates its input nor generates any return value in any current draft. Just want to make sure you understood that and recognize that the behavior supposedly implemented and being discussed here is entirely a new feature (one against the recommendations of the spec). Apologies if I've misread things, but yeah that is how these comments read to me. |
Thanks, @Julian , that's a good explanation. |
@Julian Well, yes and no. In the specification is this sentence:
I understand it as it can be implemented or cannot. I decided to include it in the library as it's a nice feature and for speed optimisations (which is why I wrote my library in the first place) do what you don't like here at all. I don't like it either, but still I think it's good trade-off. So, the https://json-schema.org/latest/json-schema-validation.html#rfc.section.10.2 |
@horejsek unlike the capitalized MAY, SHOULD, and MUST, which have precise meanings defined by RFC 2119, lowercase "can" does not carry any sort of requirements. It's just an observation that it's possible to do something- in this case, it's talking about what sort of additional usage on top of a JSON Schema implementation is possible. So you can offer it as an extended feature that users can turn on (and many implementations do). But it is not part of the actual specification requirements, and doing it automatically means you are not in conformance. |
Ok. I will add the option to turn it on or off. Is OK for you to have strict version disabled by default? I would like to not do breaking change. |
No description provided.