swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

In a x-www-form-urlencoded request body, string param value '1.0' is rewritten as '1'

Open sotty opened this issue 2 months ago • 3 comments

Q&A (please complete the following information)

  • OS: Windows 11
  • Browser: Chrome
  • Version: 122.0.x
  • Method of installation: via quarkus-swagger-ui, but also editor.swagger.io
  • Swagger-UI version: 5.20.8 .. 5.29.4
  • Swagger/OpenAPI version: OpenAPI 3.0.1

Content & configuration

Reproducible on https://editor.swagger.io/

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: Reproducer
  version: "1.0"
paths:

  /test:
    post:
      operationId: testOp
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/Example'
      responses:
        200:
          description: "Success"
          
components:
  schemas:
    Example:
      type: object
      properties:
        versionTag:
          type: string
          default: "1.0"

Describe the bug you're encountering

My API exposes a POST endpoint with a 'version tag' attribute of type string. When invoked through Swagger-UI "Try it out", the String "1.0" is parsed as the value "1", which is then passed to the server. Given that this a version tag, not a decimal number, the change is significant.

To reproduce...

Steps to reproduce the behavior:

  1. Use the given spec in editor.swagger.io
  2. Hit "try it out"
  3. See the actual CURL - the version tag value has been rewritten as '1'
curl -X 'POST' \
  'https://editor.swagger.io/test' \
  -H 'accept: */*' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'versionTag=1'

Expected behavior

The version tag parameter value should be '1.0':

curl -X 'POST' \
  'https://editor.swagger.io/test' \
  -H 'accept: */*' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'versionTag=1.0' 

Screenshots

Additional context or thoughts

Most likely related to #10047

sotty avatar Oct 18 '25 02:10 sotty

Hi, I've looked into this and would like to try fixing it. Can you please assign this to me?

Halcyonic-01 avatar Oct 19 '25 16:10 Halcyonic-01

Hey @KushagraSingh001-crypto!

I've assigned you to this issue ✅ Looking forward to PR 👀

robert-hebel-sb avatar Oct 30 '25 10:10 robert-hebel-sb

Hey @robert-hebel-sb ! I have raised a PR

Halcyonic-01 avatar Nov 10 '25 19:11 Halcyonic-01