feat: add support for custom package alias for external ref imports#2211
Merged
mromaszewicz merged 4 commits intooapi-codegen:mainfrom Feb 13, 2026
Merged
Conversation
Member
|
Your CI failure has nothing to do with your code. |
mromaszewicz
approved these changes
Feb 12, 2026
Member
|
We will merge this once I get my CI fix approved, and you rebase to run precommit using that fix. |
6657405 to
ca82a7e
Compare
Member
|
Thank you, @InventivetalentDev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for specifying a package alias for external imports, which allows using custom names instead of auto-generated aliases like
externalRef0,externalRef1, ...This allows for more consistent import names when dealing with large projects and multiple linked specs, where the same
externalRef0import can end up referencing different source packages.Motivation
I'm using
oapi-codegenin a complex project in combination withtygoto generate TS types for my frontend code.tygoalso supports external imports, but they need to be explicitly mapped from the Go package to the TS file, so my config for that currently looks something like this:needing to map the same package/type multiple times since different files have varying starting indexes for externalRef imports.
Using the custom alias allows me to simply do this instead:
previous implementation: #2193