Skip to content

builder: correct uniqueItems and array types for non-body parameters - #629

Open
Lfan-ke wants to merge 1 commit into
kubernetes:masterfrom
Lfan-ke:fix/parameter-uniqueitems
Open

builder: correct uniqueItems and array types for non-body parameters#629
Lfan-ke wants to merge 1 commit into
kubernetes:masterfrom
Lfan-ke:fix/parameter-uniqueitems

Conversation

@Lfan-ke

@Lfan-ke Lfan-ke commented Jul 26, 2026

Copy link
Copy Markdown

buildParameter set UniqueItems = !AllowMultiple() on every non-body parameter. But uniqueItems is an array-only validation in JSON Schema / OpenAPI, so:

  • scalar query, path, header and form parameters (the overwhelming majority) were emitted with a spurious uniqueItems: true, and
  • a parameter that does accept multiple values was still typed as a scalar instead of an array.

This corrects both the v2 (pkg/builder) and v3 (pkg/builder3) builders to:

  • emit only {type, format} for scalar parameters (no uniqueItems);
  • emit an array when the parameter allows multiple values - type: array + items (+ collectionFormat: multi in v2).

Unit tests cover both the scalar and the multi-value paths; the existing golden expectations are updated to drop the spurious uniqueItems.

Refs kubernetes/kubernetes#140050

Signed-off-by: 林晨 (Leo Cheng) <leo-cheng@vip.qq.com>
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 26, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Lfan-ke / name: 林晨 (Leo Cheng) (5f770b1)

@kubernetes-prow
kubernetes-prow Bot requested review from Jefftree and sttts July 26, 2026 06:40
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Lfan-ke
Once this PR has been reviewed and has the lgtm label, please assign jpbetz for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @Lfan-ke!

It looks like this is your first PR to kubernetes/kube-openapi 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-openapi has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant