Skip to content

How to use custom extensions while reusing definitions? #2885

Answered by lcbm
lcbm asked this question in Q&A
Discussion options

You must be logged in to vote

Was able to make it work with a workaround. Really wish we could use it with $ref tho 😢

// MyObjectType my object type
//
// swagger:model MyObjectType
type MyObjectType struct {

	// ID
	ID *pkg.ID `json:"id,omitempty" bson:"f,omitempty"`

	// num
	Num Number `json:"number" bson:"number"`
}

This is what makes it work 👇

x-go-type:
  type: "Number"
  
# equivalent to
x-go-type:
    type: "Number"
    import:
      package:
      alias:
    hints:
      kind: <whatever default is>
      noValidation: false
      nullable: <whatever default is>
    embedded: false

swagger.yml

swagger: "2.0"

info:
 version: version
 title: title

paths: {}

x-types:
  id: &ID
    type: "ID"
    import:
      p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lcbm
Comment options

Answer selected by lcbm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant