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

Create an API documentation page based on the files #16

Open
sideshowcoder opened this issue Nov 28, 2013 · 10 comments
Open

Create an API documentation page based on the files #16

sideshowcoder opened this issue Nov 28, 2013 · 10 comments

Comments

@sideshowcoder
Copy link
Owner

Scanning through the directory to explore the API is nice but it would be great if it would be possible to output a simple HTML page which just lists the available endpoints with their requests.

Something like seen in the readme for showing what canned can do.

@peinguin
Copy link

Hello. My name is Sergei. I have an idea about issue#16.
My code has few problems. But I want show it to you.
I use swagger-ui. And not display's root folder, but can if need.
If you like that idea - we may discuss next steps for improving it.

@sideshowcoder
Copy link
Owner Author

Hi Sergei, I really like the idea, I just scrolled through the code real quick and it looks like a good approach really. One thing I would love to have so would be the option to turn it off, so the idea would be to make it more like a plugin you activate instead of having it always available. Maybe we can define a hook to hook into the canned method to inject stuff like this before we route to canned this would open it up for more processing since I think their will be some parts you want to filter out of the docs for example.

It is a great start and thanks for taking this on!

For reference the pull request is #38

@peinguin
Copy link

I define some like router in canned.js. But file "swagger.js" is like a plug-in.
It is possible to add support for plug-ins. And modify router.
Also I can add method setFolder. And setApiUrl. And configure plug-in through them.

@sideshowcoder
Copy link
Owner Author

That sounds like a good idea, so I would suggest moving the swagger.js file to a extensions folder, and make its loading configurable maybe passing something like this on the command line

$ canned --extensions swagger

and then instantiate swagger with the setFolder and setApiUrl and such so it can be passed.

if(extensions.swagger) new Swagger(options)

The reason for all this really is that love the concept of doing this with swagger but I also see that a lot of people don't want to use swagger so keeping it configurable seems like a good way to go for now.

What do you think about that?

@peinguin
Copy link

I try to realize it tomorrow. Another version

$ canned --include swagger "{endpoint: 'swagger'}"

And JS

includes.forEach(function(include){
  fs.stat(include.name, function(stat){
    if(!stat.isDirectory())
      return fasle

    var extension = require('./extensions/'+include.name+'/main.js')
    new extension(include.options && JSON.parse(include.options))
  })
});
}

Or something like this.

And it would be nice to add extensions to express chain.

@peinguin
Copy link

Please see 4a82e08
I ass express.
Designed as separate module. And add extensions mechanism.

@peinguin
Copy link

Try

$ ./bin/canned ./example/
$ ./bin/canned ./example/ --extensions=swagger,notexist
$ ./bin/canned ./example/ --extensions=swagger,notexist --swaggerEndpoint=docs

@sideshowcoder
Copy link
Owner Author

There has been work going on to use express in #33 and the branch express-canned but looking over this I'm not sure if the dependency to express adds that much. As far as I can see you use express to have the support for middleware can't you achieve the same with just using async.waterfall?

I don't mind the dependency to express if necessary but since it is quite a big dependency canned needs to track changes etc. I want to be sure we really need it.

@sideshowcoder
Copy link
Owner Author

(lets move the discussion to the pull request so I can comment on code :) )

@peinguin
Copy link

I add "async" variant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants