Skip to content

oneOf in path params is causing validation errors when using OAS 3.0 #458

Description

@adamsosterics

I have the following spec:

openapi: 3.0.1
paths:
  /accounts/{id}:
    get:
      operationId: getAccountId
      summary: Get the details of an account
      parameters:
        - name: id
          in: path
          required: true
          schema:
            oneOf:
              - type: integer
              - type: string
                enum: [current]

When validating e.g. GET /accounts/1 request, I get an Path segment is invalid: value at '/id' is not an integer. value at '/id' is not one of: ["current"] error.
The following schema for the path parameter already reproduces the issue:

oneOf:
  - type: integer

The following schema does not give a validation error:

type: integer

The parsed_request in /lib/openapi_first/validators/request_parameters.rb:15 in the case of a schema using oneOf:
#<data OpenapiFirst::ParsedRequest path={"id"=>"1"}, ...>, without oneOf: #<data OpenapiFirst::ParsedRequest path={"id"=>1}, ...>, that could cause the path param to be invalid.

I believe the spec above using the schema with the oneOf is valid and should not give validation errors for requests like GET /accounts/1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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