stoplightio / prism

Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.

Home Page:https://stoplight.io/open-source/prism

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

query parameter name with "[]" not work on prism proxy

absszero opened this issue · comments

It's allowed to send an array data via query name ends with [] on PHP.
Ex. http://127.0.0.1/foo.php?bar[]=1&bar[]=2

But prism proxy does not support query parameter name with "[]".

Steps to Reproduce

# openapi.yaml
openapi: 3.0.3
info:
  title: OpenAPI 3.0
  version: 0.1

paths:
  /pet:
    get:
      summary: Find pet by ID
      parameters:
        - name: petId[]
          in: query
          description: ID of pet to return
          required: true
          schema:
            type: array
            items:
              type: integer
      responses:
        '200':
          description: successful operation
prism proxy --errors openapi.yaml http://example
[11:06:16 AM] › [CLI] …  awaiting  Starting Prism…
[11:06:16 AM] › [CLI] ℹ  info      GET        http://127.0.0.1:4010/pet?petId%5B%5D=318
[11:06:16 AM] › [CLI] ▶  start     Prism is listening on http://127.0.0.1:4010
[11:06:20 AM] › [HTTP SERVER] get /pet ℹ  info      Request received
[11:06:20 AM] › [HTTP SERVER] get /pet ✖  error     Request terminated with error: https://stoplight.io/prism/errors#UNPROCESSABLE_ENTITY: Invalid request

I got a error message when open http://127.0.0.1:4010/pet?petId%5B%5D=318

{
   "type":"https://stoplight.io/prism/errors#UNPROCESSABLE_ENTITY",
   "title":"Invalid request",
   "status":422,
   "detail":"Your request is not valid and no HTTP validation response was found in the spec, so Prism is generating this error for you.",
   "validation":[
      {
         "location":[
            "query"
         ],
         "severity":"Error",
         "code":"required",
         "message":"Request query must have required property 'petid%5b%5d'"
      }
   ]
}

Environment

  • Version used: prism 5.5.2
  • Environment name and version: Firefox 121.0(64 bit)
  • Operating System and version (desktop or mobile): macOS 14.1 (23B74)