swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.36k stars 2.17k forks source link

OSGI bundle for Swagger-Core #272

Closed MiloHub closed 9 years ago

MiloHub commented 10 years ago

I am looking for OSGI bundle version on swagger -core maven plugin.Any advice

ddragosd commented 10 years ago

This can be achieved with maven-bundle-plugin:

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>1.4.0</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>
                            ${pom.artifactId}
                        </Bundle-SymbolicName>
                        <Export-Package>
                            scala*, <!-- unless you have scala already exposed -->
                            org.scalastuff.scalabeans.*,
                            com.thoughtworks.paranamer,
                            com.wordnik.swagger.*;version=1.2.1,
                            com.sun.jersey.multipart.*;version=1.13,
                            com.fasterxml.*,
                            com.fasterxml.jackson.module.scala.*
                        </Export-Package>
                    </instructions>
                </configuration>
            </plugin>

It would be nice though to have it as part of swagger-core.

MiloHub commented 10 years ago

Thanks for the post. Mentioned export package need to converted to OSGI bundle?

ddragosd commented 10 years ago

This is just an example using maven-bundle-plugin, and it works with Jersey. If you don't use Jersey you may only need to expose a subset of these packages.

MiloHub commented 10 years ago

I tried adding at the parent pom(swagger-core).but the manifest is created with no import and export packages. Am i missing anything

fehguy commented 10 years ago

I suggest you add this to swagger-jaxrs or swagger-jersey-jaxrs

MiloHub commented 10 years ago

I added at swagger-jaxrs below is the manifest got generated

Manifest-Version: 1.0 Export-Package: com.wordnik.swagger.jaxrs.listing;uses:="scala.collect ion,scala.collection.immutable,javax.ws.rs,com.wordnik.swagger.annota tions,scala.collection.mutable,scala.runtime,com.wordnik.swagger.core ,scala,javax.servlet,scala.reflect,com.wordnik.swagger.jaxrs,scala.co llection.generic,javax.ws.rs.core";version="1.2.1",com.wordnik.swagge r.jaxrs;uses:="scala.collection.immutable,scala.collection,com.faster xml.jackson.databind,javax.ws.rs,com.wordnik.swagger.annotations,scal a.util.matching,scala.collection.mutable,com.wordnik.swagger.core,sca la.runtime,javax.ws.rs.ext,scala,org.slf4j,org.apache.commons.lang,ja vax.servlet,scala.reflect,com.wordnik.swagger.core.util,scala.collect ion.generic,javax.ws.rs.core";version="1.2.1" Bundle-Version: 1.2.5 Tool: Bnd-0.0.238 Bundle-Name: swagger-jaxrs Bnd-LastModified: 1375391584032 Created-By: 1.6.0_26 (Sun Microsystems Inc.) Bundle-ManifestVersion: 2 Bundle-Description: Sonatype helps open source projects to set up Mave n repositories on https://oss.sonatype.org/ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.html Bundle-SymbolicName: swagger-jaxrs_2.9.1 Import-Package: com.fasterxml.jackson.databind;version="2.1",com.wordn ik.swagger.annotations,com.wordnik.swagger.core,com.wordnik.swagger.c ore.util,com.wordnik.swagger.jaxrs;version="1.2.1",com.wordnik.swagge r.jaxrs.listing;version="1.2.1",javax.servlet,javax.ws.rs;version="1. 1",javax.ws.rs.core;version="1.1",javax.ws.rs.ext;version="1.1",org.a pache.commons.lang;version="2.4",org.slf4j;version="1.6",scala,scala. collection,scala.collection.generic,scala.collection.immutable,scala. collection.mutable,scala.reflect,scala.runtime,scala.util.matching

fehguy commented 10 years ago

is it working?

MiloHub commented 10 years ago

I got error for other dependent bundle in the deployment, scala . Also i converted swagger-annotation to osgi which was another dependent package

MiloHub commented 10 years ago

Is there any plan for making

com.wordnik
        <artifactId>swagger-jaxrs_2.9.1</artifactId>
    as OSGI bundle version?
ddragosd commented 10 years ago

+1 in making the swagger bundles OSGI compatible. Besides this, once you move into OSGI you also need to reset Swagger cache when you know you have deployed a new Resource. This is something that's not OOTB and it depends on the particular implementation. For this reason I'd also add an integration-test with Apache Felix or Apache Karaf to show how to implement Swagger with OSGI. WDYT ?

fehguy commented 10 years ago

It's not in the current plans but if there are contributions, happy to see about getting it in.

ddragosd commented 10 years ago

In which branch should we contribute this ? 1.3-RC3 or master or another one ?

ddragosd commented 10 years ago

For now I've added OSGI support in the scala_2.10.0 branch from my fork, until we decide in which branch we should push the code. I've chosen scala_2.10.0 branch as scala 2.10 comes with OSGI support OOTB. ( using scala 2.9.1 involves some extra export packages and the solution is not that clean ).

@fehguy how is the roadmap for scala support in the master branch ? Are there any plans to have 2.10 supported as default ?

fehguy commented 10 years ago

Hi, I would work off the 1.3-RC3 branch as the right place to work from. Scala 2.10 will become the default shortly (RC3 on 2.10 was just pushed to maven central last night).

ddragosd commented 10 years ago

"...RC3 on 2.10 was just pushed to maven central last night..." -> from scala_2.10 branch or from another one ?

fehguy commented 10 years ago

scala_2.10-1.3-RC3 is the correct branch for the 2.10 version

fehguy commented 9 years ago

supported in 1.3.7