Swagger Generates docs for the classes in jar - rest

New to swagger :
I have a web application which combines multiple modules jars into a single war file. Now I want to be able to generate swagger docs for those modules classes (jars) as well. how do I do it?

Related

How to Add Existing Bundles as Declarative Services Within OSGI Enroute

I have a folder of existing bundled jars I need to use as declarative services. I'm aware of how to treat these like typical Eclipse Plugins and have them declared inside of the typical Component.xml file inside of my plugin project OSGI-INF folder, but now I'd like to follow the OSGI Enroute style of coding and load my bundles as Declarative Services inside there. It seems like services are added to the generated Component.xml for you with OSGI Enroute when you add the #Component annotation, but I'm struggling to figure out how to bring in my pre-existing bundles as Declarative Services since they don't have the annotations in them and I can't change their code (plus they don't have poms). Is there some intuitive way of solving this that I'm missing? Enroute seems like a great way to handle OSGI otherwise.
If I understood your question right, then:
You have legacy bundles
You can not change the code of those bundles
Services with in those bundles are not Declarative Services (using the #Component annotation)
You want to have those services as Declarative Services
In that case you could write the XML files for the Declarative Services yourself:
Add a new Maven module to your project
Add the legacy bundle(s) as dependency
Add the "hand-written" XML files for those services as sources to the module
Let Maven unpack the legacy bundles
Add the "hand-written" XML files to the new bundle with Maven
Update the MANIFEST.MF of the bundle (if necessary)
Package everything back to a OSGi bundle
In the end the #Component annotation is just used to create XML files during the build describing your Declarative Service. If the code for those old service does not change anymore, it would be reasonable to write the XML files by hand.

GWT hosted mode and tomcat deploy differences

I have a very specific problem dealing with GWT. I have a web application and a jar file which contains the business logic. Inside this jar I use dozer mapper and I have the related config file inside the jar itself. The config file is under META-INF/dozer_mappings.xml. While in hosted mode it works perfectly, in web mode it has a problem. It says:
Unable to locate dozer mapping file [/META-INF/dozer_mappings.xml] in the classpath!
Actually I don't understand why it should change: if the file is not in the classpath it should not work in both the environments... Of course all my libraries are in the WEB-INF/lib folder. The one with the dozer configuration is there as well.

swagger : annotation in java code to json spec conversion

I am looking for a tool that reads the java file with swagger annotation and generates that API JSON spec file? Please do let me know if there is already one.
You can use swaggerdocgen Maven plugin to generate Swagger documents in the both JSON and YAML formats. This is assuming that you are able to use Maven for your application.
You can find more information about swaggerdocgen plugin here: https://github.com/WASdev/tool.swagger.docgen
Basically, you need to create a WAR Maven project and add your application files there. Then as part of running mvn package, the Swagger document will be generated in the 'Target' directory of your project.

CQ5 - Separate out a servlet's business logic into a standalone bundle

I am new to java, osgi, bundles, cq5 console etc..
Can someone please point me to a tutorial or a starting point from where I can learn how to do what I am trying to achieve.
Basically we have common search functionality in 3-4 CQ5 websites, all of which reside on a single cq instance. This same functionality is implemented in all websites as a servlet and is called from client side using javascript. Redundant code....
We would like to:
a) take this servlet's code out from all the websiteName-core bundles where it resides repeatedly as of now.
b) create a single separate standalone installable OSGI bundle which only contains a servlet.
Then we would like to call this single separated out bundle from all our CQ5 websites's client side.
Aprt from code redundancy, we wish to make this common search bundle shippable so that other development teams can use it in their projects by just installing it in their console and calling the servlet.
Long story short. I want to create an OSGI bundle that has a servlet.
I wish to have an understanding of the whole game here and would prefer to get a tutorial link that explains it from start to end.
You can start by turning the search code into a separate maven multi module project.The archetype and instructions for creating one can be found on adobe's documentation site (link)
The maven multimodule project will have two module's Bundle and content. Bundle will hold all the servlets, OSGI services and back-end stuff. The content module will have all the UI and authoring related stuff like templates and components. It maps to the repository on the CQ server. The UI nodes are serialized and stored on flat file systems as XML documents.
Since it is a maven project on it's own, it's dependencies will be self contained. In the bundle module add the search servlet and all the required classes. The compiled package of this project will be shippable.
As long as the package is installed in the server, any other website will be able to make calls to it.
Servlets in sling are implemented as OSGI services of javax.servlet.Servlet class. Any exported service of the Servlet class will be recognized by the sling servlet resolver, You can get more details of it at this link
Sharath Madappa's answer is correct if you want to create a set of related bundles and distribute them as a CQ content package.
If you just want to create a single bundle to package some OSGi services (including servlets) you just need to build the bundle jar with the required metadata. The Apache Sling GET servlets bundle is a good example of that.

sbt for web app with command line code

I'd like sbt to generate two packages:
A WAR file, for the web app
A JAR file, which has command line and batch code
The two packages share a lot of similar code (the business logic) and dependencies, but of course the Servlet aspects are only in the WAR, and the command line and batch only in the JAR.
I'd like the JAR to run by itself, no external dependencies required (ala sbt-assembly).
How can I do this?
WAR file
You can make a war file using earldouglas/xsbt-web-plugin and use sbt-assembly for fat JAR. You might have to get a bit creative to include some files in one but exclude from the other.
Generating JAR and WAR from the same code base
If the resulting packages contain different library dependencies at the end, for example including Jetty or Netty for standalone JAR, I think it needs to be a separate subproject. See Multi Project builds.