Documentation
¶
Overview ¶
Command ogen-fixformdata fixes ogen-generated code to skip encoding empty JSON arrays/objects in form-data.
This tool addresses an issue where ogen generates form-data encoders that always call e.EncodeValue(string(enc.Bytes())) even when the JSON encoder produced no output. This results in empty strings being sent for nil slice/map fields, which many APIs reject.
Usage:
ogen-fixformdata <oas_request_encoders_gen.go>
The tool modifies the file in place, adding a length check before encoding JSON content in form-data requests.
This tool is designed to be run as a post-processing step after ogen generation. It can be integrated into a generate.sh script:
ogen --package api --target internal/api --clean openapi.json ogen-fixformdata internal/api/oas_request_encoders_gen.go
Click to show internal directories.
Click to hide internal directories.