Skip to content

fix(utils): disallow schema type array value string#10691

Merged
lukaszzazulak merged 4 commits intomasterfrom
fix(utils)-disallow-schema-type-array-value-string
Jan 30, 2026
Merged

fix(utils): disallow schema type array value string#10691
lukaszzazulak merged 4 commits intomasterfrom
fix(utils)-disallow-schema-type-array-value-string

Conversation

@lukaszzazulak
Copy link
Contributor

@lukaszzazulak lukaszzazulak commented Jan 28, 2026

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

  • No code changes (changes to documentation, CI, metadata, etc)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@lukaszzazulak lukaszzazulak requested a review from Copilot January 28, 2026 12:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 arrayStringCheck validation 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.

@robert-hebel-sb
Copy link
Contributor

LGTM 💅

but let's add E2E test in test/e2e-cypress/e2e/bugs to ensure the fix works for the following spec

openapi: 3.0.3
info:
    title: test
    version: 1.0.0
paths:
    /test:
        get:
            parameters:
                - in: query
                  name: test
                  required: true
                  schema:
                    type: array
                    example: 'test1'
                    items:
                        type: string
                        enum:
                            - 'test1'
                            - 'test2'
                            - 'test3'
            responses:
                default:
                    description: ok

@lukaszzazulak
Copy link
Contributor Author

@robert-hebel-sb added e2e test

Copy link
Contributor

@glowcloud glowcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
 */

@lukaszzazulak lukaszzazulak merged commit e87ecd7 into master Jan 30, 2026
9 checks passed
@hakornyutt-create
Copy link

fix(utils)-disallow-schema-type-array-value-string

lukaszzazulak added a commit that referenced this pull request Feb 4, 2026
swagger-bot pushed a commit that referenced this pull request Feb 16, 2026
## [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))
@swagger-bot
Copy link
Contributor

🎉 This PR is included in version 5.31.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

delendik-testops pushed a commit to ModiusOpenData/swagger-ui that referenced this pull request Mar 3, 2026
* fix(utils): disallow schema type array value string
delendik-testops pushed a commit to ModiusOpenData/swagger-ui that referenced this pull request Mar 3, 2026
delendik-testops pushed a commit to ModiusOpenData/swagger-ui that referenced this pull request Mar 3, 2026
## [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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants