Create REST API documentation via swagger.io - swagger

I have my REST API created with JAX-RS and Resteasy. I annotated with swagger annotation and I would like to generate the documentation by running some task via the Eclipse maven plugin. (Eclipse Luna/Maven 3).
I included the following dependencies in the project .pom
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.2-M2</version>
</dependency>
I create a new configuration under Eclipse -> Run Configuration with a Goal set to Package, but when I run it nothing happens.
Am I missing some dependencies?
Can anyone suggest some tips, I am not making out in using this tool and the site documentation is not helping.
Thanks

take a look at the swagger-samples project, which shows how you need to configure your application after adding the annotations (which, I suggest you update to the latest, 1.5.7).

Related

How to use licensed version of flyway with dropwizard-flyway library

We are using the dropwizard-flyway library from https://github.com/dropwizard/dropwizard-flyway and want to use flyway Enterprise because we have SQL Server 2012. How can we get the license information into the dropwizard-flyway library?
We are trying out the trial version of flyway Enterprise and noticed that it installs its JARs into the maven repo org\flywaydb\trial.... Does this mean that we have to change our maven dependencies for flyway components from org.flywaydb.* to org.flywaydb.trial.* in order to use the trial version?
For others who may run into the same issue, this is how I eventually fixed it:
Download and unzip the flyway enterprise trial version
Navigate to the directory you unzipped into
Run installToLocalMavenRepo.cmd
Run deployToRemoteMavenRepo.cmd - here you will need your remote repo ID and URL. I found these in my distributionManagement section in my projects POM.XML file.
In your project POM.XML file - add an exclusion for flyway-core to the dropwizard-flyway artifact as follows:
<dependency>
<groupId>io.dropwizard.modules</groupId>
<artifactId>dropwizard-flyway</artifactId>
<version>5.0.7</version>
<exclusions>
<exclusion>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</exclusion>
</exclusions>
</dependency>
Add a dependency to flyway-core trial version as follows:
<dependency>
<groupId>org.flywaydb.trial</groupId>
<artifactId>flyway-core</artifactId>
<version>5.0.7</version>
</dependency>
You should now be good to go.

How to resolve spring security core plug in?

I am having problem with my exercise in Spring Security. I already declare on my pom file:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
and on my maven dependency, the spring security core jar file is there, but upon importing class UserDetailsService my eclipse cannot found it. I did cleaning and updating my maven project but nothing happens.
Hope someone can advice.
I can't add a comment so I will write here. Have you tried to delete local maven repository?

How to use RatingStars Vaadin addon

How to use RatingStars Vaadin addon?
I want to use RatingStars addon on all our vaadin pages so that we can get quick feedback from user.
Is there any example available which shows how to use that?
Using widgets with Vaadin (with or without Maven) usually means you have to do 3 things before starting your application:
adding the widget dependency to your classpath
compiling the widgetst
specifying your widgetset
From your description you've already done the first but you had some trouble, so let's take them separately and since you're already using Maven we'll just continue down this road:
1: Adding widgets
I used dependency in project but maven couldn't find this jar so it's failing
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>ratingstars</artifactId>
<version>2.1</version>
</dependency>
Some of the widgets, also known as add-ons, may not be available in the central maven repo, so make sure you add the Vaadin dedicated repo in your POM:
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
...
</repositories>
Now it should resolve and download your dependency, adding it to the classpath.
2: Compiling the widgetset
Then I manually downloaded that jar, unzipped it and kept that my source location. But it's still failing for
Failed to execute goal com.vaadin:vaadin-maven-plugin:7.6.1:compile (default) on project vaadin-widgetset: GWT Module org.vaadin.teemu.ratingstars.RatingStars not found in project sources or resources
Now, before you can run your app, you also need to compile the widgetset. If you've generated your project skeleton using the vaadin-archetype-application everything should be already configured and you simply need to run mvn package (or mvn vaadin:compile for just the compilation process).
Otherwise take a look at this sample project for a standard vaadin-maven-plugin configuration.
P.S. Depending on you IDE, you can also use dedicated IDE plugins for these tasks, but that's up to you.
3: Specifying the widgetset
Finally, depending on your servlet version and app setup you can define your widgetset location by:
using the web.xml file:
<init-param>
<description>Application widgetset</description>
<param-name>widgetset</param-name>
<param-value>com.example.MyWidgetSet</param-value>
</init-param>
annotating your UI with #Widgetset("com.example.MyWidgetSet")
Now you should be able to run your application and see the widget on your screen :-)

Maven: dynamic specification of dependencies

I have started to learn Maven and have the following question:
I would like to dynamically specify a dependency for building maven project instead of using the dependency specified in POMs - is there a way to do that?
So although I have the following dependencies specified in POM
...
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>ProjectComponent</artifactId>
<version>1.0</version>
</dependency>
...
I would like to specify in the build command that I want to use a different version.
Is there a way to specify this?
The idea is that I want to have an integration build made in Jenkins with a dependency on the latest available snapshot of the system for a particular branch. That snapshot is not released to the maven repository yet, so I would like to fetch it in Jenkins and specify a dependency for mvn build.
Thanks!
POSSIBLE SOLUTION: What I ended up with is to use ${my.lib.version} construction and specify it with -Dmy.lib.version=1.0-SNAPSHOT" when calling to mvn. Thus I can use it for Jenkins integration builds by fetching arbitrary snapshot versions of dependencies from svn and feeding their snapshot versions to the integration build pom.
Maven may use "dynamically" specified property (ex: group.ProjectComponent.version) with the help of profiles.
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>ProjectComponent</artifactId>
<version>${group.ProjectComponent.version}</version>
</dependency>
So if you create some profiles you may switch between them (see maven references)
Example:
<profile>
<id>stable-builds</id>
<properties>
<group.ProjectComponent.version>1.0</group.ProjectComponent.version>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>beta-builds</id>
<properties>
<group.ProjectComponent.version>2.0.Beta1</group.ProjectComponent.version>
</properties>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
</profile>
What I ended up with is to use ${my.lib.version} construction and specify it with -Dmy.lib.version=1.0-SNAPSHOT" when calling to mvn. Thus I can use it for Jenkins integration builds by fetching arbitrary snapshot versions of dependencies from svn and feeding their snapshot versions to the integration build pom.
Just came across this as I was looking for something similar. In my case same application code is being reused on different stacks which means using different "drivers" for accessing data. Although drivers implement same interface they do come from different artifacts.
No you can't change the dependencies dynamically. Furthermore it does not make sense, cause you would like to have a reproducible build.

Using Maven API download a JAR

In a simple java program, How can I download a JAR from a Maven repository ?
The repository can be local as well as remote ? I am using Maven 3.
As noted by #amit your use of Maven-3 is not relevant. Your application is interested in accessing a JAR at runtime. It just so happens that this JAR is available at a Maven repository. Maven is a build-time tool. It cannot help you at runtime.
So if we have interpreted your question correctly, the issue is one of formulating the URL and making an HTTP request. Since you say the JAR is hosted by a Maven repository you know the format of the URL:
http://repository.url/group_id_segments_separated_with_slashes/artifact_id/version/artifact_id-version.jar
You can take advantage of this in your program if you need to access more than one JAR in this fashion.
define the necessary mapping for dependency tags in POM.xml and than provide repository information inside repository tags... for example..
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.11</version>
</dependency>
and
<repository>
<id>snapshot-repository.java.net</id>
<name>Java.net Snapshot Repository for Maven</name>
<url>https://maven.java.net/content/repositories/snapshots/</url>
<layout>default</layout>
</repository>
see more about this here

Resources