#2499·go-swagger

x-go-custom-tag tag not taken into account in some cases since 0.26.0

Author: maxatomeCreated Jan 25, 2021Updated Aug 11, 2026
Labelsfuture/maybetags

Problem statement

x-go-custom-tag tag is no longer taken into account for a property.

Following spec using swagger-v0.26.0 generates:

type Bad struct {

        // blah blah blah
        Test MyType `json:"test,omitempty"`
}

while swagger-v0.25.0 generates:

type Bad struct {
        
        // blah blah blah
        Test MyType `json:"test,omitempty" db:"test"`
}

Swagger specification

yaml
definitions:
  MyType:
    type: array
    items:
      type: string

  Bad:
    type: object
    properties:
      test:
        $ref:  '#/definitions/MyType' 
        description: blah blah blah
        x-go-custom-tag: db:"test"                                     

  Ok:
    type: object
    properties:
      test:
        type: array
        items:
          type: string
        description: blah blah blah
        x-go-custom-tag: db:"test"                                     

Steps to reproduce

swagger-v0.26.0 generate model -f api.yaml

Environment

swagger version: 0.26.0 go version: 1.15.7 OS: Linux amd64