hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
191 stars 98 forks source link

swagger.json is missing basePath property from Swagger Configuration #139

Open grgshfr opened 8 years ago

grgshfr commented 8 years ago

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:

<dependency>
    <groupId>com.eclipsesource.jaxrs</groupId>
    <artifactId>swagger-all</artifactId>
    <version>1.5.7</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.eclipsesource.jaxrs</groupId>
    <artifactId>publisher</artifactId>
    <version>5.3.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.eclipsesource.jaxrs</groupId>
    <artifactId>jersey-all</artifactId>
    <version>2.22.2</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.eclipsesource.jaxrs</groupId>
    <artifactId>provider-swagger</artifactId>
    <version>1.1.1</version>
    <scope>provided</scope>
</dependency>
hstaudacher commented 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.

bearcherian commented 8 years ago

@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.

ctron commented 8 years ago

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.

ctron commented 8 years ago

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.

jmacauley commented 8 years ago

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!

BryanHunt commented 8 years ago

@hstaudacher Are you going to be able to look at this?

tomq42 commented 8 years ago

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.

madhugarimilla commented 7 years ago

@hstaudacher @BryanHunt Is there a plan to incorporate the fix for this issue anytime soon?

col-panic commented 7 years ago

@hstaudacher Could you please quote whether you are still actively maintaining this project and considering pull requests? Thank you very much!

BryanHunt commented 7 years ago

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).

col-panic commented 7 years ago

Thank you @BryanHunt for clarifying this! 👍

col-panic commented 6 years ago

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