Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`

Aperta Adatta ai principianti
#8,701 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ousamabenyounes ci sta già lavorando.

Dal 16/10/2026.

  • #8724 di @ousamabenyounes — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
80/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
openapi, php
Ambito
api

Direzione di ricerca

Il problema è indicato nell'issue: JsonApi\JsonSchema\SchemaFactory::buildSchema(), dove alle definizioni degli item viene assegnato il loro properties. Leggi quel metodo, poi aggiungi type con valore object accanto a quell'assegnazione, ma solo per gli schemi degli item. È completato quando la specifica esportata con bin/console api:openapi:export mostra "type": "object" su Book.jsonapi, Order.jsonapi, Order.OrderInput.jsonapi e OrderLine.jsonapi, e i test esistenti sugli schemi JSON:API continuano a passare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

API Platform version(s) affected

4.4.4

Description

The JSON:API resource document schemas, such as Book.jsonapi and the input schemas like Order.OrderInput.jsonapi, have only a properties key at the top level. They have no type: object.

A schema without type also accepts a string, number, array or null, because properties applies only to objects. Validators and fuzzers that generate requests from the spec (for example Schemathesis) then send bodies like "foo" or 42, which the API never accepts. The nested data objects already declare "type": "object". Only the top level is missing it.

How to reproduce

Any resource with the jsonapi format shows it, for example the Book resource from #8699. Generated schema:

"Book.jsonapi": {
  "properties": {
    "data": { "type": "object", "properties": { "...": "..." } }
  }
}

In a minimal app with the resources from #8698 and #8699, these four schemas have no type: Book.jsonapi, Order.jsonapi, Order.OrderInput.jsonapi, OrderLine.jsonapi.

Expected: every *.jsonapi document schema declares "type": "object".

Possible Solution

In JsonApi\JsonSchema\SchemaFactory::buildSchema(), set $definitions[$definitionName]['type'] = 'object' next to the properties assignment for item schemas.

Additional Context

Checked on api-platform/core v4.4.4, Symfony 7.4, PHP 8.5, in an empty Symfony app. The code of JsonApi\JsonSchema\SchemaFactory on main is the same as in v4.4.4.

The app has only FrameworkBundle, TwigBundle and ApiPlatformBundle, with this config:

$c->extension('api_platform', [
    'mapping' => ['paths' => ['%kernel.project_dir%/src/ApiResource']],
    'formats' => ['jsonapi' => ['application/vnd.api+json']],
    'docs_formats' => ['jsonopenapi' => ['application/vnd.openapi+json']],
    'doctrine' => ['enabled' => false],
]);

The spec comes from bin/console api:openapi:export.

Lingua principale
PHP
Stelle
2.6k
Fork
989
Merge medio
1g 23h
PR unite (30g)
102

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di api-platform/core

Tutte le issue di api-platform/core

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.