Skip to content
New issue

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

net/ghttp: Use ghttp.MiddlewareHandlerResponse causes the responses value in the swagger document to be incorrect #3786

Open
nonlinearthink opened this issue Sep 18, 2024 · 2 comments
Labels

Comments

@nonlinearthink
Copy link

What do you want to ask?

I am using ghttp.MiddlewareHandlerResponse, but the output swagger document does not include the 'code', 'message', and 'data' fields, and I used the swagger-generator to generate the client's code, which strongly depends on the swagger document.

@UncleChair
Copy link

Middleware would not change the final doc. If you want to add a "common response", you can add one in the openapi config

openapi.Config.CommonResponse = api.CommonRes{}

or change response structure one by one in your Standardized Routing.

@nonlinearthink
Copy link
Author

@UncleChair Thank you, I have resolved this problem through:

openapi := s.GetOpenApi()
openapi.Config.CommonResponse = ghttp.DefaultHandlerResponse{}
openapi.Config.CommonResponseDataField = "Data"

@nonlinearthink nonlinearthink changed the title github.com/gogf/gf/v2/net/ghttp: Use ghttp.MiddlewareHandlerResponse causes the responses value in the swagger document to be incorrect net/ghttp: Use ghttp.MiddlewareHandlerResponse causes the responses value in the swagger document to be incorrect Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants