Skip to content

Conversation

@Anticom
Copy link
Contributor

@Anticom Anticom commented Oct 31, 2025

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