Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

How does one initializemiddleware for multiple swagger documents? #513

Closed
amittapalli opened this issue Jun 21, 2017 · 3 comments
Closed

Comments

@amittapalli
Copy link

No description provided.

@whitlockjc
Copy link
Member

The singular call to swaggerTools.initializeMiddleware DOES NOT support this. You could do this by chaining your calls, so long as each document has a separate base URL and/or the paths do not collide.

@amittapalli
Copy link
Author

amittapalli commented Jun 27, 2017

Is there a good example in node that allows chaining of initialize calls. I tried to do something like that but did not seem to work. The first document that I use to call 'swaggerTools.initializeMiddleware(swaggerDoc, function (middleware)'
seems to take precedence regardless of how many other ones I initialized after it.
I tried to change the basePath in each document as well

@whitlockjc
Copy link
Member

It's just like any other callback-based API. You can use something like async or do it manually yourself:

swaggerTools.initializeMiddleware(doc1, function (mw1) {
  // Do stuff with first middleware

  swaggerTools.initializeMiddleware(doc2, function (mw2) {
    // Do stuff with second middleware

    // Repeat...
  });
});

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

No branches or pull requests

2 participants