Repository navigation
Conversation
API Platform derives `default` from the PHP initializer, so `private string $slug = '';` next to a slug Assert\Regex yields `default: ""` that the property's own `pattern` rejects. Form clients start from that default and show a validation error before anyone typed. InvalidDefaultSchemaDecorator removes such defaults (pattern, minLength, maxLength, enum), walking properties, nested objects and allOf/anyOf/oneOf. On by default, switch off with schema_default_cleanup.enabled: false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
API Platform derives a property's schema
defaultfrom its PHP initializer. A common entity shapetherefore yields a schema that contradicts itself:
Form clients (the Vue admin UI with Jedison) start create forms from the schema defaults and report a validation error on a form nobody has touched yet. On one za7 stack this affected 9 properties across 7 resources (
slug,key,namefields of the menu, content, MCP-endpoint and neuron-ai bundles).Change
New
InvalidDefaultSchemaDecorator(decoratesapi_platform.json_schema.schema_factory, priority 5) removes adefaultwhen the property schema itself rejects it:pattern(ECMA pattern compiled as PCRE with/u; a pattern PHP cannot compile keeps its default rather than guessing)minLength/maxLengthfor string defaultsenumIt walks
properties, nested object properties andallOf/anyOf/oneOfbranches, so the.jsonldread schemas (properties insideallOf[1]) are covered too. Valid defaults are untouched; server-side validation is unchanged.On by default, since it only removes contradictions;
schema_default_cleanup.enabled: falseswitches it off.Verification
title: "",status: "draft").🤖 Generated with Claude Code