Skip to content

fix(go-server): skip readOnly fields in AssertXxxRequired#24257

Merged
wing328 merged 2 commits into
masterfrom
halfcrazy-fix-go-readonly2
Jul 8, 2026
Merged

fix(go-server): skip readOnly fields in AssertXxxRequired#24257
wing328 merged 2 commits into
masterfrom
halfcrazy-fix-go-readonly2

Conversation

@wing328

@wing328 wing328 commented Jul 8, 2026

Copy link
Copy Markdown
Member

based on #24170 with resolved merge conflicts

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

halfcrazy and others added 2 commits July 2, 2026 21:11
AssertXxxRequired is only invoked on decoded request bodies, but it
enforced every entry of a schema's required list, including readOnly
properties. Per OpenAPI 3.x, readOnly properties are produced by the
server and MUST NOT be sent by the client, so a schema legitimately
listing a readOnly property as required (e.g. Redfish/JSON:API identity
fields like id, @odata.type) caused the generated controller to reject
every valid request that omitted the readOnly field.

Skip readOnly entries in the requiredVars loop in model.mustache so
non-readOnly required fields are still validated while readOnly ones are
not enforced on request bodies. Add a regression test using a spec with
a readOnly+required id and a non-readOnly required name.
@wing328 wing328 changed the title Halfcrazy fix go readonly2 fix(go-server): skip readOnly fields in AssertXxxRequired Jul 8, 2026
@wing328 wing328 added this to the 7.24.0 milestone Jul 8, 2026
@wing328 wing328 marked this pull request as ready for review July 8, 2026 08:25

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

@wing328 wing328 merged commit 23296aa into master Jul 8, 2026
335 of 343 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants