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

Responses with custom HTTP statuses cannot be documented #639

Closed
JeremieLapert opened this issue Sep 12, 2019 · 7 comments
Closed

Responses with custom HTTP statuses cannot be documented #639

JeremieLapert opened this issue Sep 12, 2019 · 7 comments

Comments

@JeremieLapert
Copy link

Hi, everybody !
I actually use the la version of spring-rest-docs 2.0.3.RELEASE.
I have created a custom HttpStatus code (215) in my WebService and when i want to documentit , I have the following error :

`java.lang.IllegalArgumentException: No matching constant for [215]

at org.springframework.http.HttpStatus.valueOf(HttpStatus.java:532)
at org.springframework.restdocs.mockmvc.MockMvcResponseConverter.convert(MockMvcResponseConverter.java:40)
at org.springframework.restdocs.mockmvc.MockMvcResponseConverter.convert(MockMvcResponseConverter.java:35)
at org.springframework.restdocs.generate.RestDocumentationGenerator.handle(RestDocumentationGenerator.java:196)
at org.springframework.restdocs.mockmvc.RestDocumentationResultHandler.handle(RestDocumentationResultHandler.java:55)
at org.springframework.test.web.servlet.MockMvc.applyDefaultResultActions(MockMvc.java:223)
at org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:189)`

How to do ? Do you have an idea because I am a little lost.

Thanks,
Jérémie

@ghost
Copy link

ghost commented Sep 12, 2019 via email

@JeremieLapert
Copy link
Author

Hi, effectively i use a response entity.
This is my code :
return ResponseEntity.status(215).body(elements)

@wilkinsona wilkinsona changed the title Custom HttpStatus Support documenting responses with custom HTTP statuses Sep 12, 2019
@wilkinsona
Copy link
Member

@JeremieLapert Unfortunately, custom HTTP statuses are not supported at the moment.

@wilkinsona
Copy link
Member

The ExhangeResult from WebTestClient does not provide access to the raw status code. I've opened spring-projects/spring-framework#23630.

@wilkinsona wilkinsona changed the title Support documenting responses with custom HTTP statuses Responses with custom HTTP statuses cannot be documented Sep 12, 2019
@wilkinsona wilkinsona added this to the 2.0.4.RELEASE milestone Sep 12, 2019
@wilkinsona
Copy link
Member

This fix for this isn't as invasive as I thought it might be so I'm comfortable with fixing it in 2.0.x.

@wilkinsona
Copy link
Member

We can follow up and make an equivalent change for WebFlux once we know which versions of Framework will contain the necessary fix.

@JeremieLapert
Copy link
Author

@wilkinsona : Thank you very much for your quick help.
I look forward to this new version.

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

No branches or pull requests

3 participants