Skip to content

Add support for enumerations as strings. #17

@RParkerHp

Description

@RParkerHp

Currently, if I create an enumeration that's represented by a string in JSON, the generated swagger type is integer.

When I submit that property value as a string in swagger, it silently fails until I change the value to be a number, but then the JSON marshalling fails.

What would be good is to add support for a field tag so the type can be overridden. Something like:

type Model struct {
  type MyType `swagno:"string"`
}

And then:

  fieldType := (field.Tag.Get("swagno"))
  if fieldType == "" {
      fieldType = getType(field.Type.Kind().String())
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions