Hi,
I am using the latest version of kin-openapi (v0.106.0).
In this latest version, kin-openapi adds default values to the request body even if they are not present.
For example, if the schema contains :
prop1:
default: false
type: boolean
Then "prop1=false" will be added to the request body if not present.
This is wrong:
According to openapi specification https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schema-object:
default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided.
Meaning that the consumer should make the assumptions, not the producer.
Adding these default values just create network overhead by making the requests larger without any need.
I am getting the following error because of that :
http2: request body larger than specified content length
The code responsible for that is (in ValidateRequestBody function in validate_request.go):
if defaultsSet {
var err error
if data, err = encodeBody(value, mediaType); err != nil {
return &RequestError{
Input: input,
RequestBody: requestBody,
Reason: "rewriting failed",
Err: err,
}
}
// Put the data back into the input
req.Body = ioutil.NopCloser(bytes.NewReader(data))
}
I suggest either to remove this code, or make it optional (and the default behavior should be that no default values are added to the request body).
Thanks,
Oren
Hi,
I am using the latest version of kin-openapi (v0.106.0).
In this latest version, kin-openapi adds default values to the request body even if they are not present.
For example, if the schema contains :
Then "prop1=false" will be added to the request body if not present.
This is wrong:
According to openapi specification https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schema-object:
Meaning that the consumer should make the assumptions, not the producer.
Adding these default values just create network overhead by making the requests larger without any need.
I am getting the following error because of that :
The code responsible for that is (in ValidateRequestBody function in validate_request.go):
I suggest either to remove this code, or make it optional (and the default behavior should be that no default values are added to the request body).
Thanks,
Oren