Flagify enum validator generation#2334
Conversation
Add an `output-options.skip-enum-validate` flag that suppresses the `Valid()` method generated on enum types. The method is still emitted by default; users whose code defines its own `Valid()` on the same type can now opt out instead of seeing a compile-time conflict. Relates to PR oapi-codegen#2227, which introduced the `Valid()` method. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Greptile SummaryAdds a new Confidence Score: 5/5Safe to merge; all remaining feedback is P2 style/test suggestions with no correctness concerns. The change is additive, opt-in (defaults to false, preserving existing behaviour), and touches only the enum-generation path. The only gap is the absence of a regression test for the new flag, which is a P2 concern and does not block merge. No files require special attention.
|
| Filename | Overview |
|---|---|
| pkg/codegen/templates/constants.tmpl | Wraps the Valid() method generation in {{if not $.SkipEnumValidate}} guard inside the existing enum range loop; logic is correct. |
| pkg/codegen/configuration.go | Adds SkipEnumValidate bool field to OutputOptions with proper yaml tag and doc comment; consistent with existing skip-* fields. |
| pkg/codegen/schema.go | Adds SkipEnumValidate bool to Constants struct for passing the flag to the template. |
| pkg/codegen/codegen.go | Populates Constants.SkipEnumValidate from globalState.options.OutputOptions in GenerateEnums; consistent with how the codebase reads global config. |
| configuration-schema.json | Adds skip-enum-validate boolean field to JSON schema, keeping it in sync with the Go struct. |
Reviews (1): Last reviewed commit: "Flagify enum validator generation" | Re-trigger Greptile
Add an
output-options.skip-enum-validateflag that suppresses theValid()method generated on enum types. The method is still emitted by default; users whose code defines its ownValid()on the same type can now opt out instead of seeing a compile-time conflict.Relates to PR #2227, which introduced the
Valid()method.