fix(utils): disallow schema type array value string#10691
fix(utils): disallow schema type array value string#10691lukaszzazulak merged 4 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes support for string values when the schema type is "array", adding validation to reject such cases. Previously, the code allowed array-type parameters to accept string values, which caused issues after PR #3826 was introduced where requests would hang indefinitely.
Changes:
- Removed
arrayStringCheckvalidation that allowed string values for array-type schemas - Updated test expectations to verify that string values for array types now produce validation errors
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/core/utils/index.js | Removed the arrayStringCheck condition that allowed strings as valid values for array-type schemas |
| test/unit/core/utils.js | Updated test assertion to expect a validation error when a string is provided for an array-type parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
LGTM 💅 but let's add E2E test in |
|
@robert-hebel-sb added e2e test |
glowcloud
left a comment
There was a problem hiding this comment.
I wonder if there are any cases where we could input an actual string when the type is array. I think it could be possible with request body but we might not be using the same validation there. But I'm fine with this solution for now, we'll see if there are any issues with it.
Perhaps in the future we could change the mechanism for generating examples, so that it does not use examples/default values that are not of the provided type.
| @@ -0,0 +1,12 @@ | |||
| describe.only("Try it out with schema type array but example type string", () => { | |||
There was a problem hiding this comment.
| describe.only("Try it out with schema type array but example type string", () => { | |
| describe("Try it out with schema type array but example type string", () => { |
Also we can add this at the top of the file to enable linting for it - we need to do this manually in Swagger UI for new/refactored files, as we do not have it enabled for the entire repo.
/**
* @prettier
*/|
fix(utils)-disallow-schema-type-array-value-string |
This reverts commit e87ecd7.
## [5.31.1](v5.31.0...v5.31.1) (2026-02-16) ### Bug Fixes * **deps:** align the tree-sitter version ([#10694](#10694)) ([6453290](6453290)) * **deps:** update vulnerable dependencies ([#10725](#10725)) ([23d6c26](23d6c26)) * **utils:** disallow schema type array value string ([#10691](#10691)) ([e87ecd7](e87ecd7)) * validated support for OpenAPI 3.1.2 and updated docs ([8bf8ed9](8bf8ed9)) ### Reverts * Revert "fix(utils): disallow schema type array value string ([#10691](#10691))" ([#10710](#10710)) ([0a7ff5b](0a7ff5b))
|
🎉 This PR is included in version 5.31.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* fix(utils): disallow schema type array value string
…api#10691)" (swagger-api#10710) This reverts commit e87ecd7.
## [5.31.1](swagger-api/swagger-ui@v5.31.0...v5.31.1) (2026-02-16) ### Bug Fixes * **deps:** align the tree-sitter version ([swagger-api#10694](swagger-api#10694)) ([6453290](swagger-api@6453290)) * **deps:** update vulnerable dependencies ([swagger-api#10725](swagger-api#10725)) ([23d6c26](swagger-api@23d6c26)) * **utils:** disallow schema type array value string ([swagger-api#10691](swagger-api#10691)) ([e87ecd7](swagger-api@e87ecd7)) * validated support for OpenAPI 3.1.2 and updated docs ([8bf8ed9](swagger-api@8bf8ed9)) ### Reverts * Revert "fix(utils): disallow schema type array value string ([swagger-api#10691](swagger-api#10691))" ([swagger-api#10710](swagger-api#10710)) ([0a7ff5b](swagger-api@0a7ff5b))
Add validation and show error if the schema type is an array and value provided is string
Description
Before swagger-api/swagger-js#3826, it was possible to send request without any issues. Now validation and error has been added
Motivation and Context
After swagger-api/swagger-js#3826 has been introduced, when user tries to Execute a request, the loader appears and stays
How Has This Been Tested?
Manually and unit test
Types of changes
package.json)Checklist: