fix(go-server): allow zero values for required request body fields#24262
Draft
halfcrazy wants to merge 1 commit into
Draft
fix(go-server): allow zero values for required request body fields#24262halfcrazy wants to merge 1 commit into
halfcrazy wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/server/petstore/go-chi-server/go/model_order.go">
<violation number="1" location="samples/server/petstore/go-chi-server/go/model_order.go:16">
P3: This generated Go sample is not `gofmt`-formatted after adding the imports; Go tooling will reorder the stdlib import block. Suggest running `gofmt` so regenerated samples match normal Go formatting.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| import ( | ||
| "time" | ||
| "bytes" |
Contributor
There was a problem hiding this comment.
P3: This generated Go sample is not gofmt-formatted after adding the imports; Go tooling will reorder the stdlib import block. Suggest running gofmt so regenerated samples match normal Go formatting.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/server/petstore/go-chi-server/go/model_order.go, line 16:
<comment>This generated Go sample is not `gofmt`-formatted after adding the imports; Go tooling will reorder the stdlib import block. Suggest running `gofmt` so regenerated samples match normal Go formatting.</comment>
<file context>
@@ -13,6 +13,8 @@ package petstoreserver
import (
"time"
+ "bytes"
+ "encoding/json"
)
</file context>
…penAPITools#20496) Validate required properties by JSON key presence in UnmarshalJSON instead of rejecting primitive zero values via IsZeroValue, aligning with go-client.
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.
fix #20496
Validate required properties by JSON key presence in UnmarshalJSON instead of rejecting primitive zero values via IsZeroValue, aligning with go-client.
PR checklist
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.
cc @antihax (2017/11) @grokify (2018/07) @kemokemo (2018/09) @jirikuncar (2021/01) @ph4r5h4d (2021/04) @lwj5 (2023/04)
Summary by cubic
Allow zero values for required fields in
go-serverJSON request bodies by validating required keys during unmarshalling. Aligns server behavior with thego-clientand avoids rejecting valid zero values.allOf), handle nullable required fields, and strictly disallow unknown fields.RequiredErrorseparately from parsing errors during body decode.RequiredErrormessage to “missing”.samples/server/others/go-server/required-zero-valuesample; updated CI to include it.Written for commit 55e3079. Summary will update on new commits.