Skip to content

swagger:type override is not working #2229

@KevinJCross

Description

@KevinJCross

Problem statement

in our code we have this:

//swagger:type float64
type Decimal{
   D decimal.Decimal
}

This causes some interesting problems

  1. It does not override the struct type to float64 as the documentation suggests

  2. it creates the following self referencing type. This causes an infinite loop in the swagger diff which is sub optimal.

"Decimal": {
      "type": "object",
      "properties": {
        "D": {
          "$ref": "#/definitions/Decimal"
        }
      },
      "x-go-package": "github.com/SomeGit/package"
    },

Having a look at the code myself I go a bit lost as to where to implement it it seems the rxType exists but no rxTypeFmt and its not put into the parser.
Either can someone have a crack at fixing it or point me in the right directions to create a fix to override the struct parsing.

Upon further investigation it seems this commit has been forgotten/merged out ...
No doubt because it did not have any tests.
ca670fa

Ive had a crack at it myself and got muddled up with the old +1.11 code and the codescan package. Also where do I write the tests?

Metadata

Metadata

Assignees

No one assigned

    Labels

    generate specRelated to spec generation from code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions