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

Removing an API, adding an API using JSON and preventing handler generation. #1

Open
lgomez opened this issue May 6, 2016 · 4 comments

Comments

@lgomez
Copy link

lgomez commented May 6, 2016

Hi, I'm trying out the library. Really great work.

I'm going through the code now but have a few questions:

  1. Is there a way to dynamically remove an API from a running server (using restify in my case)?
  2. Is there a recommended way to pass a json swagger object instead of yaml?
  3. Is there a way to prevent handler generation completely?

Thank you!

@lgomez lgomez changed the title Removing an API and the effect on routes. Removing an API, adding an API using JSON and preventing handler generation. May 6, 2016
@mikestead
Copy link
Owner

Hey @lgomez,

  1. Do you mean remove a full swagger api version you've previously registered? Not currently, could you outline your use-case there?
  2. You can pass a yaml or json local file path, or js object, to the api value of config.
  3. Yeah you can disable handler generation. See generate option at the bottom of the section here

@lgomez
Copy link
Author

lgomez commented May 6, 2016

That was quick!

  1. I am trying to host load APIs into a running server based on GitHub commit notifications. So, if an existing API is changed, I'd like to remove the previous version and add the new one.
  2. Perfect.
  3. Doh! I missed that option.

Thank you,

@lgomez
Copy link
Author

lgomez commented May 7, 2016

Elaborating a bit on no. 1 above:

I'm using a restify .pre function to namespace the routes to a specific API based on the hostname. So, say I have two APIs: one being served under example.com and the other under test.example.com the routes for each would be prepended when added so my routes don't conflict. So, if I have:

  • http://example.com/users it would be set up as /example-com/users and
  • http://tes.example.com/users would be set up as /test-example-com/users

So, I know I could scan my routing table and remove all routes that match the same hostname before re-adding the updated version of the API but I was wondering if removing was something that I could do already with your library.

Thanks again!

@mikestead
Copy link
Owner

Thanks for the details. That's an approach I'd not considered.

In regards to removing all routes of an API, I may look at adding this when I get a little time.

I did have a quick look now and it seems (not tested) the best way to remove a route would be to scan the server.router.mounts object for routes you want to remove, and then pass any of those route objects to server.rm. You may have already found that out but putting here to remind myself later.

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

No branches or pull requests

2 participants