Skip to content

Feature: allow enum ordered const name override (2nd PR for this) - #2046

Merged
sdghchj merged 10 commits into
swaggo:masterfrom
drewsilcock:feature/allow-enum-ordered-const-name-override-2
Jul 24, 2025
Merged

sdghchj merged 10 commits into
swaggo:masterfrom
drewsilcock:feature/allow-enum-ordered-const-name-override-2

Conversation

@drewsilcock

Copy link
Copy Markdown
Contributor

Describe the PR
Add ability to override name of enum variant generated from ordered constant using // @name VariantName in 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-descriptions now has the same length as enum, i.e. an empty value is put into the array instead of skipping it.
  • Pulled changes from master branch and updated my code and other code accordingly, namely changing TypeSpecDef.Alias() to use the nameOverride() function.
  • Improved enum tests a bit more.

Relation issue
#1778

Additional context
N/A

@sdghchj
sdghchj merged commit b0c5cc9 into swaggo:master 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().
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.

2 participants

⌂ 换网址