Repository navigation
Conversation
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.
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.