[Metadata] Incorrect api schema for path variable
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Start at src/Metadata/Resource/Factory/LinkFactory.php, in the public completeLink method, where uriTemplate path variables become Link objects; follow how the linked resource class/property is resolved and how Link schema is consumed when building OpenAPI path parameters. Reproduce with the #[Get('entities/{id}')] example from the issue and inspect the generated OpenAPI/Swagger JSON for the id path parameter. Done means the path parameter schema reflects the property's type/format, covered by tests around LinkFactory or OpenAPI generation; note the maintainer's pending answer on bug-vs-feature and which schema fields to carry over.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
API Platform version(s) affected: 5.0.2
Description
I noticed that all path variables have the default schema ['type' => 'string'], even when the variable is linked to a class property that does have a type / format.
This means that the swagger-ui will display it as a string input field, and miss the correct validation.
How to reproduce
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
#[Get('entities/{id}')]
readonly class Entity
{
public function __construct(
#[ApiProperty(identifier: true)]
public int $id,
) {
}
}
SwaggerUI
Possible Solution
The ApiPlatform\Metadata\Resource\Factory\LinkFactory class is used to generate Link instances based on things like the Operation's uriTemplate.
Here I can use the propertyMetadataFactory to get the schema of the linked property.
Questions
Is this something that should be fixed/implemented at all? For me this would save me from having to add the uriVariables parameter with Link classes everytime.
Is this considered a bug (pull request towards 5.0 branch), or a missing feature (pull request towards main branch?
- Lenguaje dominante
- PHP
- Estrellas
- 2.6k
- Forks
- 987
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 90
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de api-platform/core
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
api-platform/core#8650 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
api-platform/core#8649 ·
Los mantenedores suelen responder en 1 día
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
api-platform/core#8648 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
api-platform/core#8647 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
api-platform/core#8612 ·
Los mantenedores suelen responder en 1 día
Todos los issues de api-platform/core
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
extension/Commercial needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
crazy-goat/rabbit-stream#753 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
opensourcepos/opensourcepos#4743 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
OpenConext/OpenConext-engineblock#2129 ·
Los mantenedores suelen responder en 3 días