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

BelongTo relation generates single object for PATCH/POST but it expects an array #12

Open
bbrala opened this issue Aug 18, 2021 · 6 comments

Comments

@bbrala
Copy link

bbrala commented Aug 18, 2021

HasMany::make('answers', 'answers')->type('concession-answers'),

results in

{
  "data": {
    "type": "concession-answers",
    "id": "7"
  }
}

but should be

{
  "data": [{
    "type": "concession-answers",
    "id": "7"
  }]
}
@bbrala
Copy link
Author

bbrala commented Aug 18, 2021

ping @maartenpaauw @Rocksheep

@bbrala
Copy link
Author

bbrala commented Aug 18, 2021

I think the result should be as per spec:

# Array of Pets
type: array
items:
  $ref: '#/components/schemas/Pet'

Right not the it seems the data property is:

# Array of Pets
type: object
items:
  $ref: '#/components/schemas/Pet'

@bbrala
Copy link
Author

bbrala commented Aug 18, 2021

Couldn't fix it unfortunately, got lost in the code. Any change you could have a look?

@captnCC
Copy link

captnCC commented Aug 20, 2021

I tried to reproduce this bug, but in the implementation, the HasMany relationship between Post and Comment works as expected and produces

{
  "data": {
    "type": "array",
    "items": {
      "$ref": "#/components/schemas/resources.posts.relationship.comments.fetch"
    }
  }
}

Can you provide more context to the problem?

@bbrala
Copy link
Author

bbrala commented Aug 20, 2021

Check the related pr it proves the bug :)

@captnCC
Copy link

captnCC commented Aug 20, 2021

I'm a bit blind this morning, yes for the request bodies this was a real bug. But it should be fixed now, you can try it out with your branch for #13!

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