Swagger/OpenAPI version: OpenAPI 3.0
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

Swagger-UI configuration options:
js
SwaggerUI({
// your config options here
})
?yourQueryStringConfig
However, parameters are ideally shown. There should be no much difference between parameters and body form data.
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:

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:
string only once when clicked the "Try it out" button. In this case we should use a typeof check or === undefined check here: https://github.com/swagger-api/swagger-ui/blob/v3.17.3/src/core/plugins/oas3/components/request-body.jsx#L98string every time it's cleared. In such case we might use the placeholder property.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?

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.

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)
It's available now: http://central.maven.org/maven2/org/webjars/swagger-ui/3.19.0/
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.
Most helpful comment
This has been prioritized, and will be fixed shortly 馃槃