Swagger-ui: Required formData parameters are not checked on form validation (OAS 3.0)

Created on 20 Aug 2019  Â·  3Comments  Â·  Source: swagger-api/swagger-ui

Q&A

  • OS: Linux (Ubuntu 18.04)
  • Browser: Chromium
  • Version: 76.0.3809.100
  • Method of installation: pip install connexion[swagger-ui]
  • Swagger-UI version: 3.22.3
  • Swagger/OpenAPI version: OpenAPI 3.0

Describe the bug you're encountering

Normally, on the swagger UI, required parameters are checked on the form validation, like this (red background):

image

But when it comes to required formData parameters, they are not checked on the form validation (no red background):

image

To reproduce...

Try the below snippet on https://editor.swagger.io/

openapi: 3.0.1

info:
  title: Test
  version: 1.0.0

paths:

  /survey/{surveyId}:
    get:
      parameters:
      - name: surveyId
        in: path
        required: true
        schema:
          type: integer
      responses:
        200:
          description: successful operation

  /survey:
    post:
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                name:
                  type: string
                fav_number:
                  type: integer
              required:
                - name
      responses:
        200:
          description: survey created

I took this example from the Swagger documentation: Describing Request Body → Form Data.

Expected behavior


Just like the required path parameter, I expected the formData parameter to be checked on the form validation (red background if the parameter is empty).

Additional context or thoughts


The issue #3747 may be related but I think it applies only for path parameters and not for formDataones.

Thanks!

Most helpful comment

Duplicate of #5181.

All 3 comments

Duplicate of #5181.

I'm experiencing the same problem, I think is not duplicate. I tried the example from 4899.

On edito.swagger.io:

  1. this required works:

    parameters:
      - name: petId
        in: path
        description: ID of pet that needs to be updated
        required: true
        schema:
          type: integer
          format: int64
    
  2. this doesn't:
    yaml requestBody: content: application/x-www-form-urlencoded: schema: type: object properties: name: type: string description: Updated name of the pet required: - name

Hi @catapimba, this problem is tracked in #5181.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ankon picture ankon  Â·  4Comments

LaysDragon picture LaysDragon  Â·  3Comments

ilnurshax picture ilnurshax  Â·  3Comments

prabhat1790 picture prabhat1790  Â·  3Comments

sgyang picture sgyang  Â·  4Comments