send function to swagger.js
Right now, need to reload swagger.js when key changes. Would be best if we can pass a function to swagger.js so it's read on each query.
please support the same for additional header params :)
+1
Would be very nice to be able to have arbitrary headers defined as inputs in the banner. I was attempting the get some OAuth2 hotness going in my API GUI. Altering the banner was simple enough. Any advice on how to alter swagger-ui in order to pull the params in as headers on every XHR?
getting there. We're just finishing up oauth 2 in the swagger spec for java, moving to node next.
Sweet :-)
-Paul Hill
On 2013-06-23, at 8:17 PM, Tony Tam [email protected] wrote:
getting there. We're just finishing up oauth 2 in the swagger spec for java, moving to node next.
— Reply to this email directly or view it on GitHub.
also, if you missed it...
https://twitter.com/fehguy/status/348516794748776449
Dude, that's awesome. Your timing is perfect. I'm going to jump right on that.
-Paul Hill
On 2013-06-23, at 8:45 PM, Tony Tam [email protected] wrote:
also, if you missed it...
https://twitter.com/fehguy/status/348516794748776449
— Reply to this email directly or view it on GitHub.
OK, let me know if you need help on it
While I've got your ear. I recently had to do rather a dodgy hack to get two swagger UI instances running in the same node.js server. Because of the requires cache you end up with one set of references by default. I was going to convert the swagger node express project to export an object constructor but thought I'd better ask you if there was another way you had in mind or had seen?
-Paul Hill
On 2013-06-23, at 8:45 PM, Tony Tam [email protected] wrote:
also, if you missed it...
https://twitter.com/fehguy/status/348516794748776449
— Reply to this email directly or view it on GitHub.
Sorry I meant 2 swagger-node-express instances.
On Sunday, June 23, 2013, Paul Hill wrote:
While I've got your ear. I recently had to do rather a dodgy hack to get two swagger UI instances running in the same node.js server. Because of the requires cache you end up with one set of references by default. I was going to convert the swagger node express project to export an object constructor but thought I'd better ask you if there was another way you had in mind or had seen?
-Paul Hill
On 2013-06-23, at 8:45 PM, Tony Tam <[email protected]<javascript:_e({}, 'cvml', '[email protected]');>> wrote:
also, if you missed it...
https://twitter.com/fehguy/status/348516794748776449
— Reply to this email directly or view it on GitHubhttps://github.com/wordnik/swagger-ui/issues/176#issuecomment-19887864 .
eh, I haven't thought through that yet, so glad you brought it up before a refactor starts. Let's open a new ticket so it can be addressed
I don't mind doing it. Just wanted to check it didn't mess you up. Let me know if I should do that or wait for the refactor.
On Sunday, June 23, 2013, Tony Tam wrote:
eh, I haven't thought through that yet, so glad you brought it up before a refactor starts. Let's open a new ticket so it can be addressed
— Reply to this email directly or view it on GitHubhttps://github.com/wordnik/swagger-ui/issues/176#issuecomment-19888884 .
sure, please feel free
Ok, I've written it as an object constructor export. Will test it tomorrow and submit a pull request. I'm not super excited about making it an object (all those noisy this.) but can't think of a better way.
-Paul Hill
On 2013-06-23, at 9:48 PM, Tony Tam [email protected] wrote:
sure, please feel free
— Reply to this email directly or view it on GitHub.
I ended up writing a little requires cache name-spacing gizmo that made it un-necessary to turn it into an object.
I did write the code for the object thing so I'll just email it to you if you are keen on taking that path. It's arguably the right way to do things if you want it to be able to run in a browser. I can't imagine why one would serve an API out of a browser but who knows.
My little cache name spacing gizmo works better in my case because I know I can assume Node.js as the environment. I can load as many swagger-node-js instances as I like and don't have to alter the module with all those noisy prototype and this references.
:-)
On Sunday, June 23, 2013, Paul Hill wrote:
Ok, I've written it as an object constructor export. Will test it tomorrow and submit a pull request. I'm not super excited about making it an object (all those noisy this.) but can't think of a better way.
-Paul Hill
On 2013-06-23, at 9:48 PM, Tony Tam <[email protected]<javascript:_e({}, 'cvml', '[email protected]');>> wrote:
sure, please feel free
— Reply to this email directly or view it on GitHubhttps://github.com/wordnik/swagger-ui/issues/176#issuecomment-19888969 .
https://npmjs.org/package/node-named-require
Sorry to co-opt this thread. Still looking forward to arbitrary headers for auth in swagger-ui
You can now add any header params you like, programmatically. See in swagger-js, which is integrated in this branch of swagger-ui:
https://github.com/wordnik/swagger-ui/tree/develop-2.0
That functionality has been there for a while. But I believe the intention was to make it so the user could enter an oauth token in an input field to be sent as a header on each subsequent request.
-Paul Hill
On 2013-07-11, at 10:26 PM, Tony Tam [email protected] wrote:
You can now add any header params you like, programmatically. See in swagger-js, which is integrated in this branch of swagger-ui:
https://github.com/wordnik/swagger-ui/tree/develop-2.0
— Reply to this email directly or view it on GitHub.
hey @fehguy and @paulhill . Do you mind pointing where to look for custom headers by method?
Is not develop-2.0 behind master?
I want to modify swagger-ui to sign all requests using something like amazon does http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html. Theoretically It should intercept the ajax request, use some of the parameters for create the hasg, add a custom http header with the hash and then allow the ajax call to continue.
Thanks, swagger is great.
hi @diaspar swagger-ui is now up-to-date, develop-2.0 is obsolete (and going away soon). I think we chatted on irc (or somebody else today asked the exact same question) but you should look here:
https://github.com/wordnik/swagger-ui#custom-header-parameters---for-basic-auth-etc
and of course you can write your own signing routine by making something like this:
https://github.com/wordnik/swagger-js/blob/master/src/swagger.coffee#L792
class ApiKeyAuthorization
type: null
name: null
value: null
constructor: (name, value, type) ->
@name = name
@value = value
@type = type
apply: (obj) ->
if @type == "query"
if obj.url.indexOf('?') > 0
obj.url = obj.url + "&" + @name + "=" + @value
else
obj.url = obj.url + "?" + @name + "=" + @value
true
else if @type == "header"
obj.headers[@name] = @value