ogen-fixformdata

command
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 4 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL