-
Notifications
You must be signed in to change notification settings - Fork 98
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
partial objects (missing attributes) #150
Comments
|
How do I determine the difference between "value not sent" and "set this value to Or, another way to ask the question, how do I implement PATCH, if bravado-core is going to set every value not delivered to Or yet another way to ask the question, where in the swagger spec does it say optional properties are to be treated as null? I think bravado-core is overreaching with this behavior. It should at least be configurable. |
Unless you use the optional |
I don't seem to be getting my point across. If a property is missing that is specified in a swagger JSON body parameter, bravado-core forces the value to None, setting it on the unmarshalled object even if it wasn't passed in the request. My reading of the spec says If a property is not required it is optional. Placing missing properties into the unmarshalled object (even with value None) renders them indistinguishable from sent properties. I've asked repeatedly, with this behavior how would I implement PATCH? If you think that through I hope you can see the problem: it is impossible to determine which properties were sent in the partial object since you cannot simply filter out properties with value None, as None may be a valid value sent from a client. I cannot find this behavior specified in the swagger spec and I believe bravado-core is overreaching with an assumption that a missing property should be added with value None. To be clear: I want any missing property from the request to be not present in the unmarshalled object. If not globally, there should be minimally a parameter or configuration option that turns off this behavior. |
Hey @dpopowich, we seem to be having a misunderstanding here. You need to distinguish between the spec (i.e. how data is being sent over the wire) and what you get if you use bravado-core to unmarshal objects for you. The design decision was made quite some time ago to make sure all attributes should be present, whether they were sent or not. If they were not sent then the value would be I've now repeatedly told you how to implement this. Have you ever actually tried it out? If an attribute has the value |
So, if a property has I'm using pyramid-swagger, which calls bravado-core. I want to be able to reference
But if just one property is marked with |
@dpopowich is this still an issue you're facing or are we having more of a theoretical discussion? I'd much rather tackle this as part of a larger Swagger 3.0 work unless you're running into real issues. |
First, my apologies for leaving off the detail of So, here's my situation: I am building a REST api with pyramid (and cornice) serving records from an ancient legacy RDB (wrapped by sqlalchemy). Nearly every table has nullable columns and these are not filtered out on request. The current consumer of the REST api is a single-page web app with the client data models managed with Backbone. Because nearly every model has nullable columns, my swagger schema objects have a lot of This issue, plus bravado-core not handling readOnly (or so it would appear - is this scheduled for inclusion?) and anyOf/oneOf not available until swagger 3 - I'm having a lot of difficulty expressing my API needs. |
Related to this issue (and let me know if I should create a new issue) is the non-use of |
I'm not yet completely sure I understand your needs fully, but at this point I think merging #152 makes sense. In regards to your last comment, |
If I have a definition like this:
And I reference this in a PUT spec:
When I call
PUT /foo/14
with a JSON body of:The unmarshalled python output from bravado-core is:
That is,
job
was missing, but bravado-core explicitly looks for missing properties and sets them on the object with aNone
value.I cannot find this behavior specified in the swagger spec anywhere. If it exists, can someone point me to this requirement (forcing missing properties to null) in the spec?
If this behavior is not required by the swagger spec and bravado-core is overreaching here, how about an option to allow partial objects?
Otherwise, how is someone supposed to provide PATCH or similar functionality?
The text was updated successfully, but these errors were encountered: