JSON Schema: possible incompatibilities when plugging symfony/json-schema
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 8/100
Piste de recherche
This is a design survey, not a single fix. Start with ShortNameDefinitionPolicy, DefinitionPolicyInterface, SchemaDocument and DefinitionProcessorInterface, which the issue names as the points where the output would diverge. Done means agreeing which differences API Platform will accept, which it will adapt through an extension point, and which need follow-up issues, with the decision recorded on this thread.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
Follow-up of #8696: what changes if api-platform/json-schema uses symfony/json-schema (https://github.com/symfony/symfony/pull/66685).
1. Dependency constraints
- The component first ships in Symfony 8.2 (its
CHANGELOG.md). - It requires PHP
>=8.4.1, API Platform requires PHP>=8.2. - It requires
symfony/type-info^7.4.6|^8.0.6, API Platform requires^7.4 || ^8.0.
2. Output changes with the default configuration
- JSON Schema output uses
$defsand#/$defs/instead ofdefinitionsand#/definitions/(Dialect::jsonSchema202012()). OpenAPI output keeps#/components/schemas/. $schemaishttps://json-schema.org/draft/2020-12/schemainstead ofhttp://json-schema.org/draft-07/schema#.- There is no Swagger 2.0 dialect. API Platform still has the deprecated
--spec-version=2export. - Definition names (
ShortNameDefinitionPolicy) put the format in aformat.<format>part instead of a.jsonldsuffix, append the direction (input/output), and have no.partial,.jsonMergePatchor_noidsuffix. Example:Dummy-read_format.jsonld_outputinstead ofDummy.jsonld-read. A customDefinitionPolicyInterfacecan produce other names. - With a direction, write-only properties are removed from output schemas and read-only properties from input schemas. API Platform keeps them, flagged
readOnly/writeOnly. The component only emits these flags without a direction. - Output schemas require properties that are always initialized (default value, promoted or constructor-set). Otherwise, mandatory constructor arguments are required. API Platform uses
ApiProperty::isRequired()(validation metadata or explicitrequired), with norequiredfor partial updates. callableandresourceproperties are removed. API Platform describes them astype: string.- Examples are
examples: [value]on JSON Schema 2020-12 and OpenAPI 3.1, andexampleonly on OpenAPI 3.0 (Dialect::example()). API Platform emitsexample. - Descriptions come from the PHPDoc. Values API Platform takes from metadata (
ApiPropertydescription,deprecated,externalDocsfromtypes, operation description) are not produced. - Ramsey
UuidInterfaceis not handled. API Platform describes it asformat: uuid.
3. Extension points
- The extension signatures have no operation or
ApiProperty. API Platform data has to go throughConfiguration::$context, which is neither part of the definition fingerprint nor of the default name. Any shape that depends on it (operation, partial update,gen_id) must be encoded in the name by a custom policy, or two shapes share one definition. SchemaDocument::reserve()anddefine()are@internal, and aDefinitionProcessorInterfacecan only change the definition it receives. Shared definitions such asHydraItemBaseSchemacannot be registered from an extension.- The root collection schema is not passed to any extension, so
hydra:member, JSON:APIdata/links/metaand HAL_embeddedstay in an outer decorator. - A
PropertySchemaProviderInterfacecan return user-defined schemas (ApiPropertyschema,jsonSchemaContext,openapiContext), but enrichers still run on top. API Platform leaves user-defined schemas untouched. - A definition is built for the first occurrence of a name, so shapes depending on the parent property (e.g.
gen_idon an embedded relation) collide: "a difference coming only from the parent cannot be detected and the first occurrence wins" (DefinitionPolicyInterface). - A
SchemaDocumentthrows when used with anotherrefPath, so JSON Schema (#/$defs/) and OpenAPI (#/components/schemas/) output cannot share one document.
Fits the existing extension points
- IRI references for non-embedded relations:
ClassSchemaResolverInterfacewithDefinitionParent. - Definition names:
DefinitionPolicyInterface. - Input/output DTOs: caller side.
- Validator constraints: built-in
ValidatorPropertySchemaEnricher. - Definitions shared across OpenAPI operations:
SchemaDocument,Dialect::openApi30()/openApi31(). - Eloquent models: the generator takes a
PropertyInfoExtractorInterface.
- Langage dominant
- PHP
- Étoiles
- 2.6k
- Forks
- 987
- Merge moyen
- 1 j 22 h
- PR mergées (30 j)
- 87
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de api-platform/core
-
API Platform ignores array shapes in the JSON SchemaPeut-être pris @afraca l’a pris il y a 3 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
api-platform/core#8766 ·
Les mainteneurs répondent en général sous 1 jour
-
SortFilter generates unsupported array form for parametersPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
api-platform/core#8744 ·
Les mainteneurs répondent en général sous 1 jour
-
JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`Peut-être pris @ousamabenyounes l’a pris il y a 12 jours. Ouverte
Difficulté 2/5 Moins d'une heure Accessibilité débutants 80/100
api-platform/core#8701 ·
Les mainteneurs répondent en général sous 1 jour
-
Doctrine ORM/ODM resource metadata collection factory runs outside the metadata cache since 4.2.16 (priority -50 vs `.cached` at -10)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
api-platform/core#8769 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 20/100
api-platform/core#8765 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de api-platform/core
Issues similaires
-
bug review needed
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
OpenMage/magento-lts#5816 ·
Les mainteneurs répondent en général sous 2 jours
-
priority:low type:docs
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
crazy-goat/rabbit-stream#958 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
nextcloud/richdocuments#6250 ·
Les mainteneurs répondent en général sous 1 jour
-
sync-en
Difficulté 1/5 1-3 heures Accessibilité débutants 83/100
Les mainteneurs répondent en général sous 1 jour
-
sync-en
Difficulté 1/5 Moins d'une heure Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour