Skip to content

openapi: fix v2 parameter and header type mapping#3919

Merged
raphael merged 1 commit intov3from
fix-openapi-param-header-types
Apr 22, 2026
Merged

openapi: fix v2 parameter and header type mapping#3919
raphael merged 1 commit intov3from
fix-openapi-param-header-types

Conversation

@raphael
Copy link
Copy Markdown
Member

@raphael raphael commented Apr 22, 2026

Summary

This fixes a bug in Goa's OpenAPI v2 generator for parameter and header schemas.

Today, body and component schemas already translate Goa types into valid OpenAPI base types and formats, but parameter/header generation was using a different code path. That mismatch meant the same logical type could be rendered correctly in one part of the spec and incorrectly in another.

In practice, the broken path could emit invalid schema types such as:

  • type: UUID
  • type: Time
  • type: int64

Those are Goa type names, not valid OpenAPI type values, so downstream OpenAPI tooling can reject the generated document.

This change makes OpenAPI v2 parameters, headers, and array items use the same primitive mapping rules as body schemas. After the fix, those cases are emitted as valid OpenAPI shapes such as:

  • type: string with format: uuid
  • type: string with format: date-time
  • type: integer with format: int64

The change also preserves validations coming from both the alias definition and the use site, so named aliases keep their expected formats when they are used in query params or headers.

What changed

  • route OpenAPI v2 parameter, header, and array-item generation through one shared primitive-to-OpenAPI mapping path
  • keep alias-level and field-level validations together when building those schemas
  • add a focused regression test that reproduces the failure with an alias-backed query param and typed response headers
  • update the affected OpenAPI v2 golden files for wildcard path params and integer headers that were already exercising the same bug

Test plan

  • go test ./http/codegen/openapi/v2
  • make

Use the same primitive mapping for v2 parameters, headers, and array items that body schemas already use so generated specs stay valid for named aliases and int64/date-time formats.

Made-with: Cursor
@raphael raphael enabled auto-merge (squash) April 22, 2026 15:16
@raphael raphael merged commit 69d2ca5 into v3 Apr 22, 2026
7 checks passed
@raphael raphael deleted the fix-openapi-param-header-types branch April 22, 2026 15:16
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.

1 participant