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

can not specify response header? #419

Closed
tianxiaoliang opened this issue Jan 13, 2020 · 3 comments · Fixed by #426
Closed

can not specify response header? #419

tianxiaoliang opened this issue Jan 13, 2020 · 3 comments · Fixed by #426

Comments

@tianxiaoliang
Copy link

// Returns allows you to document what responses (errors or regular) can be expected.
// The model parameter is optional ; either pass a struct instance or use nil if not applicable.
func (b *RouteBuilder) Returns(code int, message string, model interface{}) *RouteBuilder {
	err := ResponseError{
		Code:      code,
		Message:   message,
		Model:     model,
		IsDefault: false, // this field is deprecated, use default response instead.
	}
	// lazy init because there is no NewRouteBuilder (yet)
	if b.errorMap == nil {
		b.errorMap = map[int]ResponseError{}
	}
	b.errorMap[code] = err
	return b
}

now I can not use code to describe the response header, it can not automatically generate a complete swagger doc.

is there any way I can generate response header spec?

@emicklei
Copy link
Owner

Did you have a look how go-restful-openapi is generating Swagger (OpenAPI) docs?

@tianxiaoliang
Copy link
Author

yes

@emicklei
Copy link
Owner

If you use go-restful-openapi then with the PostBuildSwaggerObjectHandler you can perhaps achieve what you want. Your question is not clear about what you are missing in "describe the response header"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants