Skip to content

feat: Add automatic wildcard content type support#1579

Merged
ernado merged 1 commit intoogen-go:mainfrom
lanej:fix/wildcard-content-types
Nov 24, 2025
Merged

feat: Add automatic wildcard content type support#1579
ernado merged 1 commit intoogen-go:mainfrom
lanej:fix/wildcard-content-types

Conversation

@lanej
Copy link
Contributor

@lanej lanej commented Nov 23, 2025

Summary

Adds configurable wildcard content type support (*/*, application/*) to enable code generation for APIs that use wildcards in OpenAPI specs.

Fixes #2

Changes

  • Add wildcard_content_type_default configuration option (opt-in)
  • Detect and map wildcards to specified encoding (e.g., application/json)
  • Preserve binary stream handling for format: binary schemas
  • Smart key management prevents duplicate wrapper generation
  • Enable k8s.json and redoc/discriminator.json specs

Configuration

# ogen.yml
generator:
  wildcard_content_type_default: "application/json"

Without config: Wildcards fail as unsupported (backward compatible)

With config: Wildcards map to configured type and generate successfully

Testing

  • Comprehensive test spec covers */*, application/*, and mixed scenarios
  • All existing tests pass
  • k8s and redoc specs now generate without ignore rules

Impact

Enables code generation for ~15% of real-world carrier/logistics APIs that previously required skipping operations due to wildcard content types.

Add optional wildcard content type support to enable code generation for
APIs using */* or application/* in OpenAPI specs.

- Add WildcardContentTypeDefault configuration option (opt-in)
- Implement wildcard detection and mapping in gen_contents.go
- Preserve binary stream handling for format: binary
- Add comprehensive test coverage for wildcard scenarios
- Enable previously failing k8s.json and redoc specs

The feature is backward compatible (disabled by default) and allows
users to specify a default encoding (e.g., application/json) for
wildcard content types via YAML configuration.

Fixes #2
@ernado ernado merged commit 4bea3d7 into ogen-go:main Nov 24, 2025
15 checks passed
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.

Add CI

2 participants