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

103 Views Asked by At

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?

1

There are 1 best solutions below

0
Kukymbr On BEST ANSWER

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/