I have a go web application with swagger docs generation. Recently in my project was added new endpoint that uses following struct in POST & PUT requests:
Secret struct {
// Secret unique key name.
Name string `json:"name" example:"ACCESS_TOKEN"`
// type: string
// x-go-type: "string"
Value json.RawMessage `json:"value" swagger:"type:string"`
// Tags in which this secret is used.
Tags []string `json:"tags" example:"dev,prod,omitempty"`
}
when i am attempt to build swagger docs with command: swag init -md ./documentation -o ./swagger
i am getting following error:
If i am correctly understand there should be added type definition explicitly
, but i don't understand how to define type correctly, all combination of commentaries does not work. This issue is related with json.RawMessage
type (Value field) because if i replace this type with interface{} everything works fine.
CodePudding user response:
I found solution for my issue, previously i have to omit usage --parseDependency
because swagger doc generation hangs but if i simultaneously pass --parseDepth
1 my docs generates successfully, so a full cmd is:
swag init --parseDependency --parseInternal --parseDepth 1 -md ./documentation -o ./swagger
As i understand this occurs because json.RawMessage
requires import but if i am not using --parseDependency
json.RawMessage type could not be found but in my question case single --parseDependency hangs so it could not be used. Solution is to use --parseDepth
argument