NelmioApiDocBundle
NelmioApiDocBundle copied to clipboard
Swagger UI does not display value for an Example with example set to zero
I'm using a slightly older setup:
"require": {
"php": "^7.2",
"ext-ctype": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-mongodb": "*",
"ext-yaml": "*",
"aws/aws-sdk-php-symfony": "^2.6.1",
"beberlei/doctrineextensions": "^1.3.0",
"doctrine/doctrine-bundle": "^2.7.2",
"doctrine/mongodb-odm": "^2.4.3",
"doctrine/mongodb-odm-bundle": "^4.5.3",
"doctrine/orm": "^2.14.3",
"jms/serializer-bundle": "*",
"knplabs/knp-snappy": "^1.4.2",
"knplabs/knp-snappy-bundle": "^1.8.0",
"lexik/jwt-authentication-bundle": "^2.19.1",
"mongodb/mongodb": "^1.11.0",
"nelmio/api-doc-bundle": "^4.11.1",
"nelmio/cors-bundle": "^2.3.1",
"phpoffice/phpspreadsheet": "^1.19.0",
"ramsey/uuid": "^4.2.3",
"symfony/asset": "^5.4.21",
"symfony/console": "^5.4.26",
"symfony/dotenv": "^5.4.22",
"symfony/framework-bundle": "^5.4.26",
"symfony/messenger": "^5.4.26",
"symfony/monolog-bundle": "^3.8.0",
"symfony/runtime": "^5.4.26",
"symfony/translation": "^5.4.24",
"symfony/twig-bundle": "^5.4.27",
"symfony/validator": "^5.4.26",
"symfony/yaml": "^5.4.23"
},
I'm defining a parameter with example set to zero:
* @OA\Parameter(
* name="workInstructionImagesPerPage",
* in="query",
* description="Number of work instructions per page.",
* required=true,
* @OA\Schema(type="integer"),
* @OA\Examples(example="0", value="0", summary="No images."),
* @OA\Examples(example="1", value="1", summary="Single image per page."),
* @OA\Examples(example="2", value="2", summary="Two images per page."),
* @OA\Examples(example="3", value="3", summary="Three images per page.")
* )
That results in the following Swagger UI HTML:
The zero value is not shown in the input. Instead the placeholder appears:
I can workaround by moving the line to the bottom:
* @OA\Parameter(
* name="workInstructionImagesPerPage",
* in="query",
* description="Number of work instructions per page.",
* required=true,
* @OA\Schema(type="integer"),
* @OA\Examples(example="1", value="1", summary="Single image per page."),
* @OA\Examples(example="2", value="2", summary="Two images per page."),
* @OA\Examples(example="3", value="3", summary="Three images per page."),
* @OA\Examples(example="0", value="0", summary="No images.")
* )
That results in the following Swagger UI HTML with the same(!) select but correct input value:
The zero value is shown:
But having the zero value at the top does not seem to be the problem. When adding another line with zero value but a different example name...
* @OA\Parameter(
* name="workInstructionImagesPerPage",
* in="query",
* description="Number of work instructions per page.",
* required=true,
* @OA\Schema(type="integer"),
* @OA\Examples(example="0", value="0", summary="No images."),
* @OA\Examples(example="no", value="0", summary="No images2."),
* @OA\Examples(example="1", value="1", summary="Single image per page."),
* @OA\Examples(example="2", value="2", summary="Two images per page."),
* @OA\Examples(example="3", value="3", summary="Three images per page.")
* )
...the following HTML is rendered:
@pascalf22 used a similar example in his issue but apparently without problems: https://github.com/zircote/swagger-php/issues/1145