mimi0007
mimi0007

Reputation: 91

How to define "interface" as a datatype in open API?

In my golang project, I have a structure that contains this field:

type hook struct {
   Data interface{} `json:"data"`
}

How to represent this Data field in Open API Spec?

Upvotes: 0

Views: 502

Answers (1)

kukymbr
kukymbr

Reputation: 185

It is not a good idea to use the absolutely free form type in the specification, I think, but if you want to do so, use the {} form of definition:

data: {}

Also you can add a null value to the allowed:

data:
  nullable: true

See the "Any Type" section of the types documentation: https://swagger.io/docs/specification/data-models/data-types/

Upvotes: 1

Related Questions