express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

JSON in queries defined to be JSON object produces "must be object" error

Open danwdart opened this issue 2 years ago • 1 comments

Describe the bug Using content.application/json to describe a JSON object within a query string just gives "must be object" error, even with swagger ui

To Reproduce Have the following or similar inside the parameters section of a get schema:

        - name: a
          required: true
          in: query
          content:
            application/json:
              schema:
                type: object
                properties:
                  b:
                    type: string
                  c:
                    type: string
                  d:
                    type: string
                required: ["b", "c", "d"]

Run and try to hit the endpoint with ?a={"b":"b","c":"c","d":"d"} or open the inbuilt swagger ui server, even this gives examples which makes its own server fail in the same way.

Actual behavior validator barfs with "a must be object"

Expected behavior validation successful passing in the correct object to the request

danwdart avatar May 23 '23 16:05 danwdart

Workaround: pass as string and validate with some other library once you get into the request, but this is suboptimal as this library was supposed to do that part.

danwdart avatar Jun 15 '23 10:06 danwdart