Skip to content

Commit 609cef0

Browse files
committed
added android client
1 parent cfa1f1a commit 609cef0

File tree

23 files changed

+2180
-16
lines changed

23 files changed

+2180
-16
lines changed

bin/android-java-petstore.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
cd $APP_DIR
21+
22+
23+
# if you've executed sbt assembly previously it will use that instead.
24+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
25+
ags="$@ samples/client/petstore/android-java/AndroidJavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs special-key"
26+
27+
if [ -f $APP_DIR/target/scala-2.9.1/swagger-codegen.jar ]; then
28+
scala -cp target/scala-2.9.1/swagger-codegen.jar $ags
29+
elif [[ -f $APP_DIR/target/scala-2.10/swagger-codegen.jar ]]; then
30+
scala -cp target/scala-2.10/swagger-codegen.jar $ags
31+
else
32+
./sbt assembly
33+
scala -cp target/swagger-codegen.jar $ags
34+
fi
35+

build.sbt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ organization := "com.wordnik"
55

66
name := "swagger-codegen"
77

8-
version := "2.0.9-SNAPSHOT"
8+
version := "2.0.10-SNAPSHOT"
99

1010
scalaVersion := "2.9.1"
1111

@@ -55,13 +55,6 @@ publishTo <<= (version) { version: String =>
5555
Some("Sonatype Nexus Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
5656
}
5757

58-
publishTo <<= (version) { version: String =>
59-
val artifactory = "https://ci.aws.wordnik.com/artifactory/m2-"
60-
if (version.trim.endsWith("SNAPSHOT"))
61-
Some("snapshots" at artifactory + "snapshots")
62-
else
63-
Some("releases" at artifactory + "releases")
64-
}
6558

6659
//publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository")))
6760

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright 2013 Wordnik, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.wordnik.swagger.codegen.BasicJavaGenerator
18+
19+
object AndroidJavaPetstoreCodegen extends BasicJavaGenerator {
20+
def main(args: Array[String]) = generateClient(args)
21+
22+
// location of templates
23+
override def templateDir = "android-java"
24+
25+
// where to write generated code
26+
override def destinationDir = "samples/client/petstore/android-java/src/main/java"
27+
28+
// package for api invoker, error files
29+
override def invokerPackage = Some("com.wordnik.client")
30+
31+
// package for models
32+
override def modelPackage = Some("com.wordnik.petstore.model")
33+
34+
// package for api classes
35+
override def apiPackage = Some("com.wordnik.petstore.api")
36+
37+
additionalParams ++= Map(
38+
"artifactId" -> "swagger-petstore",
39+
"artifactVersion" -> "1.0.0",
40+
"groupId" -> "com.wordnik")
41+
42+
// supporting classes
43+
override def supportingFiles = List(
44+
("apiInvoker.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiInvoker.java"),
45+
("jsonUtil.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "JsonUtil.java"),
46+
("apiException.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiException.java"),
47+
("pom.mustache", "samples/client/petstore/android-java", "pom.xml")
48+
)
49+
}
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.wordnik</groupId>
5+
<artifactId>swagger-petstore</artifactId>
6+
<packaging>jar</packaging>
7+
<name>swagger-petstore</name>
8+
<version>1.0.0</version>
9+
<scm>
10+
<connection>scm:git:[email protected]:wordnik/swagger-mustache.git</connection>
11+
<developerConnection>scm:git:[email protected]:wordnik/swagger-codegen.git</developerConnection>
12+
<url>https://github.com/wordnik/swagger-codegen</url>
13+
</scm>
14+
<prerequisites>
15+
<maven>2.2.0</maven>
16+
</prerequisites>
17+
18+
<build>
19+
<plugins>
20+
<plugin>
21+
<groupId>org.apache.maven.plugins</groupId>
22+
<artifactId>maven-surefire-plugin</artifactId>
23+
<version>2.12</version>
24+
<configuration>
25+
<systemProperties>
26+
<property>
27+
<name>loggerPath</name>
28+
<value>conf/log4j.properties</value>
29+
</property>
30+
</systemProperties>
31+
<argLine>-Xms512m -Xmx1500m</argLine>
32+
<parallel>methods</parallel>
33+
<forkMode>pertest</forkMode>
34+
</configuration>
35+
</plugin>
36+
<plugin>
37+
<artifactId>maven-dependency-plugin</artifactId>
38+
<executions>
39+
<execution>
40+
<phase>package</phase>
41+
<goals>
42+
<goal>copy-dependencies</goal>
43+
</goals>
44+
<configuration>
45+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
46+
</configuration>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
51+
<!-- attach test jar -->
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-jar-plugin</artifactId>
55+
<version>2.2</version>
56+
<executions>
57+
<execution>
58+
<goals>
59+
<goal>jar</goal>
60+
<goal>test-jar</goal>
61+
</goals>
62+
</execution>
63+
</executions>
64+
<configuration>
65+
</configuration>
66+
</plugin>
67+
68+
<plugin>
69+
<groupId>org.codehaus.mojo</groupId>
70+
<artifactId>build-helper-maven-plugin</artifactId>
71+
<executions>
72+
<execution>
73+
<id>add_sources</id>
74+
<phase>generate-sources</phase>
75+
<goals>
76+
<goal>add-source</goal>
77+
</goals>
78+
<configuration>
79+
<sources>
80+
<source>src/main/java</source>
81+
</sources>
82+
</configuration>
83+
</execution>
84+
<execution>
85+
<id>add_test_sources</id>
86+
<phase>generate-test-sources</phase>
87+
<goals>
88+
<goal>add-test-source</goal>
89+
</goals>
90+
<configuration>
91+
<sources>
92+
<source>src/test/java</source>
93+
</sources>
94+
</configuration>
95+
</execution>
96+
</executions>
97+
</plugin>
98+
<plugin>
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-compiler-plugin</artifactId>
101+
<version>2.3.2</version>
102+
<configuration>
103+
<source>1.6</source>
104+
<target>1.6</target>
105+
</configuration>
106+
</plugin>
107+
<plugin>
108+
<groupId>net.alchim31.maven</groupId>
109+
<artifactId>scala-maven-plugin</artifactId>
110+
<version>${scala-maven-plugin-version}</version>
111+
<executions>
112+
<execution>
113+
<goals>
114+
<goal>compile</goal>
115+
<goal>testCompile</goal>
116+
</goals>
117+
</execution>
118+
</executions>
119+
<configuration>
120+
<configuration>
121+
<recompileMode>incremental</recompileMode>
122+
</configuration>
123+
<jvmArgs>
124+
<jvmArg>-Xmx384m</jvmArg>
125+
</jvmArgs>
126+
<args>
127+
<arg>-target:jvm-1.5</arg>
128+
<arg>-deprecation</arg>
129+
</args>
130+
<launchers>
131+
<launcher>
132+
<id>run-scalatest</id>
133+
<mainClass>org.scalatest.tools.Runner</mainClass>
134+
<args>
135+
<arg>-p</arg>
136+
<arg>${project.build.testOutputDirectory}</arg>
137+
</args>
138+
<jvmArgs>
139+
<jvmArg>-Xmx512m</jvmArg>
140+
</jvmArgs>
141+
</launcher>
142+
</launchers>
143+
</configuration>
144+
</plugin>
145+
</plugins>
146+
</build>
147+
<reporting>
148+
<plugins>
149+
<plugin>
150+
<groupId>net.alchim31.maven</groupId>
151+
<artifactId>scala-maven-plugin</artifactId>
152+
<version>${scala-maven-plugin-version}</version>
153+
</plugin>
154+
</plugins>
155+
</reporting>
156+
<dependencies>
157+
<dependency>
158+
<groupId>com.fasterxml.jackson.core</groupId>
159+
<artifactId>jackson-core</artifactId>
160+
<version>${jackson-version}</version>
161+
<scope>compile</scope>
162+
</dependency>
163+
<dependency>
164+
<groupId>com.fasterxml.jackson.core</groupId>
165+
<artifactId>jackson-annotations</artifactId>
166+
<version>${jackson-version}</version>
167+
<scope>compile</scope>
168+
</dependency>
169+
<dependency>
170+
<groupId>com.fasterxml.jackson.core</groupId>
171+
<artifactId>jackson-databind</artifactId>
172+
<version>${jackson-version}</version>
173+
<scope>compile</scope>
174+
</dependency>
175+
<dependency>
176+
<groupId>org.apache.httpcomponents</groupId>
177+
<artifactId>httpclient</artifactId>
178+
<version>${httpclient-version}</version>
179+
<scope>compile</scope>
180+
</dependency>
181+
182+
<!-- test dependencies -->
183+
<dependency>
184+
<groupId>org.scala-lang</groupId>
185+
<artifactId>scala-library</artifactId>
186+
<version>${scala-version}</version>
187+
<scope>test</scope>
188+
</dependency>
189+
<dependency>
190+
<groupId>org.scalatest</groupId>
191+
<artifactId>scalatest_2.9.1</artifactId>
192+
<version>${scala-test-version}</version>
193+
<scope>test</scope>
194+
</dependency>
195+
<dependency>
196+
<groupId>junit</groupId>
197+
<artifactId>junit</artifactId>
198+
<version>${junit-version}</version>
199+
<scope>test</scope>
200+
</dependency>
201+
</dependencies>
202+
203+
<properties>
204+
<jackson-version>2.1.4</jackson-version>
205+
<scala-version>2.9.1-1</scala-version>
206+
<junit-version>4.8.1</junit-version>
207+
<maven-plugin-version>1.0.0</maven-plugin-version>
208+
<junit-version>4.8.1</junit-version>
209+
<scala-test-version>1.6.1</scala-test-version>
210+
<httpclient-version>4.2.3</httpclient-version>
211+
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
212+
</properties>
213+
</project>
214+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.wordnik.client;
2+
3+
public class ApiException extends Exception {
4+
int code = 0;
5+
String message = null;
6+
7+
public ApiException() {}
8+
9+
public ApiException(int code, String message) {
10+
this.code = code;
11+
this.message = message;
12+
}
13+
14+
public int getCode() {
15+
return code;
16+
}
17+
18+
public void setCode(int code) {
19+
this.code = code;
20+
}
21+
22+
public String getMessage() {
23+
return message;
24+
}
25+
26+
public void setMessage(String message) {
27+
this.message = message;
28+
}
29+
}

0 commit comments

Comments
 (0)