Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set integer type enum generated as string from x-enum-varnames instead #1717

Open
hwlee96 opened this issue Dec 12, 2023 · 1 comment
Open

Comments

@hwlee96
Copy link

hwlee96 commented Dec 12, 2023

I have an enum in my gin code that is defined similar with iota, e.g.:

package types

type Class int

const (
	A Class = iota + 1 // AAA
	B                  /* BBB */
	C
	D
)

and this would output with swaggo:

Actual Behaviour (where the schema indicates the expected type returned is integer)

definitions:
  types.Class:
    type: integer
    enum:
      - 1
      - 2
      - 3
      - 4
    x-enum-comments:
      A: AAA
      B: BBB
    x-enum-varnames:
      - A
      - B
      - C
      - D

However, in my gin code, the type returned is string, not integer. Hence, I'd like the type returned for this enum to be the string values from x-enum-varnames instead.
Desired Behaviour

definitions:
  types.Class:
    type: string
    enum:
      - A
      - B
      - C
      - D
    x-enum-comments:
      A: AAA
      B: BBB

Would this be possible with any custom configuration?

@sdghchj
Copy link
Member

sdghchj commented Dec 18, 2023

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

No branches or pull requests

2 participants