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

Aperta
#458 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
openapi, ruby
Ambito
api

Direzione di ricerca

The bug is in path parameter handling: lib/openapi_first/validators/request_parameters.rb around line 15 receives the path as a string when the schema uses oneOf, but as an integer when it uses type: integer. Start by reproducing with the spec in the issue and checking how the path value is coerced before validation. Done means GET /accounts/1 passes for a oneOf integer/enum path parameter, with a regression test added to the request validation specs.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Ruby
Stelle
222
Fork
27
Merge medio
17h 15m
PR unite (30g)
6

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ahx/openapi_first

Tutte le issue di ahx/openapi_first

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.