Repository navigation
Conversation
soyuka
force-pushed
the
feat/json-schema-kernel
branch
from
December 1, 2026 14:04
3842104 to
c9ed87d
Compare
soyuka
marked this pull request as ready for review
December 1, 2026 14:04
Work in progress for symfony/symfony#64279. Golden tests compare buildSchema() with generate() on the spiked component (json-schema-component @ 1e167b63d5f), which has to be autoloaded locally for now.
Nested resources get the Hydra item wrapper and their operation description from definition processors, the Hydra decorator keeps the root envelope. jsonld_nested_output_dto stays skipped until the 5.0 nested output DTO fix is merged up.
api_platform.json_schema.generator (off by default) swaps the base schema factory for the Symfony JsonSchema generator. Definition processors are autoconfigured, the Hydra item processor is tagged.
Resolvers, policies and processors receive the object type instead of the class name. CI requires the released component.
api-platform#8643, api-platform#8652 and api-platform#8653 are merged up, so their cases run on both paths again. The JSON:API and HAL goldens follow the schema fixes merged on main.
The property metadata describes array shapes with properties and required keys holding unresolved class references, which overrode the generated ones.
A service id or a callable resolves its groups at validation time, so the generator path describes the Default group like the base path, for the property metadata and for the definition name.
Symfony's discriminator support inlines an anyOf without a named definition nor an OpenAPI discriminator, so the generator path keeps it off and ports the base path behaviour in a definition processor: oneOf over the subtypes, an own branch for mapped parents, type property enums across nested maps, gated by resource polymorphism. Subtypes described at the root are named like nested definitions, as on the base path.
Hydra item base schemas referenced by nested definitions are only added when the generator is enabled, the collection description is back to main, and the generator-only item definition processor is registered with the generator for JSON-LD.
The component supports PHP 8.2, so every job installs it and runs the goldens on both paths; the generator job only keeps its generator-mode step. Hydra needs api-platform/json-schema 5.1 for the definition policy.
Keyed keyword lists instead of array_flip per property, a method instead of a closure per property, shared format and definition name constants, and a test cache directory per schema generator mode.
soyuka
force-pushed
the
feat/json-schema-kernel
branch
from
December 1, 2026 15:52
c9ed87d to
fa442b0
Compare
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.
Follows symfony/symfony#66685, the JsonSchema component got merged in 8.2 and it was seeded from our json-schema engine. This PR lets API Platform generate its schemas through
Symfony\Component\JsonSchema\SchemaGeneratorinstead of our ownSchemaFactory, withoutOperationleaking into the generation.It's opt-in for 5.1:
symfony/json-schemaneeds PHP 8.4 so it's only suggested, the old factory stays the default and enabling the option without the component throws aLogicException.How it plugs in:
GeneratorSchemaFactoryreplaces the baseapi_platform.json_schema.schema_factory, the Hydra/HAL/JSON:API/MCP decorators stay on top.Configuration::$context.ApiPlatformDefinitionPolicyso they don't change (declared group order is kept,.partial,.jsonMergePatch,_noid).#[AsJsonSchemaDefinitionProcessor], FrameworkBundle 8.2 autoconfigures the bare Symfony interfaces for its own generator ([FrameworkBundle][JsonSchema] Add JsonSchemaBundle symfony/symfony#66929) and we don't want those running on resources.Tests:
GoldenSchemaTestpins 46 cases (json, jsonld, jsonhal, jsonapi, mcp, input/output, partial, merge-patch, dialects...) and asserts the oldbuildSchema()and the newgenerate()produce the same document. A newphpunit-json-schema-generatorCI job installssymfony/json-schema:8.2.x-devand runs the goldens plus the JSON Schema / OpenAPI functional tests with the generator on.Draft until these 5.0 fixes found along the way merge up, the goldens skip around them: #8643, #8644, #8652, #8653. Laravel wiring is a follow-up.