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

Requestbody x-www-form-urlencoded is not properly rendered #4643

Closed
lspvic opened this issue Jun 13, 2018 · 21 comments · Fixed by #4823
Closed

Requestbody x-www-form-urlencoded is not properly rendered #4643

lspvic opened this issue Jun 13, 2018 · 21 comments · Fixed by #4823

Comments

@lspvic
Copy link

lspvic commented Jun 13, 2018

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:

     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:

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

@arlix85
Copy link

arlix85 commented Jun 14, 2018

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

@lspvic
Copy link
Author

lspvic commented Jun 15, 2018

@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.

@arlix85
Copy link

arlix85 commented Jun 15, 2018

@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

@lspvic
Copy link
Author

lspvic commented Jun 15, 2018

@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.

@arlix85
Copy link

arlix85 commented Jun 15, 2018

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

@danielflower
Copy link

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.

@bestmike007
Copy link
Contributor

@danielflower the default value issue is fixed since 8f65483#diff-47300e7ecd8989b6246221de88fc9a3cR633

The re-appear issue is definitely a bug.

@bestmike007
Copy link
Contributor

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.

@sryze
Copy link

sryze commented Aug 10, 2018

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).

@shockey
Copy link
Contributor

shockey commented Aug 16, 2018

This has been prioritized, and will be fixed shortly 😄

@shockey
Copy link
Contributor

shockey commented Aug 18, 2018

Fixed!

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

@huihe
Copy link

huihe commented Aug 27, 2018

Got the same issue here.

@shockey
Copy link
Contributor

shockey commented Aug 27, 2018

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

@huihe
Copy link

huihe commented Aug 27, 2018

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

@yottachen
Copy link

yottachen commented Aug 29, 2018

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

@danielflower
Copy link

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:

"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
        }

@shockey
Copy link
Contributor

shockey commented Sep 21, 2018

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

@danielflower
Copy link

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

@deki
Copy link

deki commented Sep 27, 2018

@danielflower
Copy link

Works great now. Thanks a lot!

@shockey
Copy link
Contributor

shockey commented Sep 27, 2018

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.

@swagger-api swagger-api locked as resolved and limited conversation to collaborators Sep 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants