Skip to content

[Bug]: Scramble API docs not updating when changing transformer or HasAllowedFilters, HasAllowedSorts #101

@OmkoBass

Description

@OmkoBass

What happened?

I have a model that implements both HasAllowedFilters and HasAllowedSorts.
I also have a Transformer for that model which returns objects that have their own properties.

When I open Scramble API docs there is no way to specify a filter or sort, nor can I see the proper response example that matches the Trasnformer.

How to reproduce the bug

Create a modal an add at the end of it HasAllowedFilters, HasAllowedSorts

Then add these two methods in your model class

public static function getAllowedFilters(): array
    {
        return [
            'name'
        ];
    }

    public static function getAllowedSorts(): array
    {
        return [
            'name'
        ];
    }

Open up the Scramble API docs and you will see that there is no way to specify the filter nor sort.

For the second issue, create a transformer and just specify an one-to-many or many-to-many relationship and the response in the Scramble API docs will not mirror the transformer.

public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'slug' => $this->slug,
            'description' => $this->description,
            'price' => $this->price,
            'tags' => $this->tags->pluck('name'),
            'category' => $this->category->name,
        ];
    }

Package Version

3.4

PHP Version

8.2

Laravel Version

12.0

Which operating systems does with happen with?

macOS

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions