Skip to content

oneOf within array's items description doesn't seem to validate/work as expected #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gerazenobi opened this issue Apr 11, 2019 · 0 comments
Labels
area/schema Indicates an issue on schema area

Comments

@gerazenobi
Copy link

gerazenobi commented Apr 11, 2019

I have the following query parameter described within a certain path:

      parameters:
        - in: query
          name: date
          required: true
          explode: true
          style: form
          schema:
            type: array
            items:
              oneOf:
                - type: string
                  format: date-time
                - type: string
                  pattern: '^now$|^in-(\d+)-(minutes|hours)$'
            example:
              - '2019-04-07T15:30:00.000Z'
              - 'in-60-minutes'

Though the parameter values are not being validated as I would expect: I can send any types (string, integer,...) and any format of string ( e.g 'non_valid_format') and the validation won't complaint about it.

Note that for example If I were to specify a homogeneous array (without specifying oneOf) the specified constraints work as expected and I get the expected error messages:

      parameters:
        - in: query
          name: date
          required: true
          explode: true
          style: form
          schema:
            type: array
            items:
              type: string
              pattern: '^now$|^in-(\d+)-(minutes|hours)$'

Correct response having providing wrong values:

Invalid parameter value for `date`: Value 2019-04-11T10:32:04.662007+00:00 does not match the pattern ^now$|^in-(\d+)-(minutes|hours)$
      parameters:
        - in: query
          name: date
          required: true
          explode: true
          style: form
          schema:
            type: array
            items:
              type: string
              format: date-time

Correct response having provided wrong values:

Invalid parameter value for `date`: Failed to format value in-60-minutes to format date-time

So my guess is that the problem lies only when using the constraints within a oneOf in an array's items section.

I am currently using openapi-core 0.8.0

@p1c2u p1c2u added the area/schema Indicates an issue on schema area label Sep 5, 2019
@p1c2u p1c2u closed this as completed Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/schema Indicates an issue on schema area
Projects
None yet
Development

No branches or pull requests

2 participants