JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

JR isn't letting me send `meta` as a record property, despite it allows in jsonapi.org

Open
#1,040 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Enhancement
Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

Data:

> POST /v1/ayments HTTP/1.1
> Host: commerce.laurelandwolf.local
> Accept-Encoding: deflate, gzip
> Content-Type: application/vnd.api+json
> Accept: application/vnd.api+json
> Content-Length: 364
| {
| 	"data": {
| 		"type": "payments",
| 		"attributes": {
| 			"token": "tok_visa"
| 		},
| 		"relationships": {
| 			"chargeable": {
| 				"data": {
| 					"id": "1",
| 					"type": "requests"
| 				}
| 			}
| 		},
| 		"meta": {
| 			"request": {
| 				"shipping-cents": 10000,
| 				"shipping-currency": "USD"
| 			}
| 		}
| 	}
| }

Response:

{
	"errors": [
		{
			"title": "Param not allowed",
			"detail": "meta is not allowed.",
			"code": "105",
			"status": "400"
		}
	]
}

jsonapi.org specification:

Creating Resources

A resource can be created by sending a POST request to a URL that represents a collection of resources. The request MUST include a single resource object as primary data. The resource object MUST contain at least a type member.

Resource Objects

"Resource objects" appear in a JSON API document to represent resources.

A resource object MUST contain at least the following top-level members:

  • id
  • type

Exception: The id member is not required when the resource object originates at
the client and represents a new resource to be created on the server.

In addition, a resource object MAY contain any of these top-level members:

  • attributes: an [attributes object][attributes] representing some of the resource's data.
  • relationships: a [relationships object][relationships] describing relationships between
    the resource and other JSON API resources.
  • links: a [links object][links] containing links related to the resource.
  • meta: a [meta object][meta] containing non-standard meta-information about a
    resource that can not be represented as an attribute or relationship.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the POST request from the issue and trace how the resource object's top-level members are validated. Confirm the JSON:API resource-object handling rejects meta, then add coverage for this payload and verify that a valid resource with meta is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.