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
Configuring global request parameters #152
Comments
I don't believe we're going to support global parameters so quickly. That's the bad news. The good news is that authorization gets special treatment anyways and there's a way to declare security schemes globally. I just updated the security sections in the spec yesterday/today (depending on your TZ) which allows you to declare a security header or query parameter that needs to be sent with the request. https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#swaggerSecurityDefinitions By the way, this is not new to 2.0 and could have been done in previous versions as well. |
So, as far as I understood, the security scheme type I should use to solve my problem (just to pass the |
That is correct. |
Ok, I'll look into it. Thank you =]. |
Hi @webron I have this defined in the global swagger-spec: securityDefinitions:
forwarded:
name: authorization
type: apiKey
in: header /profiles/me:
x-swagger-router-controller: profile
get:
security:
- passaporte:
- forwarded
description: Gets the information about the current user
operationId: me How can I obtain the security params? Thank you, |
I'm not sure what you mean by that question... |
I am sorry. Let me try to put this another way. My problem is the the same of the first post in this thread: I need to forward an authorization header to another API. This is repeated across almost every API entry, but the authentication and refresh authentication ones. Right now, I'm doing it in an operation-base: parameters:
- name: authorization
in: header
description: The user access token
required: true Now I'm trying to remove this and use the security object, but I need access to the security parameters in order to forward them, but I couldn't find a way of doing so. |
What do you mean access and forward them? Swagger is for documentation, there's no 'action' behind it. |
When I'm passing a header as a parameter, I'm able to access it like: function someExpressRouteCallback(req, res) {
var authorization = req.params.swagger.authorization.value;
} What I'm asking is if there's a way of obtaining the value of this authorization header when I configure it as a security definition. |
This is using which library? |
Oh, I see now. This is not defined here. Sorry about that. |
Hehe, yeah. They may have not had the chance to implement it yet, but you should bring it up with them. |
@webron can you please help me how to access apiKey at url after setting it. https://stackoverflow.com/questions/49050969/setting-swagger-apikey-in-version-3-0 |
Is it possible to set a default apikey value like the one below.
I tried this, but it doesn't work. |
Could we have a way for declaring global request parameters?
I'm working on an aggregation API that has its own authentication method. What I do is just to forward an
Authentication
header to these APIs that will handle the authentication.Currently, I have to set:
in every request.
Is there an easy way to include a option that allows us to configure global request parameters? I'm pretty sure I'm not the only one with this need. Some coleagues of mine have worked with swagger some time ago and they told me they had faced the same issue.
Suggestions I have for this:
Having an wildcard entry on paths:
It could be very repetitive if we needed to set the parameters for every request method.
Having an wildcard entry on paths that allows global path and global method configuration:
This way, we could set global parameters for every method and refining if needed.
There should also be a way to ignore these global configurations, such as:
Also, there should be possible to overwrite the global configurations, like:
The text was updated successfully, but these errors were encountered: