Skip to content

Commit ceadea1

Browse files
committed
Merge pull request #1813 from swagger-api/issue-1811
added Docker support
2 parents 1acf5d2 + 69e7990 commit ceadea1

File tree

8 files changed

+53
-46
lines changed

8 files changed

+53
-46
lines changed

.travis.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
sudo: false
1+
sudo: required
22
language: java
3-
script: mvn verify -Psamples
43
jdk:
54
- oraclejdk7
5+
services:
6+
- docker
7+
before_install:
8+
# required when sudo: required for the Ruby petstore tests
9+
- gem install bundler
10+
install:
11+
- docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD
12+
script:
13+
- mvn verify -Psamples
14+
- docker build -t $DOCKER_IMAGE_NAME ./modules/swagger-generator
15+
- if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$TRAVIS_TAG; fi && docker push $DOCKER_IMAGE_NAME
16+
env:
17+
- DOCKER_IMAGE_NAME=swaggerapi/swagger-generator

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,3 +585,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
585585
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
586586
See the License for the specific language governing permissions and
587587
limitations under the License.
588+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM java:7
2+
3+
WORKDIR /generator
4+
COPY target/lib/jetty-runner* /generator/jetty-runner.jar
5+
COPY target/*.war /generator/swagger-generator.war
6+
7+
ENV GENERATOR_HOST=https://generator.swaggerhub.com/api/swagger.json
8+
RUN apt-get update
9+
10+
EXPOSE 8080
11+
CMD ["java", "-jar", "/generator/jetty-runner.jar", "/generator/swagger-generator.war"]
12+

modules/swagger-generator/pom.xml

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
<resource>
1717
<directory>src/main/resources</directory>
1818
<filtering>true</filtering>
19-
<excludes>
20-
<exclude>logback.xml</exclude>
21-
</excludes>
2219
<includes>
2320
<include>**/version.prop</include>
21+
<include>logback.xml</include>
2422
</includes>
2523
</resource>
2624
</resources>
@@ -43,6 +41,17 @@
4341
<groupId>org.apache.maven.plugins</groupId>
4442
<artifactId>maven-war-plugin</artifactId>
4543
<version>2.1.1</version>
44+
<configuration>
45+
<webResources>
46+
<resource>
47+
<!-- this is relative to the pom.xml directory -->
48+
<directory>${project.build.directory}/swagger-ui-master/dist</directory>
49+
<excludes>
50+
<exclude>index.html</exclude>
51+
</excludes>
52+
</resource>
53+
</webResources>
54+
</configuration>
4655
</plugin>
4756
<plugin>
4857
<artifactId>maven-failsafe-plugin</artifactId>
@@ -68,7 +77,7 @@
6877
<stopPort>8079</stopPort>
6978
<stopKey>stopit</stopKey>
7079
<httpConnector>
71-
<port>8001</port>
80+
<port>8080</port>
7281
<idleTimeout>60000</idleTimeout>
7382
</httpConnector>
7483
</configuration>
@@ -111,31 +120,6 @@
111120
</execution>
112121
</executions>
113122
</plugin>
114-
<plugin>
115-
<artifactId>maven-resources-plugin</artifactId>
116-
<version>2.6</version>
117-
<executions>
118-
<execution>
119-
<id>copy-resources</id>
120-
<phase>validate</phase>
121-
<goals>
122-
<goal>copy-resources</goal>
123-
</goals>
124-
<configuration>
125-
<outputDirectory>target/${project.artifactId}-${project.version}</outputDirectory>
126-
<resources>
127-
<resource>
128-
<directory>${project.build.directory}/swagger-ui-master/dist</directory>
129-
<filtering>true</filtering>
130-
<excludes>
131-
<exclude>index.html</exclude>
132-
</excludes>
133-
</resource>
134-
</resources>
135-
</configuration>
136-
</execution>
137-
</executions>
138-
</plugin>
139123
</plugins>
140124
</build>
141125
<dependencies>
@@ -212,7 +196,17 @@
212196
<artifactId>jetty-deploy</artifactId>
213197
<version>${jetty-version}</version>
214198
</dependency>
215-
199+
<dependency>
200+
<groupId>org.eclipse.jetty</groupId>
201+
<artifactId>jetty-runner</artifactId>
202+
<version>${jetty-version}</version>
203+
<exclusions>
204+
<exclusion>
205+
<groupId>org.glassfish</groupId>
206+
<artifactId>javax.el</artifactId>
207+
</exclusion>
208+
</exclusions>
209+
</dependency>
216210
<dependency>
217211
<groupId>org.testng</groupId>
218212
<artifactId>testng</artifactId>

modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,6 @@ public void init(ServletConfig config) throws ServletException {
5252
}
5353
}
5454

55-
String host = config.getInitParameter("generator.host");
56-
if(host == null) {
57-
host = "generator.swagger.io";
58-
}
59-
bc.setHost(host);
60-
61-
String scheme = config.getInitParameter("generator.protocol");
62-
if(host == null) {
63-
scheme = "https";
64-
}
65-
bc.setSchemes(new String[]{scheme});
6655
bc.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
6756
bc.setResourcePackage("io.swagger.generator.resource");
6857
bc.setScan(true);

modules/swagger-generator/src/main/resources/logback.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
66
</layout>
77
</appender>
8-
<logger name="io.swagger.jaxrs" level="debug"/>
98
<root level="error">
109
<appender-ref ref="STDOUT"/>
1110
</root>

modules/swagger-generator/src/main/webapp/WEB-INF/web.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<servlet-class>io.swagger.generator.Bootstrap</servlet-class>
4444
<init-param>
4545
<param-name>generator.host</param-name>
46-
<param-value>localhost:8001</param-value>
46+
<param-value>localhost:8080</param-value>
4747
</init-param>
4848
<init-param>
4949
<param-name>generator.protocol</param-name>

modules/swagger-generator/src/main/webapp/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
if (url && url.length > 1) {
2828
url = decodeURIComponent(url[1]);
2929
} else {
30-
url = "https://generator.swagger.io/api/swagger.json";
30+
url = window.location.protocol + '//' + window.location.host + '/api/swagger.json';
3131
}
3232
window.swaggerUi = new SwaggerUi({
3333
url: url,

0 commit comments

Comments
 (0)