mulesoft-labs / swagger-to-raml-object

This repository is deprecated! Please use the official oas-raml-converter instead.
https://github.com/mulesoft/oas-raml-converter
Other
26 stars 5 forks source link

Open link with authentication #4

Closed mmans closed 8 years ago

mmans commented 9 years ago

Hi!

I'm trying to convert a swagger definition on a public website. The problem is that I need to login on this site. Is there a way to get around this?

Greetz, Marco Mans

sichvoge commented 9 years ago

Can you elaborate a little bit more about what public website and if you try to convert a Swagger 2.0 definition?

mmans commented 9 years ago

Hi Christian!

Thanks for the quick response!!!

I try to convert a swagger def on this site: https://my.zipato.com/zipato-web/v2-doc/doc

This is the header of the definition:

{ "apiVersion" : "v2", "swaggerVersion" : "1.2", "apis" : [ {

So it is a swagger 1.2 definition.

When I download the file from the website, I can successfully convert it to RAML. But the complete API is splittet into 30+ seperate documents, and I'm too lazy to download them all :)

I think a possible tweak would be to inject a cookie (JSESSIONID) from a authenticaties webbrowser session.

Do you need any more information?

Regards,

Marco Mans

2015-03-12 14:53 GMT+01:00 Christian Vogel notifications@github.com:

Can you elaborate a little bit more about what public website and if you try to convert a Swagger 2.0 definition?

— Reply to this email directly or view it on GitHub https://github.com/mulesoft/swagger-to-raml-object/issues/4#issuecomment-78483072 .

mmans commented 9 years ago

With the following dirty-tweak I am able to convert the full api:

File function filereader (filename, done) { if (/https?:\/\//i.test(filename)) { var j = request.jar(); var cookie = request.cookie('JSESSIONID=DE6A571064D0A712AFE1A1C9B1xxxxxx.frontend3'); j.setCookie(cookie, filename); var req = request(filename, { 'jar':j }, function (err, res, body) { return done(err, body); }); return req; }

return fs.readFile(filename, 'utf8', done); }

blakeembrey commented 8 years ago

@mmans I'm going to close this issue, it looks like you solved. You could always override the "filereader" to support what you needed using the JavaScript API.