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

support describing response headers #426

Merged
merged 1 commit into from Mar 9, 2020
Merged

Conversation

zhulijian1
Copy link
Contributor

Fixes #419

In the OpenAPI Specification, response object has a headers field. (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#responseObject)

But there is no field about headers in struct ResponseError. So I can not use code to describe the response header.

type ResponseError struct {
	Code      int
	Message   string
	Model     interface{}
	IsDefault bool
}

I added the Headers field with reference to the OpenAPI Specification. And in order to maintain compatibility, I did not modify Returns method, but added a new method ReturnsWithHeaders.

@emicklei
Copy link
Owner

your change looks good to me.
unfortunately, the OpenAPI specifics are now in the go-restful package ; most of it I was able to put in the go-restful-openapi package.
However, I can imagine that the non-OpenAPI counterpart will look just like you included in the PR.
I does not make sense to come up with a different type (another name) with will have the same fields anyway.

@zhulijian1
Copy link
Contributor Author

zhulijian1 commented Mar 9, 2020

My aim is to achieve the ability to define response headers and automatically generate a complete swagger doc. So I need a structure to save the response header's information. But if I don't add that structure, I can not find any structure suitable for describing the response headers.
Do you have any good suggestions on what I should do to achieve my aim?

@emicklei
Copy link
Owner

emicklei commented Mar 9, 2020

@zhulijian1 no i do not. I will merge this change and make it available in v2 and v3

@emicklei emicklei merged commit 23def8e into emicklei:master Mar 9, 2020
emicklei pushed a commit that referenced this pull request Mar 9, 2020
@zhulijian1
Copy link
Contributor Author

thanks :)

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 this pull request may close these issues.

can not specify response header?
2 participants