Skip to content

Add functions to response models for schema-extraction #2379

Merged
mromaszewicz merged 4 commits into
oapi-codegen:mainfrom
rd-andreas-tollkoetter:issue-2191
May 19, 2026
Merged

Add functions to response models for schema-extraction #2379
mromaszewicz merged 4 commits into
oapi-codegen:mainfrom
rd-andreas-tollkoetter:issue-2191

Conversation

@rd-andreas-tollkoetter

Copy link
Copy Markdown
Contributor

closes #2191

@rd-andreas-tollkoetter
rd-andreas-tollkoetter requested a review from a team as a code owner May 19, 2026 07:43
@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds generated response-body getter methods for client response models. It changes:

  • Adds GetBody() to ClientWithResponses response structs by default.
  • Adds typed getters such as GetJSON200() for decoded response fields.
  • Adds output-options.skip-response-body-getters to disable the new methods.
  • Updates the configuration schema and generated fixtures.
  • Adds focused tests for enabled and skipped getter generation.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
pkg/codegen/templates/client-with-responses.tmpl Adds default response getter generation behind the new output option.
configuration-schema.json Documents the new skip-response-body-getters output option for schema validation.
internal/test/outputoptions/response-body-getters/enabled/response_body_getters_test.go Verifies the default generated response type exposes GetBody() and typed getters.
internal/test/outputoptions/response-body-getters/skipped/response_body_getters_test.go Verifies the opt-out config suppresses generated response-body getter methods.

Reviews (2): Last reviewed commit: "Update config schema, regenerate everyth..." | Re-trigger Greptile

Comment thread pkg/codegen/configuration.go
Comment thread pkg/codegen/templates/client-with-responses.tmpl
@mromaszewicz mromaszewicz added the enhancement New feature or request label May 19, 2026
@mromaszewicz

Copy link
Copy Markdown
Member

I'm addressing Greptile's findings and pushing an update to your fork.

- Add `skip-response-body-getters` to `configuration-schema.json` under
  `output-options` so schema-based config validation accepts the new flag
  (Greptile P1 on `configuration.go`).
- Regenerate every committed `*.gen.go` fixture so the new default
  `GetBody()` and `Get<TypeName>()` response getters are reflected in the
  committed output (Greptile P1 on `client-with-responses.tmpl`).
- Add `internal/test/outputoptions/response-body-getters/` covering both
  the default (`enabled/`) and opt-out (`skipped/`) code paths. The tests
  instantiate the generated response type and use reflection to assert
  the getters are present or absent as configured.
@mromaszewicz

Copy link
Copy Markdown
Member

@greptileai, review latest patch

@mromaszewicz mromaszewicz added the notable changes Used for release notes to highlight these more highly label May 19, 2026
@mromaszewicz
mromaszewicz merged commit c5641fd into oapi-codegen:main May 19, 2026
15 checks passed
lwc pushed a commit to lwc/oapi-codegen that referenced this pull request Jun 23, 2026
…2379)

* added Getter functions for response bodies

* add configuration option to skip response body getter generation

* Update config schema, regenerate everything

- Add `skip-response-body-getters` to `configuration-schema.json` under
  `output-options` so schema-based config validation accepts the new flag
  (Greptile P1 on `configuration.go`).
- Regenerate every committed `*.gen.go` fixture so the new default
  `GetBody()` and `Get<TypeName>()` response getters are reflected in the
  committed output (Greptile P1 on `client-with-responses.tmpl`).
- Add `internal/test/outputoptions/response-body-getters/` covering both
  the default (`enabled/`) and opt-out (`skipped/`) code paths. The tests
  instantiate the generated response type and use reflection to assert
  the getters are present or absent as configured.

---------

Co-authored-by: Marcin Romaszewicz <marcinr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request notable changes Used for release notes to highlight these more highly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add functions to response models for schema-extraction

2 participants