question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for `default` HTTP response

See original GitHub issue

According 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:open
  • Created 5 years ago
  • Reactions:6
  • Comments:18 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
dsilvasccommented, Apr 14, 2019

@blast-hardcheese That seems reasonable. Right now I take the generated swagger and replace all defaults with 200s before feeding it to guardrail.

1reaction
kelnoscommented, Apr 1, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found