Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Reset" button creates invalid inputs in the Try It Out form #9158

Open
eroushblizz opened this issue Aug 22, 2023 · 3 comments
Open

"Reset" button creates invalid inputs in the Try It Out form #9158

eroushblizz opened this issue Aug 22, 2023 · 3 comments

Comments

@eroushblizz
Copy link

eroushblizz commented Aug 22, 2023

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: Chrome / Firefox
  • Version: 115.0.5790.171 (Chrome)
  • Method of installation: Docker
  • Swagger-UI version: 3.18.3
  • Swagger/OpenAPI version: 3.0.3

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3
info:
  title: Test API
  version: 1.0.0
paths:
  /users:
    post:
      summary: Create a user
      description: Create a user, one of various ways
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/UserSource'
      responses:
        '204':
          description: Successfully opened document
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                properties:
                  output:
                    type: string
                    example: "Invalid request"
components:
  schemas:
    UserSource:
      type: object
      properties:
        name:
          description: Full name
          type: string
          example: "John Smith"
        badgeid:
          description: Badge number
          type: integer
          format: uint32
          example: 959310
        email:
          description: E-mail
          type: string
          example: "jsmith@business.com"
      minProperties: 1
      maxProperties: 1

Describe the bug you're encountering

When the Reset button is used on a Try It Out form with optional parameters with default values, it creates a strange invalid state on the form.

  • 'Send empty value' checkbox becomes checked, even though the form values were reset to their defaults
    -> normally, the checkbox is greyed out / off, when there is a value in the field (as it has no purpose if the field is populated)
  • The request it builds does not reflect the state of the fields - it doesn't send the repopulated default values, and it also doesn't send empty values (contrary to the checkbox states). If you manually re-enter one of the form values, it will send only that parameter, although the form looks like it would send all of them.

To reproduce...

Steps to reproduce the behavior:

  1. Try the provided yaml, e.g. in Swagger Editor online
  2. Expand the single POST request
  3. Click 'Try It Out'
  4. Click 'Reset'

Expected behavior

(1) Parameters should be reset to their default values in the UI
(2) "Send empty value" should be unchecked and disabled for all fields with default values set
(3) Clicking Execute should build a request with all parameters set to their values seen in the form

(Instead, only (1) is true.)

Screenshots

bug

@eroushblizz
Copy link
Author

eroushblizz commented Aug 22, 2023

(Note: the screenshot shows the state after I've taken two additional steps after the repro, to show how the request gets generated):
5. Re-enter "Badge number"
6. Click "Execute"

@aviral-badola9
Copy link

Hi Everyone, I have raised a PR [https://github.com//pull/9346] for this issue. Kindly take a look.

@seressakos
Copy link

Hello, can you give an update about the status of this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants