swagger-api / swagger-api/swagger-ui

add type to button elements

Open
#10,234 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: [e.g. macOS] Any
  • Browser: [e.g. chrome, safari] Chrome, Safari
  • Version: [e.g. 22] 5.18.2
  • Method of installation: [e.g. npm, dist assets] npm
  • Swagger-UI version: [e.g. 3.10.0] 5.18.2
  • Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0] OpenAPI 3.0
Content & configuration

Example Swagger/OpenAPI definition:

# [Online Swagger Pet Store](https://petstore.swagger.io)

Swagger-UI configuration options:

SwaggerUI({
  // nothing extra
})
?yourQueryStringConfig
Describe the bug you're encountering

Our Swagger UI React is wrapped under React Hook Form and whenever the Swagger expand spec is clicked (The down arrow) the whole form submits, this is because of missing type attribute in native <button> element. Request you to add type on your buttons like <button type="button" > to avoid any default submission.

This is a sample element currently -

To reproduce...

Steps to reproduce the behavior:

  1. Go to Pet Store
  2. Click on Inspect Element of "Down Arrow" of any endpoint like '/pet/{petId}/uploadImg
  3. Scroll down to the HTML Button element and see there is no Type attribute
  4. See missing attribute
Expected behavior

the tag should be present with attribute so that any Swagger UI under form submission works properly

Screenshots
Additional context or thoughts

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 by reproducing the issue in the Swagger UI React interface using the Pet Store example, then inspect the rendered expand-spec button shown in the report. Ensure the affected native buttons explicitly declare their intended type, and verify that expanding an endpoint inside a form no longer submits it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.