swagger-api / swagger-api/swagger-ui
Extra special characters getting added due to pattern.
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: macOS
- Browser: chrome
- Version: [e.g. 22]
- Method of installation: npm
- Swagger-UI version: 4.18.1 [(swagger-ui-react)]
- Swagger/OpenAPI version: Swagger 2.0
Content & configuration
Example Swagger/OpenAPI definition:
{
"swagger": "2.0",
"info":
{ "version": "v1", "title": "Test API" },
"host": "test.com",
"schemes": ["https"],
"paths":
{
"/{customer}/singleUse/$launchIcaFile":
{
"post":
{
"tags": ["SingleUseLaunch"],
"summary": "Create ICA File",
"description": "test description",
"operationId": "SingleUseLaunch_IcaFile",
"consumes": ["application/json"],
"produces": ["application/json; charset=utf-8"],
"parameters":
[
{
"name": "customer",
"in": "path",
"description": " Cloud customer id",
"required": true,
"type": "string",
},
{
"name": "request",
"in": "body",
"description": "Request that describes the hosted environment for the end user's browser",
"required": true,
"schema":
{ "$ref": "#/definitions/SingleUseLaunchRequestModel" },
},
{
"name": "Authorization",
"in": "header",
"description": " Cloud authorization bearer token",
"required": true,
"type": "string",
},
{
"name": "TransactionId",
"in": "header",
"required": false,
"type": "string",
"format": "uuid",
},
{
"name": "Accept",
"in": "header",
"required": true,
"type": "string",
},
],
"responses":
{
"200":
{
"description": "Success",
"schema":
{ "$ref": "#/definitions/SingleUseIcaFileResponse" },
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
"Content-Type": { "type": "string" },
"X-Content-Type-Options": { "type": "string" },
},
},
"400":
{
"description": "Body could not be parsed or requested an incompatible combination of options",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"402":
{
"description": "Customer account not entitled to use Remote Browser Isolation",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"404":
{
"description": "Customer account not recognized",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"401":
{
"description": "Authorization header is missing or invalid",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"415":
{
"description": "Must use application/json;charset=utf-8 media type",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"406":
{
"description": "Must accept application/json media type",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
},
},
},
"/{customer}/singleUse/$launchUrl":
{
"post":
{
"tags": ["SingleUseLaunch"],
"summary": "Create Single-Use Launch URL",
"description": "An API for launching arbitrary addresses within the hosted environment, without permanently\r\npublishing the URL. The returned value is a launch URL which may only be used once and\r\nwill time out if not used within ten minutes.",
"operationId": "SingleUseLaunch_LaunchUrl",
"consumes": ["application/json"],
"produces": ["application/json; charset=utf-8"],
"parameters":
[
{
"name": "customer",
"in": "path",
"description": " Cloud customer id",
"required": true,
"type": "string",
},
{
"name": "request",
"in": "body",
"description": "Request that describes the hosted environment for the end user's browser",
"required": true,
"schema":
{ "$ref": "#/definitions/SingleUseLaunchRequestModel" },
},
{
"name": "Authorization",
"in": "header",
"description": " Cloud authorization bearer token",
"required": true,
"type": "string",
},
{
"name": "TransactionId",
"in": "header",
"required": false,
"type": "string",
"format": "uuid",
},
{
"name": "Accept",
"in": "header",
"required": true,
"type": "string",
},
],
"responses":
{
"200":
{
"description": "Success",
"schema":
{ "$ref": "#/definitions/SingleUseLaunchUrlResponse" },
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
"Content-Type": { "type": "string" },
"X-Content-Type-Options": { "type": "string" },
},
},
"400":
{
"description": "Body could not be parsed or requested an incompatible combination of options",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"402":
{
"description": "Customer account not entitled to use Remote Browser Isolation",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"404":
{
"description": "Customer account not recognized",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"401":
{
"description": "Authorization header is missing or invalid",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"415":
{
"description": "Must use application/json;charset=utf-8 media type",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
"406":
{
"description": "Must accept application/json media type",
"headers":
{
"TransactionId":
{ "type": "string", "format": "uuid" },
},
},
},
},
},
},
"definitions":
{
"SingleUseLaunchRequestModel":
{
"required": ["address"],
"type": "object",
"properties":
{
"name":
{
"description": "Title of the page in the client browser",
"pattern": "^[^=+\\-@\\\\\\/][^\\/\\\\]*",
"type": "string",
},
"address":
{
"description": "Fully-qualified URL to launch within the session",
"type": "string",
},
"geo":
{
"description": "Geographical region to host the remote session. Acceptable values are \"Auto\", \"WUS\", \"WEurope\",\r\n\"SEAsia\", \"APS\". Default value is \"WUS.\"",
"type": "string",
},
"whitelist":
{
"description": "List of sites that the hosted browser is allowed to contact. Entries are in the\r\nformat \"hostname:port number\", separated by newlines, with asterisks as wild cards.\r\nDefault value is \"*:*\", which allows all traffic.",
"type": "string",
},
"filterProfile":
{
"description": "Profile for URL filtering. Acceptable values are \"None\", \"Lenient\", \"Moderate\", and \"Strict\". Default\r\nvalue is \"None\".",
"type": "string",
},
"userIdentity": { "$ref": "#/definitions/SingleUseUserIdentity" },
"policies": { "$ref": "#/definitions/SingleUsePolicyModel" },
},
},
"SingleUseUserIdentity":
{
"type": "object",
"properties":
{
"username":
{
"description": "Name of the user. This is used for reporting purposes.",
"type": "string",
},
"clientIP":
{
"description": 'IP address of the user. This is used for reporting, and for choosing a geographical region when "Auto" is requested.',
"type": "string",
},
},
},
"SingleUsePolicyModel":
{
"type": "object",
"properties":
{
"copyPaste":
{
"description": "Enable clipboard operations between client and session. Disabled by default.",
"type": "boolean",
},
"printing":
{
"description": "Enable printing of remote pages. Disabled by default.",
"type": "boolean",
},
"nonKiosk":
{
"description": "Do not run the hosted browser in kiosk mode. Disabled by default.",
"type": "boolean",
},
"disableRegionFailover":
{
"description": "By default if the geographical region requested is reporting an issue, the session will be automatically\r\ntransferred to another. If disabled, the session may fail instead of connecting to an unexpected region.",
"type": "boolean",
},
"sessionIdleTimeout":
{
"format": "int32",
"description": "Number of minutes to allow the session to remain idle before closing automatically. Default ten minutes.",
"type": "integer",
},
"sessionIdleTimeoutWarning":
{
"format": "int32",
"description": "Number of minutes before an automatic log off to display a warning dialog to the user. Default two minutes.",
"type": "integer",
},
},
},
"SingleUseIcaFileResponse":
{
"required": ["icaFile"],
"type": "object",
"properties":
{
"icaFile":
{
"description": "An ICA file that connects to the environment described in the request",
"type": "string",
},
},
},
"SingleUseLaunchUrlResponse":
{
"required": ["launchUrl"],
"type": "object",
"properties":
{
"launchUrl":
{
"description": "A launch URL that connects to the environment described in the request",
"type": "string",
},
},
},
},
}
Swagger-UI configuration options:
SwaggerUI({
// your config options here
})
?yourQueryStringConfig
Describe the bug you're encountering
The body params showing extra special characters when using pattern in the properties object.
To reproduce...
Steps to reproduce the behavior:
- Go to 'https://editor.swagger.io/'
- Click on 'paste the below json'
- Scroll down to 'SingleUseLaunch' (post)
- See error ( "name": "r4lApofxvGI4|(qRcgW<" )
Expected behavior
The params should show the datatype Expected example: ("name": "string")
Screenshots
Additional context or thoughts
Removing the pattern fixes this issue, so the problem i guess is around the pattern parsing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named in the report. Reproduce the Swagger 2.0 example in Swagger UI 4.18.1 using the npm installation and Chrome, then trace how the name property's pattern is processed; done means the extra special characters no longer appear while the intended pattern behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100