You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
Basically, it makes sense for JSON API servers to validate that there is an ID in all data it deals with, BUT there are situations where you don't want to have to see this ID after you load some data.
For instance, I have an example where my server returns a dictionary that corresponds to the keyword arguments to plotly.plot(), but it won't accept an ID field in the kwargs.
My current hack is this:
class EphemeralSchema(Schema):
id = f.String(dump_only=True)
data = EphemeralSchema(unknown=EXCLUDE).load(response.json)
However, this means I have to use unknown=EXCLUDE, which I don't actually want to do (I want to include arbitrary kwargs). I also can't use exclude=['id'], because that will trigger json-api's schema validation.
What is the best solution here? I'm happy to write a PR, but I need a little guidance on how to best implement this.
The text was updated successfully, but these errors were encountered:
@TMiguelT Did you ever figure out a way to do this? I need to do something similar and can't figure out a way besides unknown=EXCLUDE (which I don't want to do).
Following on from discussion here: json-api/json-api#1427.
Basically, it makes sense for JSON API servers to validate that there is an ID in all data it deals with, BUT there are situations where you don't want to have to see this ID after you load some data.
For instance, I have an example where my server returns a dictionary that corresponds to the keyword arguments to
plotly.plot()
, but it won't accept an ID field in the kwargs.My current hack is this:
However, this means I have to use
unknown=EXCLUDE
, which I don't actually want to do (I want to include arbitrary kwargs). I also can't useexclude=['id']
, because that will trigger json-api's schema validation.What is the best solution here? I'm happy to write a PR, but I need a little guidance on how to best implement this.
The text was updated successfully, but these errors were encountered: