Skip to content

Use net/http constants in boilerplate#2398

Open
mromaszewicz wants to merge 1 commit into
oapi-codegen:mainfrom
mromaszewicz:fix/issue-2397
Open

Use net/http constants in boilerplate#2398
mromaszewicz wants to merge 1 commit into
oapi-codegen:mainfrom
mromaszewicz:fix/issue-2397

Conversation

@mromaszewicz

Copy link
Copy Markdown
Member

Closes: #2397

Replace raw integer literals in generated strict server code with named net/http constants (e.g. http.StatusOK instead of 200). Covers WriteHeader/Status/StatusCode calls in all strict server templates and status code comparisons in generated client switch statements.

@mromaszewicz mromaszewicz requested a review from a team as a code owner June 5, 2026 22:27
@greptile-apps

greptile-apps Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces generated raw HTTP status numbers with net/http constants. It changes:

  • Strict server response boilerplate for standard, Fiber, and Iris outputs.
  • Client response parsing comparisons in generated code.
  • Shared codegen helpers for mapping fixed status codes to http.Status* names.
  • Regenerated examples and internal fixtures to match the template output.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
pkg/codegen/operations.go Adds the fixed status-code to net/http constant mapping used by generated output.
pkg/codegen/template_helpers.go Updates generated client response conditions to compare against HTTP status constants.
pkg/codegen/templates/strict/strict-interface.tmpl Emits HTTP status constants for fixed strict-server response codes.
pkg/codegen/templates/strict/strict-fiber-interface.tmpl Emits HTTP status constants for fixed Fiber strict-server responses.
pkg/codegen/templates/strict/strict-iris-interface.tmpl Emits HTTP status constants for fixed Iris strict-server responses.

Reviews (2): Last reviewed commit: "Use net/http constants in boilerplate" | Re-trigger Greptile

Comment thread internal/test/issues/issue-1087/api.gen.go Outdated
Closes: oapi-codegen#2397

Replace raw integer literals in generated strict server code with named
net/http constants (e.g. http.StatusOK instead of 200). Covers
WriteHeader/Status/StatusCode calls in all strict server templates and
status code comparisons in generated client switch statements.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@mromaszewicz

Copy link
Copy Markdown
Member Author

@greptileai, please look again, comments addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use constants from net/http for the status codes

1 participant