swag icon indicating copy to clipboard operation
swag copied to clipboard

support array of pointers Model composition in response

Open wu0407 opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. Support array of pointers for objects as nested response. May be that is no pointless, it can work on array of object. but it diffrent from the code. struct defind:

type ResponsePaginated struct {
	Count int64 `json:"count"`
	BaseHttpResponse
}

type BaseHttpResponse struct {
    Code         int         `json:"error_code" yaml:"error_code"`                   
    ErrorMessage string      `json:"error_message,omitempty" yaml:"error_message,omitempty"` 
    Data         interface{} `json:"data,omitempty" yaml:"data,omitempty"`            
    ErrorDetail  interface{} `json:"error_detail,omitempty" yaml:"error_detail,omitempty"`  
}

the annotation of response:

@success      200  {object}  httptool.ResponsePaginated{data=[]*coreapi.Pod}  "pod list"

executing init return invalid type: httptool.ResponsePaginated{data=[]

Describe the solution you'd like generate docs sucuccess

Describe alternatives you've considered current the solution is replace array of pointers to array of object.

Additional context Add any other context or screenshots about the feature request here.

wu0407 avatar Dec 13 '21 14:12 wu0407

@wu0407 This is an Open Source project. If this is a must for you, please feel free and contribute through a PR, and we will be more than happy to assist you with a code review.

ubogdan avatar Dec 15 '21 14:12 ubogdan

Is it essential to add * ? It has no effect on the swagger docs.

sdghchj avatar Dec 30 '21 02:12 sdghchj

More in line with go language habits

wu0407 avatar Jan 01 '22 02:01 wu0407