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

For Forms: Enum Contains Default Against Configuration, and Default is Unsubmittable Anyways #6976

Closed
MarioIshac opened this issue Feb 20, 2021 · 3 comments · Fixed by #7004

Comments

@MarioIshac
Copy link

MarioIshac commented Feb 20, 2021

Q&A (please complete the following information)

  • OS: Ubuntu 20.04.1
  • Browser: Firefox, Chrome
  • Installation: Tested on editor.swagger.io
  • Swagger-UI version: 3.43.0
  • Swagger/OpenAPI version: OpenAPI 3.0.3

Content & configuration

openapi: 3.0.3
paths:
  /test:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema: 
              $ref: '#/components/schemas/TestBody'
components:
  schemas:
    TestBody:
      required:
        - test_enum
      type: object
      properties:
        test_enum:
          allOf:
            - $ref: "#/components/schemas/TestEnum"
    TestEnum:
      enum:
        - A
        - B

Plug into editor.swagger.io.

Describe the bug you're encountering

  1. Enum contains default even though no default was configured.
  2. Leaving default selected leaves request unsubmittable with red visual indicator, must manually select.

To reproduce

  1. Expand /test.
  2. Press Try it out.
  3. Press execute.
  4. See red visual indicator.

Expected behavior

Enum should not have default available in first place, but looking past this, the default should be submittable anyways. Instead, manual selection is required. Not sure if these bugs are related or separate.

Screenshots

Submission

Additional Context

Same issue as #3706 and #3890, both closed in 2017.

This applies to enums in form bodies, not as parameters (see below comments). So application/x-www-form-urlencoded and multipart/form-data are affected.

@mathis-m
Copy link
Contributor

valid Minimal Reproduction:
https://editor.swagger.io/?url=https://gist.githubusercontent.com/mathis-m/c3c097c16174acad5415affcc22886e1/raw/7cd158e43b1062aeb4c1eea5ffa88af7824cefc0/KCgSSD1Lqe.txt

openapi: 3.0.3
info:
  title: asd
  version: 0.0.1
paths:
  /test:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema: 
              $ref: '#/components/schemas/TestBody'
      responses:
        200:
          description: ok
components:
  schemas:
    TestBody:
      required:
        - test_enum
      type: object
      properties:
        test_enum:
          allOf:
            - $ref: "#/components/schemas/TestEnum"
    TestEnum:
      enum:
        - A
        - B

@mathis-m
Copy link
Contributor

mathis-m commented Feb 26, 2021

@MarioIshac Could you include multipart/form-data in the issues description and title because I could not reproduce this for parameters.

@mathis-m mathis-m mentioned this issue Feb 26, 2021
17 tasks
@MarioIshac
Copy link
Author

Thanks for fixing up my example to add the fields I missed, and will change title & description to include multipart/form-data (and also application/x-www-form-urlencoded, was able to reproduce w/ that).

@MarioIshac MarioIshac changed the title Enum Contains Default Against Configuration, and Default is Unsubmittable Anyways For Forms: Enum Contains Default Against Configuration, and Default is Unsubmittable Anyways Feb 26, 2021
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.

3 participants