Skip to content

Error value.split is not a function when trying to analyze a param serialization with simple style #2710

@danielferromeral

Description

@danielferromeral

When I try to analyze with the proxy an array path param with style simple and explode true I get an error TypeError: value.split is not a function.

Context

I cannot validate the array as a param in the request.

Current Behavior

Given this enpoint in a openAPI 3.0.4

/codes/{codeIds}:
    get:
      tags:
        - code
      parameters:
        - in: path
          name: codeIds
          required: true
          schema:
            type: array
            items:
              type: integer
              minimum: 100
              maximum: 999
              example: 123
            minItems: 1
            uniqueItems: true
          style: simple
          explode: false
          example: 123,245,345
        - name: size
          in: query
          required: false
          description: Number of elemments to return
          schema:
            type: integer
            minimum: 0
            example: 10
        - name: page
          in: query
          required: false
          description: From where return elements
          schema:
            type: integer
            minimum: 0
            example: 0
      responses:
        '200':
          description: Users with that Codes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Users'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unathorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

When I run the query /codes/123,456?size=5&page=5

Then I got the following error:

[1:24:56 PM] › [HTTP SERVER] get /codes/123,456 ℹ  info      Request received

/opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/@stoplight/prism-http/dist/validator/deserializers/style/simple.js:20
    return value === '' ? [] : value.split(',');
                                     ^
TypeError: value.split is not a function
    at deserializeArray (/opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/@stoplight/prism-http/dist/validator/deserializers/style/simple.js:20:38)
    at deserializeSimpleStyle (/opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/@stoplight/prism-http/dist/validator/deserializers/style/simple.js:9:16)
    at /opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/@stoplight/prism-http/dist/validator/validators/params.js:31:19
    at /opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/lodash/lodash.js:13469:38
    at /opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/lodash/lodash.js:4967:15
    at baseForOwn (/opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/lodash/lodash.js:3032:24)
    at mapValues (/opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/lodash/lodash.js:13468:7)
    at /opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/@stoplight/prism-http/dist/validator/validators/params.js:27:77
    at /opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/fp-ts/lib/Option.js:211:71
    at pipe (/opt/homebrew/lib/node_modules/@stoplight/prism-cli/node_modules/fp-ts/lib/function.js:311:35)

Expected Behavior

The proxy should be able to analyze codeIds as an array without an error, and tell me if the style is correct.

Possible Workaround/Solution

I guess is a problem with the value field, probably value is not consider as a string so it doesn't have split() method.

Steps to Reproduce

openapi.yml
package-lock.json
package.json
server.js

  1. Run the server with npm run start
  2. Run the proxy with prism proxy openapi.yml http://localhost:3000 -p 3001 -v trace
  3. Execute curl curl --location 'http://127.0.0.1:3001/codes/123,456?size=5&page=5' \ --header 'Authorization: Bearer 1234'

Environment

Version used: Prsim 5.14.2
Node version: 24.4.1
Operating System and version (desktop or mobile): Mac 15.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions