Skip to content

related must support JSON:API to-one object and null responses #51

Description

@artpar

Summary

daptin-cli related assumes JSON:API data is an array and rejects a valid
to-one relationship response object.

Reproduced with daptin-cli v0.9.0 / 56c4ba0 and Daptin v0.12.36.

Reproduction

Schema: ticket belongs_to project.

daptin-cli related ticket <ticket-reference-id> project_id

The server correctly returned JSON:API data: { ... } for the to-one relation.
CLI failed:

malformed related response: expected JSON:API data array

Expected behavior

  • Accept data object for to-one, array for to-many, and null for an empty
    nullable to-one relation.
  • Preserve table/JSON output and relation metadata.
  • --quiet prints the one target reference id or nothing for null.
  • Pagination flags should either be ignored/documented for to-one or rejected
    clearly.

Acceptance test

Cover belongs-to present/null and has-many empty/nonempty response shapes,
including --output json and --quiet.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions