Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

merge from develop 2.0 for release #2

Merged
merged 28 commits into from
Jun 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
build/
lib/*.jar
target
samples/scala-play2/logs
.idea
.idea_modules
.settings
.project
.classpath
.cache
atlassian-ide-plugin.xml
*.iml
.java-version
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# swagger-samples

The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and
computers to discover and understand the capabilities of the service without access to source code, documentation, or
through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the
remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level
programming, Swagger removes the guesswork in calling the service.

Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger
project, including additional libraries with support for SpringMVC, other languages and more.

## What's here?

This repository serves for samples for various projects. Right now it contains the samples for swagger-core under
the java library. Each sample contains a README file with details how to run it and what to check.
10 changes: 10 additions & 0 deletions java/java-dropwizard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To run the sample:

```
mvn package

java -jar target/swagger-java-dropwizard-sample-app-1.0.0-SNAPSHOT.jar server conf/swagger-sample.yml

```

You can then access swagger at http://localhost:8080/swagger.json
8 changes: 8 additions & 0 deletions java/java-dropwizard/conf/swagger-sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defaultName: Swagger-sample
logging:
level: ERROR
appenders:
- type: console
threshold: ALL
timeZone: UTC
target: stdout
177 changes: 177 additions & 0 deletions java/java-dropwizard/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>io.swagger</groupId>
<artifactId>swagger-samples-project</artifactId>
<version>1.0.0</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-dropwizard-sample-app</artifactId>
<packaging>jar</packaging>
<name>swagger-java-dropwizard-app</name>
<version>1.0.0</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.swagger.sample.SwaggerSampleApplication</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>swagger-ui</id>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://github.com/swagger-api/swagger-ui/archive/master.tar.gz</url>
<unpack>true</unpack>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/${project.artifactId}-${project.version}</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}/swagger-ui-master/dist</directory>
<filtering>true</filtering>
<excludes>
<exclude>index.html</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey-jaxrs</artifactId>
<version>${swagger-version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.7.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-guava</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.18.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.swagger.sample;

import io.swagger.jaxrs.config.*;
import io.swagger.jaxrs.listing.ApiListingResource;
import io.swagger.config.*;

import com.fasterxml.jackson.annotation.JsonInclude;

import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.swagger.sample.resource.PetResource;

public class SwaggerSampleApplication extends Application <SwaggerSampleConfiguration> {
public static void main(String[] args) throws Exception {
new SwaggerSampleApplication().run(args);
}

@Override
public void initialize(Bootstrap<SwaggerSampleConfiguration> bootstrap) { }

@Override
public String getName() {
return "swagger-sample";
}

@Override
public void run(SwaggerSampleConfiguration configuration, Environment environment) {
environment.jersey().register(new ApiListingResource());
environment.jersey().register(new PetResource());
environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);

BeanConfig config = new BeanConfig();
config.setTitle("Swagger sample app");
config.setVersion("1.0.0");
config.setResourcePackage("io.swagger.sample.resource");
config.setScan(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.swagger.sample;

import io.dropwizard.Configuration;

import com.fasterxml.jackson.annotation.JsonProperty;

import org.hibernate.validator.constraints.NotEmpty;

public class SwaggerSampleConfiguration extends Configuration {
@NotEmpty
@JsonProperty
private String defaultName = "swagger-sample";

public String getDefaultName() {
return defaultName;
}
}
Loading