fix(parameters): render items format for array-type parameters (#4516)#10886
Open
yogeshwaran-c wants to merge 1 commit into
Open
fix(parameters): render items format for array-type parameters (#4516)#10886yogeshwaran-c wants to merge 1 commit into
yogeshwaran-c wants to merge 1 commit into
Conversation
When a query parameter is `type: array` with `items.format`, the format
on the items was dropped from the rendered type column, so e.g.
`items: { type: string, format: uuid }` showed as `array<string>` instead
of `array<string($uuid)>`. Non-array parameters already render their
format via `parameter-row.jsx`, but the JSON Schema Draft 5 `getType`
helper used by Swagger 2.0 and OpenAPI 3.0 never consulted the items
format when building the `array<...>` label.
`getType` now accepts an internal `withFormat` flag that the array
recursion turns on, so item types are emitted as `<type>($<format>)`
inline within the `array<...>` label. The top-level call path is
unchanged, so primitive parameter rendering still produces a separate
`(format)` span and the existing test expectations hold.
Fixes swagger-api#4516
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For an array-type parameter whose items declare a
format, Swagger UI dropped that format from the rendered type column. For example a Swagger 2.0 query parameter:rendered as
array<string>instead of something carrying theuuidformat. Non-array parameters already render their format (see #4231 / #4245), so the gap was specific to arrays.Root cause
getTypeinsrc/core/plugins/json-schema-5/fn.jsbuilds thearray<...>label by recursing intoitems, but the recursive call only returned the items'typeand ignored theirformat. The calling componentsrc/core/components/parameter-row.jsxthen renders the resulting label as-is and appends a separate(format)span derived from the top-level schema'sformat, which is undefined for array parameters. Net result: array items'formathad no rendering path.This affects Swagger 2.0 and OpenAPI 3.0, which share
json-schema-5. OpenAPI 3.1+ usesjson-schema-2020-12and is intentionally out of scope here.Fix
getTypeaccepts an internalwithFormatflag that the array recursion turns on, so item types are emitted inline as<type>($<format>)within thearray<...>label, e.g.array<string($uuid)>. The top-level call path is unchanged, so primitive parameter rendering still produces a separate(format)span and existing test expectations hold.Motivation and Context
Closes #4516.
How Has This Been Tested?
getSchemaObjectTypeLabelintest/unit/core/plugins/json-schema-5/fn.jscovering: plain primitive, primitive with format (no inline format at top level),array<string>,array<string($uuid)>,array<integer($int64)>, nestedarray<array<string($uuid)>>, and the exact spec excerpt from the issue.<ParameterRow/>unit tests intest/unit/components/parameter-row.jsxfor both Swagger 2.0 and OpenAPI 3.0 array parameters with and without items format.test/e2e-cypress/e2e/bugs/4516.cy.jsdriven by a small Swagger 2.0 fixturetest/e2e-cypress/static/documents/bugs/4516.yaml. Verified locally: 3/3 passing.<ParameterRow/>unit tests still pass (10/10) — the non-array path is unchanged.Checklist