swagger-api / swagger-api/swagger-ui

Example request body for multipart/form-data POST isn't used by "Try it out"

Open
#10,248 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: try-it-out Nice to have P3 type: bug Workaround available
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.1.0
info:
 title: Test
 version: '0.0.1'
paths:
 /example:
   post:
     summary: Example endpoint
     operationId: example_endpoint
     parameters: []
     requestBody:
       required: true
       content:
         multipart/form-data:
           schema:
             type: object
             required:
               - required_field
             properties:
               required_field:
                 type: string
                 minLength: 1
               optional_field:
                 type: string
             example:
               required_field: foo
     responses:
       "200":
         description: OK

Swagger-UI configuration options:

SwaggerUI({
 // I am using https://editor-next.swagger.io/
})
Is your feature request related to a problem?

Clicking the "Try it out" button for my example endpoint gives the following initial form state:
image

Instead of using the example provided.

Describe the solution you'd like

I would like the initial form state to be the following
image

(required_field="foo" and optional_field omitted) to reflect the example given.

Describe alternatives you've considered

I've played around with different ways of specifying the request body and the example. Nothing seems to produce this result in the swagger UI.

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 OpenAPI 3.1 definition and Swagger UI configuration included in the issue, then reproduce the behavior through the multipart/form-data endpoint's "Try it out" form. Done means the form initializes required_field with "foo" from the request-body example while leaving optional_field omitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.