Skip to content

feat(embedding): allof embedding structs impl#6

Merged
zdunecki merged 45 commits intolivesessionfrom
feat/embedding
Mar 2, 2026
Merged

feat(embedding): allof embedding structs impl#6
zdunecki merged 45 commits intolivesessionfrom
feat/embedding

Conversation

@zdunecki
Copy link
Member

No description provided.

mromaszewicz and others added 30 commits February 6, 2026 17:04
…oapi-codegen#2197)

This is a prototype implementation of a future versions of oapi-codegen. It's almost a full rewrite, heavily
inspired by previous code, and lessons learned.

- much more flexibility in configuring generated code
- move from kin-openapi to libopenapi to support 3.1 and 3.2 specs
- webhook support
- callback support
- incompatible codegen changes to aggregate types (allOf, anyOf, oneOf)
- many existing codegen bugs around schemas fixed
oapi-codegen#2198)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Add output filtering

Fixes oapi-codegen#2200

Add output filtering like in V2, and support fetching specs via HTTP.

* Fix lint issue

---------

Co-authored-by: Marcin Romaszewicz <mromaszewicz@nvidia.com>
Co-authored-by: Marcin Romaszewicz <mromaszewicz@nvidia.com>
Thanks to Speakeasy and LivePeer for their support over the years!
As a way to keep updates to the CI pipelines more straightforward, we
can extract this out to a shared, versioned (and updated by Renovate)
Action.

We can make sure to keep our binary builds going, but only for the
current versions of Go - other build failures will be caught by our
shared Action.
…urity] (oapi-codegen#2207)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Yuichiro Tsuji <yui.tsuji@mbk-wellness.co.jp>
Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
Co-authored-by: Marcin Romaszewicz <mromaszewicz@users.noreply.github.com>
…api-codegen#1438)

Co-authored-by: Ula <ulad@users.noreply.github.com>
Co-authored-by: Marcin Romaszewicz <mromaszewicz@users.noreply.github.com>
…ers are exist in Iris strict server. (oapi-codegen#1411)

Co-authored-by: Marcin Romaszewicz <mromaszewicz@users.noreply.github.com>
…gnature (oapi-codegen#1419)

* hotfix:
- Bump fiber version to 2.52.0
- Adopted middleware template for fiber to handle new GetReqHeader() method, that has changed signature in fiber 2.50.0 (https://github.com/gofiber/fiber/releases/tag/v2.50.0)

* Use latest fiber, and fix go deps

The latest Fiber requires Go 1.24, therefore, we have to increase
the version in the modules which use it. This is constrained to
tests and examples, so it doesn't affect the main repo.

Go 1.24 can't compile the version of golang.org/x/tools which we
were using, so update that as well.

* fix: use valueList[0] for fiber header IsPassThrough case

The merge with upstream/main resolved a conflict in the fiber
middleware template's header IsPassThrough handler by taking
upstream's version, which still used the old single-string `value`
variable. This is incorrect because fiber 2.50.0+ changed
GetReqHeaders() to return map[string][]string. Fix by using
valueList[0] to match the rest of the header handling block.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Tidy up modules

This seems to be about the minimal set of changes to have
everything build and test cleanly.

* fix: add Go 1.24 version guards to Makefiles

The internal/test and examples modules now require Go 1.24+ in their
go.mod files, but their Makefiles lacked version guards, causing CI
failures on Go 1.22 and 1.23. Add execute-if-go-124 guards matching
the pattern used by other Go 1.24+ modules. Also bump the
strict-server/stdhttp Makefile guard from 1.22 to 1.24.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Alexey Boltunov <apboltunov@mts.ru>
Co-authored-by: Marcin Romaszewicz <marcinr@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* fixed duplicate type names

* add typename dedup functions

* Fixup: use full-word suffixes and add regression test for issue oapi-codegen#200

- Rename auto-dedup suffixes to use full words: Parameter, Response,
  RequestBody (instead of Param, Resp, ReqBody)
- Add internal/test/issues/issue-200/ with spec, config, generated code,
  and a compile-time regression test that instantiates every expected type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Gate duplicate type name resolution behind output-options config flag

Add ResolveTypeNameCollisions bool to OutputOptions and the JSON schema.
When false (the default), the codegen errors on duplicate type names as
before. When true, FixDuplicateTypeNames auto-renames colliding types.

Also cleans up ComponentType: removes unused constants, improves doc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Marcin Romaszewicz <marcinr@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…egen#2212)

* Fiber deps in their own modules

Move the fiber dependences to their own modules, to contain Go 1.24
to the minimal subset of our code.

Update make rules to exclude Go 1.24 tests on Go < 1.24

Update Readme with minimum Go version for each router.

* Update Fiber in test issue

Contain Fiber to its own module in test for Issue 1469
We only need to run lint on a single version of Go, as the output isn't
Go runtime dependent, however, we need to be careful to run it in an
environment where the Go runtime isn't newer than what the golangci-lint
executable was built with, because it panics on some kind of version
check in that case.

Resolves: oapi-codegen#2214
…api-codegen#2211)

* support specifying package alias

* update test

* fix local package

* simplify
* fix: escape quoted media type directives

fixes oapi-codegen#1529

* squashme: expanded tests to cover iris, fiber & echo tests

* squashme: added makefile to fiber test directory, fixing root level tests

* squashme: actually fixed the generate issues with fiber tests

* squashme: skip fiber test for go versions <1.24

* squashme: make actually uses the execute-if-go-124 function
…2220)

Some real-world OpenAPI specs (e.g. Keycloak) reuse the same path
parameter more than once in a single URI, such as:
/clients/{client-uuid}/roles/{role-name}/composites/clients/{client-uuid}

Previously this caused a "has 4 positional parameters, but spec has 3
declared" error because SortParamsByPath compared raw URI placeholder
count against unique declared parameters.

Fix this by deduplicating the path parameters extracted from the URI
(preserving first-occurrence order) before matching them against the
spec declared parameters. This is the right level to fix the issue
rather than scattering dedup logic across template helpers.

Fixes oapi-codegen#1574
Supersedes oapi-codegen#2175

Co-authored-by: Junior Rantila <junior.rantila@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Response and RequestBodies need to include any additional types
into model generation. This is an ancient bug, from the very
first days of oapi-codegen.

Extend the issue-200 spec with inline objects containing
additionalProperties inside components/responses and
components/requestBodies. The test confirms the codegen produces
named types (Bar_Pagination, Bar_Metadata) for these inline schemas.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…api-codegen#2225)

* test: add regression test for issue oapi-codegen#2190

Add a minimal reproduction for invalid generated code when reusing
response components. The generated VisitGetTestResponse method attempts
[]byte(response) on a struct type, which does not compile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: generate correct type for $ref text responses in strict server (oapi-codegen#2190)

When a response is defined as a $ref to a component response with
text/plain content type (and no headers), the strict-server template
generated a struct-embedding type whose Visit method tried to call
[]byte(response) on a struct, which failed to compile.

The root cause was the revert of PR oapi-codegen#1132 (commit 891a067), which had
originally fixed this by making all text responses string types. That
PR was reverted because it broke text responses with headers (oapi-codegen#1676),
which require the struct form with a Body field.

The fix extends the existing multipart special case in Branch 1A of the
strict-interface template to also cover text responses without headers.
This generates a named type alias (e.g. `type GetTest401TextResponse
UnauthorizedTextResponse`) instead of a struct embedding, so
[]byte(response) compiles and works correctly.

Text responses with headers continue to go through Branch 1C (struct
with Body + Headers fields), so oapi-codegen#1676 is unaffected — confirmed by
verifying no diff in internal/test/issues/issue-1676/ping.gen.go.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…en#2222)

Fixes oapi-codegen#2116

Strict server handlers unconditionally decoded the request body,
causing an EOF error when no body was sent for operations with
optional request bodies (requestBody.required defaults to false in
OpenAPI 3.0).

For optional JSON bodies, the generated handlers now treat io.EOF
from the decoder as "no body provided" and leave request.Body as nil
rather than returning an error. For optional text bodies, an empty
read is similarly treated as absent. Required bodies retain the
original unconditional error handling.

All five strict server templates are updated: stdhttp (used by chi
and gorilla), echo, gin, fiber, and iris.

Two new test operations (RequiredJSONBody, RequiredTextBody) with
required: true are added to the strict server test schema to verify
both code paths are generated correctly.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…-codegen#2223)

* feat: add configurable type mapping for OpenAPI primitive types

Supersedes oapi-codegen#428, since the original author's branch is gone and
his PR only exists in the ref log.

Added a TypeMapping configuration that lets users override the default
OpenAPI type/format to Go type mappings. User-specified mappings are
merged on top of built-in defaults, so only overrides need to be
specified. For example, mapping string/date-time to a civil.DateTime
or changing the default integer type to int64.

Changes:
- New TypeMapping, FormatMapping, SimpleTypeSpec types with Merge()
  and Resolve() methods (pkg/codegen/typemapping.go)
- TypeMapping field added to Configuration struct
- Merged type mapping stored on globalState, initialized in Generate()
- Replaced hardcoded switch statements in oapiSchemaToGoType() with
  map-based lookups via globalState.typeMapping
- Updated configuration-schema.json with type-mapping property and
  reusable $defs for format-mapping and simple-type-spec
- Unit tests for merge, resolve, and default mapping completeness

Co-Authored-By: natsukagami <natsukagami@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Move TypeMapping to OutputOptions

* Add example for type-mapping

* Address PR feedback

Move type-mapping examples to output-options

---------

Co-authored-by: natsukagami <natsukagami@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Otherwise the sentence ends abruptly.
iamtakingiteasy and others added 15 commits February 16, 2026 19:24
* feat: add Valid() method to generated enum types

Generate a Valid() bool method on each enum type that returns true when
the receiver matches one of the defined enum constants and false
otherwise. This lets callers validate enum values at runtime with a
simple method call instead of hand-writing switch statements.

This is default-on because it only adds a new method to an already
generated type -- existing code that does not call Valid() is completely
unaffected, so this should be very unlikely to break anything.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Reduce complexity in enum validation

It turns out we don't need a sorted map of names, since we have
the same thing already present on the template context in a
different way.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Gaiaz Iusipov <g.iusipov@gmail.com>
Don't automatically review each PR, users can request a code review
via tagging @greptileai

Exclude generated files from code reviews. It's pointless.
As a fix similar to c4ba545, we had
cases where the global `prefer-skip-optional-pointer` could lead to not
nil checking when we should have been.

The previous behaviour would lead to incorrectly converting i.e.
`user_ids=nil` to `user_ids[]=`, which is not correct.

To do this, we can add the same helper functions that we have elsewhere.
…egen#2232) (oapi-codegen#2235)

When x-oapi-codegen-extra-tags was placed on the schema inside a
parameter definition (rather than on the parameter itself), the
extension was silently ignored. This happened because
GenerateParamsTypes only read parameter-level extensions, not
schema-level ones.

Merge extensions from both the parameter and its schema when building
the Params struct, with parameter-level extensions taking precedence.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
As a follow-up to oapi-codegen#2185, we can make sure we generate a Nullable type if
required to do so.
Fixes oapi-codegen#2091

The `omitempty` JSON tag was not being added to optional nullable fields.
The condition `!p.Nullable && shouldOmitEmpty` explicitly prevented any
nullable field from receiving `omitempty`, even when the field was
optional (not required). This contradicted the documented behavior.

The fix removes the `!p.Nullable` guard so nullable fields follow the
same `omitempty` rules as non-nullable fields. The special-case
exception for the `nullable-type` output option is no longer needed
since the logic is now uniform.

Note: `x-go-type-skip-optional-pointer: true` on a nullable field
suppresses the pointer (generating `string` instead of `*string`) but
still correctly receives `omitempty` when the field is optional. Whether
skip-optional-pointer should be allowed to suppress the pointer on
nullable fields is a separate concern.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
So it's clearer when the PR is for `examples/` or `internal/test/`,
similar to regular PRs.
So they don't get pulled into Release Drafter releases.
@zdunecki zdunecki merged commit 3d28653 into livesession Mar 2, 2026
47 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.