Swagger-ui: Requestbody x-www-form-urlencoded is not properly rendered

Created on 13 Jun 2018  路  21Comments  路  Source: swagger-api/swagger-ui

Q&A (please complete the following information)

  • OS: windows
  • Browser: chrome
  • Version: 67
  • Method of installation: dist
  • Swagger-UI version: 3.17.0
  • Swagger/OpenAPI version: OpenAPI 3.0

    Content & configuration

Swagger/OpenAPI definition:
yaml requestBody: description: user info to be filled content: application/x-www-form-urlencoded: schema: type: object required: - username - name properties: username: type: string description: user identity name: type: string description: user name phone_number: type: string pattern: '/\d{11}/' description: phone number
_20180613215633
Swagger-UI configuration options:
js SwaggerUI({ // your config options here })

?yourQueryStringConfig

Is your feature request related to a problem?

  • property descriptions are not shown
  • required properties are not starred
  • required properties checking, string regex pattern checking is not performed when try swagger client

However, parameters are ideally shown. There should be no much difference between parameters and body form data.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

P1 try-it-out 3.x bug

Most helpful comment

This has been prioritized, and will be fixed shortly 馃槃

All 21 comments

Hello, I was about to open a new issue but I've seen this one which is correlated. I would like to integrate Ispvic report with the object-level "example" (as documented here https://swagger.io/docs/specification/adding-examples/#request-response-bodies) which doesn't seem to be supported:

         application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                userid:
                  type: string
                  description: the id (or email address) inserted by the user in the login form
                password:
                  type: string
                  format: password
              example:
                userid: test
                password: password

Plus, the example is still populated by using the notation inside the properties...

              properties:
                userid:
                  type: string
                  description: the id (or email address) inserted by the user in the login form
                  example: test

...but in the form the example is always rendered between quotation marks:
screenshot-gimme5 acomea prv-2018 06 14-12-25-56

If something is wrong on my YAML code, please let me know, I wasn't able to correct the issue even with different notations.

Thanks,
Fabio

@arlix85 , what is your required configuration for your schema, and which version is your swagger-ui. In my example, the red star and required is not shown.
Thank you.

@lspvic just like "example", "required" is still working if used inside the property, like the old v2 standard:

              properties:
                userid:
                  type: string
                  description: the id (or email address) inserted by the user in the login form
                  example: test
                  required: true

@arlix85 In OpenAPI 3.0, required is not suitable for properties, there's a required array for properties, like

         type: object
              required:
                  - userid
              properties:
                userid:
                  type: string
                  description: the id (or email address) inserted by the user in the login form
                  example: test

Thanks.

@lspvic yes, I know, but since it's still working in SwaggerUI, I'm using this workaround until this issue is fixed.

In case this helps, it's easy to reproduce.

Go to https://petstore.swagger.io/#/pet/updatePetWithForm
Then use this URL: https://gist.githubusercontent.com/danielflower/5c5ae8a46a0a49aee508690c19b33ada/raw/b06ff4d9764b5800424f6a21a40158c35277ee65/petstore.json

You can see endpoints such as POST /pet/{petId} rendering with "string"

These values are also the default in the Try It Out form, and annoyingly even if you clear the value it normally re-appears on blur.

@danielflower the default value issue is fixed since https://github.com/swagger-api/swagger-ui/commit/8f65483510770ef548ea7a79d9e5ba9a3387dcee#diff-47300e7ecd8989b6246221de88fc9a3cR633

The re-appear issue is definitely a bug.

I'm not sure which is the designed behavior:

I prefer not setting the sample value at all if not present, use the description as the input placeholder would be better.

I've also noticed that all the parameter rows are re-render when one of them is changed, which might be a performance issue.

Is this planned to be fixed? I saw this issue a few months ago, thought that I would be addressed by now but after trying 3.0 again it seems to be present to this day (on SwaggerHub).

This has been prioritized, and will be fixed shortly 馃槃

Fixed!

@arlix85, be advised that the forthcoming version of Swagger UI will break the property-level required that you mentioned.

Got the same issue here.

@huihe, this is fixed, are you sure you're on the latest version of Swagger UI? 馃槃

@shockey, not yet. I saw the release notes, and plan to upgrade to the latest. Thank you.

I tried to use Swagger-UI 3.18.2(https://github.com/swagger-api/swagger-ui/releases). The description is still not shown when using urlencoded.

And I notice that the tag(3.18.2) is inconsistent with the last commit(3.18.1). Is it proper tag?
screen shot 2018-08-29 at 2 39 44 pm

I've just upgraded to 3.18.2 and while the issue is slightly different, it is still there. Previously the pre-populated value was "string" and now it's string (so the quotes have gone). But the value still cannot be deleted.

image

Here is the JSON:

json "requestBody": { "content": { "application/x-www-form-urlencoded": { "schema": { "required": [ "gitUrl" ], "type": "object", "properties": { "appName": { "type": "string", "description": "The ID that the app will be referenced which should just be letters, numbers, and hyphens. Leave blank to infer it from the git URL", "nullable": true, "deprecated": false }, "gitUrl": { "type": "string", "description": "An SSH or HTTP git URL that points to an app-runner compatible app", "nullable": false, "deprecated": false } } } } }, "required": false }

@danielflower, are you still seeing this in latest (3.19.0)?

That version doesn't appear to be available in maven central yet. (Using org.webjars:swagger-ui)

Works great now. Thanks a lot!

Great!

I'm going to close out this thread now - if anyone is having issues with this in the future, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sgyang picture sgyang  路  4Comments

insideshell picture insideshell  路  3Comments

fehguy picture fehguy  路  3Comments

easyest picture easyest  路  3Comments

prabhat1790 picture prabhat1790  路  3Comments