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

Wrong specification #40

Open
5ghz opened this issue Jan 19, 2018 · 4 comments
Open

Wrong specification #40

5ghz opened this issue Jan 19, 2018 · 4 comments

Comments

@5ghz
Copy link

5ghz commented Jan 19, 2018

jsonapi-requests is not JSON API compatible. Because if server returns this relationship obejct:

"relationships":{"vendor":{"links":{"self":"http://example.org/api/rest/admin/gateway-groups/14/relationships/vendor","related":"http://example.org/api/rest/admin/gateway-groups/14/vendor"}}}
Empty relationship object in ApiResponse

But in http://jsonapi.org/format/#document-resource-object-relationships

A “relationship object” MUST contain at least one of the following:

links: a links object containing at least one of the following:
    self: a link for the relationship itself (a “relationship link”). This link allows the client to directly manipulate the relationship. For example, removing an author through an article’s relationship URL would disconnect the person from the article without deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data. (See Fetching Relationships.)
    related: a related resource link
data: resource linkage
meta: a meta object that contains non-standard meta-information about the relationship

Project must support this.

@jgoclawski
Copy link
Member

Please provide a full code example or preferably a failing test. Right now I don't know if you use jsonapi-requests in ORM or in raw mode. In raw mode everything works as intended.

The following test uses raw "get" and passes. You should look at response.data.relationships instead of response.relationship.

def test_get_relationships(api_configuration, request_mock):
    valid_response = mock.Mock(status_code=200)
    valid_response.json.return_value = {
        'data': {
            'relationships': {
                'vendor': {
                    'links': {
                        "self": "http://example.org/api/rest/admin/gateway-groups/14/relationships/vendor",
                        "related": "http://example.org/api/rest/admin/gateway-groups/14/vendor",
                    }
                }
            }
        }
    }
    request_mock.return_value = valid_response
    response = request_factory.ApiRequestFactory(api_configuration).get('endpoint')
    assert response.data.relationships['vendor'] == data.Relationship.from_data({
        'links': {
            'self': 'http://example.org/api/rest/admin/gateway-groups/14/relationships/vendor',
            'related': 'http://example.org/api/rest/admin/gateway-groups/14/vendor'
        }
    })

@5ghz
Copy link
Author

5ghz commented Jan 19, 2018

ORM mode

@jgoclawski
Copy link
Member

@5ghz Please provide me with code example presenting the issue or (preferably) a failing test - with would greatly improve communication :)
Links might not be fully supported in ORM mode, but to better understand your use case, I need an example.

@5ghz
Copy link
Author

5ghz commented Mar 13, 2018

Good day, please review patch.

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

No branches or pull requests

2 participants