Skip to content

Resources with optional id #74

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

Open
genbattle opened this issue Jul 20, 2020 · 0 comments
Open

Resources with optional id #74

genbattle opened this issue Jul 20, 2020 · 0 comments

Comments

@genbattle
Copy link

Thanks for providing this crate, I've found it really useful as a base for my jsonapi implementation.

One problem that I've run into is that the jsonapi spec allows id to be optional for create operations where an id will be generated. This library requires that all Resource objects have an id and they fail to serialize from any json resource representation that doesn't include an id field.

This might be achievable by expanding the PrimaryData definition to add an option which takes some kind of PartialResource or something. The id field of the Resource struct could be make optional, but that would violate the jsonapi spec in every case except this specific one.

I'm not sure what the right answer is, but I would appreciate it if this use case can be supported. For now I'm using dummy id values in my create requests as a workaround, but it doesn't match the behavior of other APIs we have that are implemented in other languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant