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

Structural improvements: enhance headers handling #690

Open
arno-di-loreto opened this issue May 11, 2016 · 18 comments
Open

Structural improvements: enhance headers handling #690

arno-di-loreto opened this issue May 11, 2016 · 18 comments
Labels
headers re-use: globals/defaults Default or global components that can be overridden in some way
Milestone

Comments

@arno-di-loreto
Copy link
Contributor

Following (again) ideas from #563 and OAI/sig-moonwalk#115, extending #369:

paths:
  responseHeaders:
     # Headers returned on all api responses
  /resources:
    responseHeaders:
      # Headers returned on all /resources operations responses
    get:
      responseHeaders:
        # Headers returned on all operations responses
      200:
         headers:
           # Headers returned on this response
schemas:
  responseHeaders:
    # reusable headers describe with a Header Object, used with $ref

The problem is the naming consistency: responseHeaders almost everywhere vs headers on response level.
What if we use headers or responseHeaders everywhere?

nb: and don't forget to modify Header Object to include #321 (required)

@arno-di-loreto
Copy link
Contributor Author

parent #560

@webron
Copy link
Member

webron commented May 19, 2016

Can't put my finger on it, but something here seems tricky when it comes to the resolution of the 'effective' spec. Multiple levels of being able to define both headers and responses (which can define the headers as well)... feels like a recipe for trouble. I'm probably overthinking it though.

@etoews
Copy link

etoews commented Jun 9, 2016

Being able to define reusable response headers in someway is a necessity. Having to constantly repeat yourself for response headers is a significant maintenance burden.

@talolierwork
Copy link

Sounds like a great idea, maybe even generalize it even more to use refer to definitions-like item from various places for reuse.

@iq-dot
Copy link

iq-dot commented Nov 24, 2016

Absolutely a great idea and a must have.

Currently we hare facing issues where we have to copy paste headers across all APIs which makes for error prone updates and maintainability issues. The key flexibility would be able to reference the headers and in addition specifying headers at a global level would help clean up the spec.

@n-alex-white
Copy link

I agree, some means of defining standard headers to be applied to all the requests and responses in a swagger definition would be exceptionally useful. At the moment an API definition I'm working on has been bloated by 1,300 lines by the need to include the same additional headers for each response code on each API member.

it obscures the intent and provides maintenance problems; it is crying out for the ability to reference standard sets of headers IMO.

@synackSA
Copy link

I'm in the process of trying to define a API now and the thought of adding the rate-limit headers to every single response definition is already making me want to pack it in. This really needs to happen,.

@darrelmiller
Copy link
Member

@synackSA Personally, I would define a 429 response in #/components/responses and reference it on whichever operations are rate limited.

I've never quite understood why APIs choose to return rate limiting headers on successful responses. Do client applications actually read those values and hold off on making requests until they know the reset period has ended? Is there some other function that makes them useful?

@JeanMertz
Copy link

Do client applications actually read those values and hold off on making requests until they know the reset period has ended? Is there some other function that makes them useful?

As a reference: our Jenkins setup has a feature where it "scrapes" our organisation's repositories and checks all branches for a valid Jenkinsfile. This plugin actually reads the X-Rate-Remaining value from the GitHub API and implements backoff functionality to spread out GitHub API requests to make sure it doesn't run out of requests before the limit is reset every hour.

Just wanted to chime in that apparently, there are valid use-cases for these headers 👍

@synackSA
Copy link

I'm personally not sure if will or won't but they can't blame us for not providing the information to them, it's up to them to actually implement it, either way, they will get rate limited if they it their limit. All the info is there for them to manage it otherwise.

@n-alex-white
Copy link

Four years on, are we any closer to getting response headers definable as components in the same way that request headers are?

Is there anything that can be done to help move this issue forwards somehow?

@handrews handrews added headers re-use: globals/defaults Default or global components that can be overridden in some way and removed OpenAPI.Next Proposal labels Feb 8, 2024
@handrews
Copy link
Member

@n-alex-white It's possible to reference re-usable response headers under #/components/headers so I'm not sure what your question is. The larger issue here is setting headers at different levels, which is a much bigger change.

@Raimo33
Copy link

Raimo33 commented Oct 5, 2024

Almost 2025 and not even with OpenAPI3.1 we have the possibility of creating general response headers (for multiple response codes)

Big maintainability issue still!

@TamSzaGot
Copy link

A well needed feature indeed.

@handrews
Copy link
Member

This seems like something for which the now-released Overlay Specification might be the best solution?

@handrews
Copy link
Member

@OAI/tsc this sort of "set a global thing to apply everywhere" feels like it's best addressed by the now-published Overlay Specification. Do we want to make that official and close this enhancement in favor of Overlays?

@mikekistler
Copy link
Contributor

@handrews Maybe. But I think there's a counter-argument worth considering.

The counter-argument is that some people will want the API description to be complete on its own -- not require an Overlay to "fix it up". Saying that you must use Overlays for this kind of thing just makes it harder for API description authors and API description users.

An alternative approach is to borrow some of the ideas from the Overlays spec. By that I mean that we could include an "actions" field in the OAS that would work very much like the actions in Overlays. This reuses concepts and possibly technology that is already built but makes it directly available in OAS.

@handrews
Copy link
Member

@mikekistler I could see having an overlays field in the OpenAPI Object that would let you name sets of overlays to apply, which could be inline or referenced 🤔 (just speculating here, don't take it too seriously!)

I'll put this in 3.3 for further consideration, as I suspect there would be too much to work out for the super-quick 3.2 plan.

@handrews handrews removed the review label Nov 21, 2024
@handrews handrews added this to the v3.3.0 milestone Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
headers re-use: globals/defaults Default or global components that can be overridden in some way
Projects
None yet
Development

No branches or pull requests