Search code examples
phpswagger-uiopenapi

OpenApi for php doesn't render enum values correctly


I am building some documentation using OpenApi and Swagger, but I am unable to test it because of a js error.

I want to define a parameter that will accept specific values so I added enum in the schema attribute. I am defining the orderBy parameter in a GET request like this

*     @OA\Parameter(in="query", name="orderBy", required=false, allowEmptyValue=true, description="Sort type of results", examples={"asc", "desc"}, schema={"type": "string", "enum": {"asc", "desc"}, "default": "asc"})

When the documentation is generated I am getting the error below enter image description here

Developer tools

enter image description here


Solution

  • Removed examples attribute and it rendered properly.

    *     @OA\Parameter(in="query", name="orderBy", required=false, allowEmptyValue=true, description="Sort type of results", examples={"asc", "desc"}, schema={"type": "string", "enum": {"asc", "desc"}, "default": "asc"})