swagger-ui: Swagger-ui 3.x no longer detects content type based on parameter

In swagger-ui 2.x if there was a formData parameter Content-Type:application/x-www-form-urlencoded would be set automatically. Example: screen shot 2017-08-16 at 1 35 21 pm

With the new swagger-ui 3.x the ContentType isn’t changed based on the presence of a formData parameter and sticks with content-type:application/json

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (15 by maintainers)

Most upvoted comments

Glad you got it working. We’ll give it a few more days before closing the issue.

That’s because you’re defining the payload as json. If you change it to application/x-www-form-urlencoded it’ll behave differently.

openapi: 3.0.0
info:
 title: Blog API
 version: 0.1.0
components:
 responses:
   UnauthorizedError:
     description: API key is missing or invalid
paths:
 /addPost:
   post:
     requestBody:
       required: true
       content:
         application/x-www-form-urlencoded:
           schema:
             type: object
             properties:
               title:
                 type: string
               body:
                 type: string
             required:
               - title
               - body
     responses:
       '200':
         description: default response
         content:
           application/json:
             schema:
               type: object
               properties:
                 title:
                   type: boolean