Skip to content

[12.x] Implement Stringable in Enum rule#58392

Merged
taylorotwell merged 1 commit intolaravel:12.xfrom
owenconti:make-enum-rule-stringable
Jan 16, 2026
Merged

[12.x] Implement Stringable in Enum rule#58392
taylorotwell merged 1 commit intolaravel:12.xfrom
owenconti:make-enum-rule-stringable

Conversation

@owenconti
Copy link
Contributor

This allows the Enum rule class to be stringable, serializing to the "in:" rule.

@owenconti owenconti changed the title Implement Stringable in Enum rule [12.x] Implement Stringable in Enum rule Jan 16, 2026
@alexbowers
Copy link
Contributor

alexbowers commented Feb 2, 2026

This PR has caused a breaking change in how Enums are produced in OpenAPI generation using Scramble.

Using Laravel 12.47.0 you get the following (truncated) output:

"AssignUserRoleResponseData": {
                "properties": {
                    "role": {
                        "$ref": "#/components/schemas/UserRole"
                    }
                },
                "required": [
                    "role"
                ],
                "title": "AssignUserRoleResponseData",
                "type": "object"
            },

After this PR, it now looks like this:

"AssignUserRoleResponseData": {
                "properties": {
                    "role": {
                        "enum": [
                            "admin",
                            "member",
                            "jobillan"
                        ],
                        "type": "string"
                    }
                },
                "required": [
                    "role"
                ],
                "title": "AssignUserRoleResponseData",
                "type": "object"
            },

When this is combined with Typegen generation, what this means is that previously where Enums would be exported and generated for us (we use Kubb for this), these are now inline, and the exported enums no longer are referrable in Typescript.

@alexbowers
Copy link
Contributor

For anyone else who comes here with the same issue; Scramble have released a fix for this on their end v0.13.11

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

Successfully merging this pull request may close these issues.

3 participants