For JSON:API, the ID is not required in the POST request
API Platform version(s) affected: 4.0.4
Description
According to the JSON:API documentation, an ID is not required in a POST request, but Api Platform requires it in OpenAPI documentation.
Can this be resolved so that the ID is not mandatory in a POST request? It also throws an error when I include an ID.
I wouldn't create a new issue, but I don't think the link in the response header is good either:
If you didn't disable JSON-LD, this link is expected for autodiscoverability of the Hydra docs.
If you didn't disable JSON-LD, this link is expected for autodiscoverability of the Hydra docs.
I think I turned it off:
Indeed, that's a bug then!
I’ve tried to achieve a setup where the "ID" field would be removed (or mark as not required) specifically for the POST endpoint in the ApiPlatform\JsonApi\JsonSchema\SchemaFactory. Unfortunately, I’ve only found partial solutions because the schema is built once for the model, and I’m unsure how to configure the POST endpoint to use a different schema (one without the ID) compared to the others. According to the JSON:API specification, the ID can be generated on the client side, making it possible to send the ID in a POST request. However, the API Platform does not support this—it throws an exception if I include an ID.