go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

generates nested types in doc

Open zlx362211854 opened this issue 1 year ago • 2 comments

Provides the ability to generate nested types like

type CommonResponse {
	Code    int    `json:"code"` // 100 | 200
	Message string `json:"message"`
}
type UserCreateDto {
	Id string `json:"id"`
}
type UserCreateResponse {
	CommonResponse
	Result *UserCreateDto `json:"result"` // result
}

is generate to


type UserCreateResponse struct  {
	Code    int    `json:"code"` // 100 | 200
	Message string `json:"message"`
	Result struct {
            Id string `json:"id"`
        } `json:"result"` // result
}

zlx362211854 avatar Jul 28 '22 07:07 zlx362211854

How can we know when to be nested or not?

kevwan avatar Jul 28 '22 13:07 kevwan

image

image

i use this spec.ApiSpec.Types to determine whether it is a golang built-in type, and if it is, then call getRefProperty to generate the nested types

zlx362211854 avatar Jul 29 '22 02:07 zlx362211854

Use #2368 instead

kesonan avatar Sep 07 '22 09:09 kesonan