We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug
As READMD.md mentioned below:
// JSONResult's data field will be overridden by the specific type proto.Order @success 200 {object} jsonresult.JSONResult{data=proto.Order} "desc"
swaggo supports overriding an existing struct with another struct type in comments.
However, in the v2 branch, this feature is not working correctly.
To Reproduce Steps to reproduce the behavior:
create a simple example:
main.go
import ( "net/http" "swaggo-v2/api" ) // @title Swagger Example API // @version 1.0 // @description This is a sample server Petstore server. // @termsOfService http://swagger.io/terms/ // @contact.name API Support // @contact.url http://www.swagger.io/support // @contact.email support@swagger.io // @license.name Apache 2.0 // @license.url http://www.apache.org/licenses/LICENSE-2.0.html func main() { http.HandleFunc("/testapi/data1/", api.GetData1) http.HandleFunc("/testapi/data2/", api.GetData2) http.ListenAndServe(":8080", nil) }
api/api.go
package api import "net/http" type Response struct { httpStatus int `json:"-"` Code string `json:"code" example:"0"` Msg string `json:"message"` Data interface{} `json:"data"` } type GetData1Response struct { Field1 string `json:"field1" example:"Field1"` Field2 string `json:"field2" example:"Field2"` } // GetData1 godoc // // @Summary Get data1 // @Produce json // @Success 200 {object} Response{data=GetData1Response} // @Router /internal/data1 [get] func GetData1(w http.ResponseWriter, r *http.Request) { //write your code } type GetData2Response struct { Field3 string `json:"field3" example:"Field3"` Field4 string `json:"field4" example:"Field4"` } // GetData2 godoc // // @Summary Get data2 // @Produce json // @Success 200 {object} Response{data=GetData2Response} // @Router /internal/data2 [get] func GetData2(w http.ResponseWriter, r *http.Request) { //write your code }
Expected behavior expect swagger.yaml should be like this
not currently would got like this
Your swag version v2.0.0-rc4
Your go version go1.23.1
Desktop (please complete the following information):
Additional context Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
As READMD.md mentioned below:
swaggo supports overriding an existing struct with another struct type in comments.
However, in the v2 branch, this feature is not working correctly.
To Reproduce
Steps to reproduce the behavior:
create a simple example:
main.go
api/api.go
Expected behavior
expect swagger.yaml should be like this
not currently would got like this
Your swag version
v2.0.0-rc4
Your go version
go1.23.1
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: