Skip to content

Object and array path parameter serialization #43

@bali182

Description

@bali182

Hello again, I come to you with another issue. I'm trying to test an operation with path parameters.

Source of the schema is here: https://github.com/bali182/oats/blob/mocker-example/projects/openapi-e2e-test/kitchenSink.json

When sending primitve type parameters (boolean, string, or number) its working as expected. However when I'm sending array or object parameters I get an error:

[INFO ] < [400] {
    errors: [
      "Invalid path param arrayInPath. Expected value of type array but received 'a,b'",
      "Invalid path param objectInPath. Expected value of type object but received 's,str,b,false,n,1'",
    ],
  }

For this URL: /path-params/foo/1/true/a,b/s,str,b,false,n,1

This is the relevant part of the schema:

{
  "/path-params/{stringInPath}/{numberInPath}/{booleanInPath}/{arrayInPath}/{objectInPath}": {
    "parameters": [
      {
        "name": "stringInPath",
        ...
      },
      {
        "name": "numberInPath",
        ...
      },
      {
        "name": "booleanInPath",
        ...
      },
      {
        "name": "arrayInPath",
        "required": true,
        "in": "path",
        "style": "simple",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      {
        "name": "objectInPath",
        "required": true,
        "in": "path",
        "style": "simple",
        "schema": {
          "type": "object",
          "properties": {
            "s": {
              "type": "string"
            },
            "n": {
              "type": "number"
            },
            "b": {
              "type": "boolean"
            }
          }
        }
      }
    ],
    "get": {
      ...
    }
  }
}

Now for serialization, I'm using the simple method in this case described here:
https://swagger.io/docs/specification/serialization/
And I don't have explode on which is the default.

Am I misunderstanding the parameter serialization or is the mocker library expecting path parameters differently?

Thank you,
Balazs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions