Skip to content
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

Omitting id in ResourceObject #107

Open
cincauhangus opened this issue Oct 9, 2020 · 5 comments
Open

Omitting id in ResourceObject #107

cincauhangus opened this issue Oct 9, 2020 · 5 comments

Comments

@cincauhangus
Copy link

Is it possible to omit the id in ResourceObject when making a request to create a new resource? From the JSON API spec, it allows id to be omitted when creating resources.

@f3ath
Copy link
Contributor

f3ath commented Oct 10, 2020

Good point. Looks like a missing feature.

@f3ath
Copy link
Contributor

f3ath commented Oct 13, 2020

Implemented in #108. Please take a look at v2.2.0 and let me know if that works for you.

Example: https://github.com/json-api-php/json-api/blob/master/test/NewResourceObjectTest.php

@cincauhangus
Copy link
Author

thank you, will check it out in a bit!

@cincauhangus
Copy link
Author

cincauhangus commented Oct 15, 2020

I've tested it out and I believe it would work for a typical insert operation. However, I realised my current code is also not per spec as well as I have multiple new resources in the data object, e.g.

{
    data: [
        { /*new resource*/ },
        { /*new resource*/ }
    ]
}

I believe the correct method is to adopt the atomic extension. Do you have plans to support this extension?

@f3ath
Copy link
Contributor

f3ath commented Jul 27, 2022

No such plans, but PRs are always welcomed. (I know, I'm super fast with my replies)

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

No branches or pull requests

2 participants