Support for `default` HTTP response
See original GitHub issueAccording to the OpenAPI Spec 2.0 the responses
section can declare a default
response.
responses:
'200':
description: Good things happened
default:
description: An error occurred.
schema:
$ref: '#/definitions/exception'
...
definitions:
exception:
type: object
required:
- code
properties:
code:
type: string
description:
type: string
When running codegen from sbt the following error is reported:
Unknown HTTP type: default
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:18 (17 by maintainers)
Top Results From Across the Web
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >HTTP/1.1: Response
The first line of a Response message is the Status-Line, consisting of the protocol version followed by a numeric status code and its...
Read more >Default Response Codes | RESTful Java with JAX ... - dennis-xlc
The default response codes that JAX-RS uses are pretty straightforward. There is pretty much a one-to-one relationship to the behavior described in the...
Read more >List of HTTP status codes - Wikipedia
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a...
Read more >HTTP Support - Spring
The expected-response-type must be compatible with the (configured or default) HttpMessageConverter instances and the Content-Type header in the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@blast-hardcheese That seems reasonable. Right now I take the generated swagger and replace all defaults with 200s before feeding it to guardrail.
What I’d suggest:
For servers, do nothing. Emit a warning when we see a
default
response. Agreed that catch-alls in a server is a smell.For clients, it’d be nice if everyone could be explicit, but it appears that’s might be too much to ask. Honestly, it’s not bad how it is now (unknown response codes returning an error containing the raw framework response object), but we could maybe do it a little nicer. Since we’re likely already emitting the definition and decoder for the default response type, we could provide an extra method on the error type in the
Left
that unmarshals the response to it. At the very least, we need to instead a warning and not bail on generation.