krakenjs / hapi-openapi

Build design-driven apis with OpenAPI (formerly swagger) 2.0 and hapi.
Other
211 stars 75 forks source link

How to load multiple Swagger definitions on the same HAPI server #48

Closed pibi closed 8 years ago

pibi commented 8 years ago

Hi. I have many different files for API definitions that sets many paths in my swagger project. I want to load them in isolated plugins. I don't know how to do that correctly, actually I'm using a wrapper like this one:

var swaggering = {
  register: function (server, options, next) {
    return Swaggerize.register(server, options, next);
  }
};
swaggering.register.attributes = {
    name: Swaggerize.register.attributes.name+ '-' + API_NAME,
    version: Swaggerize.register.attributes.version
};

Is there any "official" way for that? Thanks a lot!

tlivings commented 8 years ago

I'd say that's probably close to an official way. The intent of this module is really one server, one API. But there's definitely nothing stopping you from wrapping it and registering multiple times.