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.

Share header with multiple response objects

See original GitHub issue

Can there not just be a simple header generically at the response level not specific to each of the status codes? For our case, this kind of header is 99% the same across our codebase.


---

responses:
  200:
    description: no error
    headers:
      Content-Type:
        description: application/json
        type: string

It would be a pain to copy+paste this to each and every routine that supports HTTP JSON responses.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:10
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

12reactions
michael-ocommented, Mar 12, 2020

Obviously the example is bad. consider the following model:

paths:
  /api/v1/modules:
    get:
      tags:
        - Modules
      summary: Lists all available modules
      operationId: listModules
      responses:
        200:
          $ref: "#/components/responses/modulesOk"
        400:
          $ref: "#/components/responses/400"
        401:
          $ref: "#/components/responses/401"
        403:
          $ref: "#/components/responses/403"
        404:
          $ref: "#/components/responses/404"
        406:
          $ref: "#/components/responses/406"
        408:
          $ref: "#/components/responses/408"
        500:
          $ref: "#/components/responses/500"

Codes like 401, 403, 404, 406, 408 will repeat through all paths. If one could add this to a generic section and selectively overwrite it, it’d be great. Having 50 paths and adding that block over and over again ist just pain.

0reactions
darrelmillercommented, Apr 27, 2017

@webron Fine: content-length, Transfer-encoding, Range, … how obscure do I need to get? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Standard for adding multiple values of a single HTTP Header ...
It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by...
Read more >
How to Set a Header on a Response with Spring 5 - Baeldung
If we want to set headers on single responses, we can use HttpServletResponse or ResponseEntity objects. In contrast, if our objective is to ......
Read more >
HTTP headers - MDN Web Docs - Mozilla
Request headers contain more information about the resource to be fetched, or about the client requesting the resource. Response headers hold ...
Read more >
HTTP/1.1: Header Field Definitions
The Accept request-header field can be used to specify certain media types which are acceptable for the response. Accept headers can be used...
Read more >
Common Response Headers - Amazon Simple Storage Service
Specifies whether the object returned was (true) or was not (false) a delete marker. Type: Boolean. Valid Values: true | false. Default: false....
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