swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.77k stars 1.2k forks source link

Support swagger type format for global override #1852

Open Yavith opened 4 months ago

Yavith commented 4 months ago

Is your feature request related to a problem? Please describe. I am trying to declare a global override in .swaggo to replace my custom date struct with the string swagger type using the date-time format

Describe the solution you'd like The solution I would be along the lines of an additional formatting parameter after the type in the 'replace' function e.g.

replace src/types.NullTime string date-time

Describe alternatives you've considered One workaround I've explored is to replace this type with another custom type with the correct swagger format:

type NullTimeSwagger struct {
    String *string `swaggertype:"string" format:"date-time"`
}

However, the generated doc places the date-time string inside a struct, which is undesirable.

serious-snow commented 2 months ago

hope same

type SFID int64

type GreeterReq struct {
    ID SFID `json:"id"`
}

The result I want is type:string, format: int64 I don't want to label every field that uses SFID, but I want to rewrite it through the interface, or--overrides Fileld