Created by: aliakseiz
*Affects the Go-server only.
Integer arrays support in a form
Adds a code generation to parse form parameter fields of int32 array
and int64 array
types.
post:
summary: Test operation
operationId: postTest
requestBody:
description: New array
content:
multipart/form-data:
schema:
type: object
properties:
Test:
type: array
items:
type: integer
format: int64
Before:
test, err := parseInt64Parameter( r.FormValue("Test"))
After:
// "," - delimiter to parse an array
// false - state of `required` property
test, err := parseInt64ArrayParameter(r.FormValue("Test"), ",", false)
Required integer fields
Also parameter's required
property is not ignored anymore, meaning that missing optional parameters of int32
, int64
, []int32
and []int64
types are initialized with 0
and empty slice
respectively, instead of failing the whole operation.
Before/after below assume, that mentioned optional and required fields are missing in the payload.
Before:
// Optional field
id, err := parseInt64Parameter(params["id"])
if err != nil { // <-- err is not nil, because empty string cannot be parsed as int64. Operation fails
w.WriteHeader(http.StatusBadRequest)
return
}
After:
// Optional field
id, err := parseInt64Parameter(params["id"], false)
if err != nil { // <-- err is nil, id is 0. Operation continues
w.WriteHeader(http.StatusBadRequest)
return
}
// Required field
idReq, err := parseInt64Parameter(params["idReq"], true)
if err != nil { // <-- err is not nil, contains `errMsgRequiredMissing` message. Operation fails, as expected
w.WriteHeader(http.StatusBadRequest)
return
}
Multipart/form-data parsing
Replaces form parsing with more specific call for multipart/form-data
. ParseForm
itself doesn't initialize the Files
parameters.
FileParam:
type: object
properties:
Files:
description: Some files
type: array
items:
type: string
format: binary
Before:
err := r.ParseForm()
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
After:
if err := r.ParseMultipartForm(32 << 20); err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
Other
Fixes minor typos and FIXMEs, which caught my eye during debugging.
Technical committee
@antihax @grokify @kemokemo @jirikuncar
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: ./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master
,5.1.x
,6.0.x
-
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.