swagger-api / swagger-api/swagger-ui

Describing parameter with 'content' not working when using array of objects

Open
#5,910 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

cat: try-it-out specification: 3.x
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: Ubuntu 18.04
  • Browser: chrome
  • Version: 80.0.3987.87
  • Method of installation: dist assets
  • Swagger-UI version: 3.25.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: API Docs
  version: '1.0'
  description: ''
  termsOfService: ''
  contact: []
tags: []
paths:
  "/api/v1/example":
    get:
      description: Example endpoint
      parameters:
      - name: sort
        in: query
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                properties:
                  property:
                    type: string
                  direction:
                    type: string
Describe the bug you're encountering

Tried to use 'content' to describe a query parameter with type array of objects but its not working.

Example use case: ?sort=[{"property":"date", "direction":"ASC"}]

Expected behavior

image

Or like this (when clicking add item, it should add the single object schema):

image

Screenshots of what I got

Its all blank:
image

Related issue: https://github.com/swagger-api/swagger-ui/issues/4442
That issue solved the content rendering but only for simple json objects.

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 by reproducing the supplied OpenAPI 3.0 query-parameter example in Swagger UI 3.25.0 and compare it with the behavior described in related issue #4442. Trace the existing content rendering entry point and its tests, if present; done means an array of objects renders and can be added as the expected schema shows.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.