oatpp / oatpp-swagger

OpenApi 3.0.0 docs + Swagger UI for oatpp services
https://oatpp.io/
Apache License 2.0
91 stars 51 forks source link

swagger-ui load resources path incorrect #16

Closed r2dliu closed 4 years ago

r2dliu commented 4 years ago

I'm building a cmake project on windows and loadResources appears to always append a forward slash, ie "C:...\res/favicon-16x16.png", resulting in a crash. Am I doing something wrong or was this not intended to be multiplatform?

lganzzzo commented 4 years ago

Hello @r2dliu ,

oatpp-swagger is intended to be cross-platform. If it doesn't work for you, it might be a bug. Also loadResources function should not prepend anything as there is no code in it's implementation doing that.

How do you call loadResources function?

Try to put the full path to installed swagger-ui resources.

  OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::swagger::Resources>, swaggerResources)([] {
    // Make sure to specify correct full path to oatpp-swagger/res folder !!!
    return oatpp::swagger::Resources::loadResources("<FULL-PATH-HERE>");
  }());

Also, make sure that your application has access to the resource files.

Please let me know if it helped!

Regards, Leonid

r2dliu commented 4 years ago

I caught a mistake with my file path, it looks like it works as intended! Thanks for the response.