swagger-api / swagger-api/swagger-ui

Query parameter content parsing error: TypeError: Cannot read properties of undefined (reading 'collectionFormat')

Open
#8,352 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A
  • OS: Windows 10 x64
  • Browser: Chrome
  • Version: Version 109.0.5414.74 (Official Build) (64-bit)
  • Method of installation: -
  • Swagger-UI version: web
  • OpenAPI version: OpenAPI 3.0.3
Content & configuration

Open https://editor.swagger.io/

To reproduce...
  1. Paste relevant spec (attached below)
  2. Open user agent dev tools
  3. Expand the only endpoint (POST: /store/order)
  4. Try it out leaving input untouched
  5. Click Execute button
  6. Inspect user agent console
Expected behavior

Request should be sent without console errors

Screenshots

image

Additional context or thoughts

This does not happen when an example is provided in conjunction with the schema object, for instance:

content:
          application/json:
            schema:
              oneOf:
                - type: integer
                  format: int64
                - type: string
                - type: object
            example: ''

I found no mentions whether example for current case is required or not in dedicated documentation section: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameter-object-examples

open-api.yaml

openapi: 3.0.0
info:
  version: 0.0.1
  title: Swagger Petstore
paths:
  /store/order:
    parameters:
      - name: storeFilter
        description: Named storeFilter
        required: false
        in: query
        content:
          application/json:
            schema:
              oneOf:
                - type: integer
                  format: int64
                - type: string
                - type: object
    post:
      summary: Petstore page
      responses:
        '200':
          description: Petstore page
          content:
            application/json:
              schema: {}
      tags:
        - store
tags:
  - name: store
    description: Access to Petstore orders

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied OpenAPI 3.0.0 specification in Swagger UI at editor.swagger.io, expand POST /store/order, and reproduce the error by executing the untouched query parameter. Trace the query parameter content parsing that reads collectionFormat; done means the request is sent without a console TypeError, including when the schema uses oneOf without an example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.