Repository navigation
Conversation
…m-ordered-const-name-override
Otherwise, there's no way to know which descriptions corresponds to which enum value.
As per PR swaggo#1866, the name override functionality has been removed from TypeName() and put into Alias() which is used by SetSchemaName().
sdghchj
approved these changes
Jul 24, 2025
pborgen
pushed a commit
to pborgen/swag
that referenced
this pull request
Jan 8, 2026
…aggo#2046) * Implement getting name override from comment for enum ordered consts. * Update README and enum tests for enum variant name override feature. * Update to address comments and linting. * Fix typo in ConstVariable.VariableName() comment. * Improve named enum testing. * `x-enum-descriptions` should have same length as `enum` array. Otherwise, there's no way to know which descriptions corresponds to which enum value. * Update TypeSpecDef.Alias() to use standard nameOverride() function. * Fix enum test. * Remove name override from TypeSpecDef.TypeName() method. As per PR swaggo#1866, the name override functionality has been removed from TypeName() and put into Alias() which is used by SetSchemaName().
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.
Describe the PR
Add ability to override name of enum variant generated from ordered constant using
// @name VariantNamein the same way you can do for types.Note: This is based on another PR, #1779, which was stuck in a state where it couldn't get merged as it had been approved by one person but required re-approval by another. This is based on that PR with a few extra changes:
x-enum-descriptionsnow has the same length asenum, i.e. an empty value is put into the array instead of skipping it.TypeSpecDef.Alias()to use thenameOverride()function.Relation issue
#1778
Additional context
N/A