Skip to content

fix: include additional types for array response type#1930

Merged
mromaszewicz merged 5 commits into
oapi-codegen:mainfrom
viktorasm:fix/1277-array-response-type
Apr 22, 2026
Merged

fix: include additional types for array response type#1930
mromaszewicz merged 5 commits into
oapi-codegen:mainfrom
viktorasm:fix/1277-array-response-type

Conversation

@viktorasm

Copy link
Copy Markdown
Contributor

fixes #1277

@viktorasm viktorasm requested a review from a team as a code owner March 15, 2025 17:07
@viktorasm viktorasm changed the title include additional types for array response type fix: include additional types for array response type Mar 15, 2025
Jamie Tanna and others added 3 commits April 21, 2026 17:35
Although this now appears to be fixed, we should add a test case for it.
The PR added a test under issues/issue1277 (no hyphen) and the
upstream defect/1277 branch added one under issues/issue-1277 (with
hyphen, matching the convention used by every other issue test).
Drop the non-hyphenated copy and fold the only meaningful additions
from it (info block and response description) into the hyphenated
version, which is also broader (generates client + chi-server +
strict-server, vs chi-server + strict-server only).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mromaszewicz

Copy link
Copy Markdown
Member

I merged @jamietanna 's test case, and merged it with yours and merged main into your branch.

I tested this, and it looks like it works, and is minimal.

@mromaszewicz

Copy link
Copy Markdown
Member

@greptileai

@mromaszewicz mromaszewicz added this to the v2.7.0 milestone Apr 22, 2026
@mromaszewicz mromaszewicz added the bug Something isn't working label Apr 22, 2026
@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes #1277 by adding a {{range .Schema.AdditionalTypes}} loop (lines 73–75) in strict-interface.tmpl, so that inline types nested inside an array response schema (e.g. the item struct generated for an array with additionalProperties) are emitted in the strict server output. Without the fix, the array alias referenced an undeclared type, causing a compile error. A new regression test case in internal/test/issues/issue-1277/ validates the fix.

Confidence Score: 5/5

Safe to merge — the template change is minimal, targeted, and validated by a new generated test fixture.

The fix is a single-line addition of an existing pattern (AdditionalTypes loop) already used elsewhere in the codebase. All findings are P2 or lower, and the generated output in the test fixture confirms the correct types are now emitted.

No files require special attention.

Important Files Changed

Filename Overview
pkg/codegen/templates/strict/strict-interface.tmpl Adds AdditionalTypes loop after each content response definition so inline item types (e.g. array element structs) are emitted in the strict server output — the core fix for #1277.
internal/test/issues/issue-1277/spec.yaml New test spec defining a GET /test endpoint that returns an array of inline objects with additionalProperties — exactly the pattern that triggered #1277.
internal/test/issues/issue-1277/config.yaml Codegen config for issue-1277 test; enables models, client, chi-server, and strict-server generation to exercise the full output surface.
internal/test/issues/issue-1277/generate.go Standard go:generate directive for regenerating the issue-1277 test fixture.

Reviews (1): Last reviewed commit: "test(issue-1277): consolidate duplicate ..." | Re-trigger Greptile

@mromaszewicz mromaszewicz merged commit 6a41349 into oapi-codegen:main Apr 22, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array in content issue

2 participants