Open NicoHaase opened 4 years ago
A further hint: there seems to be a distinction between regular URL parameters (defined in the route itself) and additional parameters.
When using this "Try out" on a route that must contain the parameter by the route definition itself (like @Route("/room/{ressource}")
), everything works as expected. The error reported above is related to a parameter defined using @OA\Parameter
with required=true
Annotation
* @OA\Get(
* path="/user/{id}",
* summary="Retrieve User",
* description="Retrieve User",
* tags={"User"},
* @OA\Parameter(ref="#/components/parameters/Identifier"),
* @OA\Response(
* response="200",
* description="User Entity",
* @OA\JsonContent(ref=@Model(type=User::class, groups={"userForm"})),
* )
* )
Config
nelmio_api_doc:
documentation:
components:
parameters:
Identifier:
name: id
in: path
description: Entity Identifier
schema:
type: integer
pattern: \d+
Result
{
"/user/{id}": {
"get": {
"tags": [
"User"
],
"summary": "Retrieve User",
"description": "Retrieve User",
"operationId": null,
"parameters": [
{
"$ref": "#/components/parameters/Identifier"
},
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "User Entity",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
}
}
}
}
In result identifier was added twice, as referenced parameter and as default parameter (string)
When i click "Try it out", fill id and "Execute", i get error in field "Required field is not provided"
Thanks for the report!
This is probably related to https://github.com/nelmio/NelmioApiDocBundle/pull/1740: the usage of $ref
for path parameters was broken.
It is not released yet, but will be soon. I'd like to merge php8 support in the master branch before.
Could you try whether it does indeed fix your issue please?
@GuilhemN I am currently at v4.8.2
version and can confirm that the query parameter is being required.
However, there is still similar problem with header parameter.
* @OA\Parameter(
* name="X-SOME-TOKEN",
* in="header",
* required=true
* )
Try out is still possible without filling required header value.
Using v4.0.0-BETA2, it is possible to submit a "Try out" request while a required field is not filled. The "Loading" animation spins and spins:
The error console provides information about this:
I had expected that the "Execute" button is disabled until all required fields are filled, or that some kind of warning pops up when clicking the button