-
Notifications
You must be signed in to change notification settings - Fork 105
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
OpenApi3 - For responses, use Reason Phrase as description instead of status code #177
Comments
Hey @marcelo-s , Thank you for reaching out! If I understand your request correctly, it's not about putting the HTTP "Reason Phrase" (how https://datatracker.ietf.org/doc/html/rfc2616#section-6.1 calls it) into the description, but to add another parameter somewhere to set this description (OpenAPI 3 spec allows for any free-text description)? I'd advise to not introduce a new parameter. There is no equivalent Spring Restdocs descriptor, either. We could also duplicate the description and write it to the response, too (since each Spring Restdocs |
@ozscheyge Thanks for your reply :) . My idea was at least to put the official RFC "Reason Phrase" of the status code as a "Response description". And if possible, allow to customize that description instead of the official "Reason Phrase" for that status code. Please note that the description that you refer to, and link to, is the description of the whole operation which is unrelated to this enhancement. I only refer to the description of the OpenApi Response Object. It is true, that sadly Spring Rest Docs does not provide any help here, as there is no way to set this value. As an "easy" implementation, I would suggest to have a map of "statusCode" to "human readable description" based on the RFC document. That way, the function would set the description by calling this map with the status code and getting the "human readable description" for that status code. |
Okay, so if it's about the Reason Phrase, it should be pretty straight-forward. There's probably a (Spring) library function for this already.
Yep, exactly. But wouldn't be wrong either, since each |
Yes, you're right. Each document call maps to a specific response. That could be another solution as well. But I still prefer to have the mapping of Status code to Reason Phrase, I think that is more standard in terms of status code description. The |
Is: Responses description is the string value of the status code. Example:
Should: Response description should have the description defined by section 10 of RFC 2616. Example:
If not mistaken the line of code is this one:
restdocs-api-spec/restdocs-api-spec-openapi3-generator/src/main/kotlin/com/epages/restdocs/apispec/openapi3/OpenApi3Generator.kt
Line 337 in b4bd4bb
Perhaps also the option to customize this description.
The text was updated successfully, but these errors were encountered: