Skip to content

[Bug]: JsonResource response for a newly created model documented as 200 instead of 201 #1071

@stayallive

Description

@stayallive

What happened?

When returning a JsonResource for a newly (in that request) created model Laravel returns a 201 but Scramble documents this as a 200 response. I expected this status code to be the correct one.

How to reproduce the bug

This is documented as a 200 response. In reality this is a 201 response.

$entity = new EntityModel;

// ... setting properties, doing other stuf etc.

$otherEntity->relation()->save($entity);

return EntityResource::make($entity);

Package Version

0.13.10

PHP Version

8.5.2

Laravel Version

12.48.1

Which operating systems does with happen with?

No response

Notes

Not sure this is fixable but otherwise it might be good to document this properly somehow since it can be pretty confusing. Or maybe I just completely missed the warnings about this, but it caught me off guard doing an implementation with my own spec 🤣

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