cdimascio / express-openapi-validator

🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification
MIT License
920 stars 211 forks source link

Serdes Does Not Work for Items in Request Parameters in Array #873

Open j-bellavista-flexidao opened 1 year ago

j-bellavista-flexidao commented 1 year ago

Describe the bug Serialization and deserialization seem to not be doing anything for request parameters that are inside an array. While individual string parameters with a custom formats work correctly, arrays containing strings with a custom format do not.

Actual behavior For the array parameter, the strings within it are not being serialized or deserialized according to the custom format format specified in the schema.

Expected behavior The expected behavior is that both individual string parameters and arrays of strings with a custom format should be serialized and deserialized correctly, following the custom format rules defined in the schema.

Examples and context This example works:

parameters:
  - name: time
    in: query
    required: true
    schema:
        type: string
        format: custom-date

This one doesn't:

parameters:
  - name: times
    in: query
    required: true
    explode: false
    schema:
        type: array
        items:
            type: string
            format: custom-date
j-bellavista-flexidao commented 1 year ago

It looks like this bug is similar to what was reported in issue #699. I checked out the fix that went in with PR #704 and thought it would cover this, but I'm still seeing the problem. I'm not super familiar with the codebase, but when I peeked at schema.preprocessor.ts, it struck me that the function doesn't seem to extract params from arrays. Maybe that’s the culprit?