Skip to content

Feature/json schema improvements#57609

Merged
taylorotwell merged 6 commits into
laravel:12.xfrom
Anticom:feature/json-schema-improvements
Nov 3, 2025
Merged

Feature/json schema improvements#57609
taylorotwell merged 6 commits into
laravel:12.xfrom
Anticom:feature/json-schema-improvements

Conversation

@Anticom

@Anticom Anticom commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Improve the current JSON schema implementation by the following:

  1. Add support for passing a backed enum to Type's enum method.
    Before:
    $schema->string('oneof')->enum(['a', 'b', 'c']);
    After:
    enum Options: string
    {
      case A = 'a';
      case B = 'b';
      case C = 'c';
    }
    
    $schema->string('oneof')->enum(Options::class);
  2. Add missing format for StringType.
    New:
    $schema->string('somedate')->format('date');

I didn't create an issue beforehand since I deemed those additions so minor.

The improved enum handling just makes sense looking at how Laravel supports this in various other places.
The missing format was added primarily to improve laravel/mcp.
Ref.: https://modelcontextprotocol.io/docs/learn/server-concepts#how-tools-work

Tests have been added.

Cheers,
Anticom

@taylorotwell taylorotwell merged commit a48282a into laravel:12.x Nov 3, 2025
66 checks passed
@Anticom Anticom deleted the feature/json-schema-improvements branch November 4, 2025 07:23
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.

2 participants