Open grgshfr opened 8 years ago
hmm, sounds weird. See here: https://github.com/hstaudacher/osgi-jax-rs-connector/blob/master/bundles/com.eclipsesource.jaxrs.provider.swagger/src/com/eclipsesource/jaxrs/provider/swagger/internal/OSGiJaxRsScanner.java#L47
The base path is set form the config.
@hstaudacher we added the config for the PID, and made sure it loaded correctly in the OSGi, but the swagger.json file doesn't show the basePath value. We applied the config by editing in the Felix console, and also by entering it in via the bundle activator, and it does not show the basePath in the JSON.
I can confirm that the swagger configuration parameters never get applied.
Digging a bit into the source I found that the "updated" method of the SwaggerConfiguration
class does get called with the proper dictionary. However the "configure" method of OSGiJaxRsScanner
never gets called.
I just found a workaround, at least for the "swagger.info" part. It is possible to add a @SwaggerDefinition
annotation to any service registered with the OSGi connector. This gets picked up by swagger.
Spent days on this before giving up and deciding to generate an issue. Turns out I should have checked here earlier in the process to save some time. I am encountering the same bug and can confirm ctron's workaround does indeed work. +1 to get this fixed. Thank you!
@hstaudacher Are you going to be able to look at this?
I've got the same issue. Digging around a bit, this is what I currently find.
The activator calls io.swagger.config.ScannerFactory.setScanner. However the corresponding getScanner method never gets called.
Stepping through the swagger code, if goes into SwaggerContextService.getScanner, which calls SwaggerScannerLocator,getScanner. Only if that returns null does it then fall back to ScannerFactory.getScanner(). However, SwaggerScannerLocator,getScanner, as a fallback, returns new DefaultJaxrsScanner(), and never returns null. So we end up not using the OSGiJaxRsScanner class, which is the thing that applies the configuration.
So a fix is to change the Activator so that it does:
SwaggerScannerLocator.getInstance().putScanner("swagger.scanner.id.default", new OSGiJaxRsScanner(swaggerConfiguration));
instead of
ScannerFactory.setScanner(new OSGiJaxRsScanner(swaggerConfiguration));
Now I class this as a bit of a hack at the moment, since I don't really know were the "swagger.scanner.id.default" value comes from. However it does cause the configuration to be applied.
@hstaudacher @BryanHunt Is there a plan to incorporate the fix for this issue anytime soon?
@hstaudacher Could you please quote whether you are still actively maintaining this project and considering pull requests? Thank you very much!
I'm working toward maintaining this project. I'll work on pull requests once #181 is complete. Things are going a bit slow right now because I have other higher priority side projects (I can only work on this in my free time).
Thank you @BryanHunt for clarifying this! 👍
I just could verify, that the provided patch from xeagle2 works for me. I pulled it into my upgraded fork on https://github.com/MEDEVIT/osgi-jax-rs-connector
We are noticing that swagger.json lacks the basePath property in addition to other properties from the configuration. We have used a bundle activator and see that the settings are set properly in the OSGI configuration under the services PID for com.eclipsesource.jaxrs.swagger.config. All bundles are activated as required.
This is leading to the "Try it Out" button not working in Swagger UI.
We are implementing this in Apache Felix.
We are using the following: