Skip to content

Commit 37118ca

Browse files
committed
Merge branch 'develop_2.0' into develop_2.0_objc_jsonmodel
Conflicts: samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m
2 parents e6d7517 + 7383520 commit 37118ca

File tree

36 files changed

+533
-271
lines changed

36 files changed

+533
-271
lines changed

README.md

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,41 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
5252
-o samples/client/petstore/java
5353
```
5454

55-
With a number of options. You can get the options with the -h flag:
56-
```
57-
usage: Codegen
58-
-a,--auth addes authorization headers when fetching the
59-
swagger definitions remotely. Pass in a
60-
URL-encoded string of name:header with a comma
61-
separating multiple values
62-
-d,--debug-info prints additional info for debugging
63-
-h,--help shows this message
64-
-i,--input-spec <arg> location of the swagger spec, as URL or file
65-
-l,--lang <arg> client language to generate.
66-
Available languages include:
67-
[android, async-scala, java, jaxrs, nodejs,
68-
objc, scalatra, scala, dynamic-html, html,
69-
swagger, tizen, php, ruby, python]
70-
-o,--output <arg> where to write the generated files
71-
-t,--template-dir <arg> folder containing the template files
55+
With a number of options. You can get the options with the `help generate` command:
56+
57+
```
58+
NAME
59+
swagger generate - Generate code with chosen lang
60+
61+
SYNOPSIS
62+
swagger generate [(-a <authorization> | --auth <authorization>)]
63+
(-i <spec file> | --input-spec <spec file>)
64+
(-l <language> | --lang <language>)
65+
[(-o <output directory> | --output <output directory>)]
66+
[(-t <template directory> | --template-dir <template directory>)]
67+
[(-v | --verbose)]
68+
69+
OPTIONS
70+
-a <authorization>, --auth <authorization>
71+
adds authorization headers when fetching the swagger definitions
72+
remotely. Pass in a URL-encoded string of name:header with a comma
73+
separating multiple values
74+
75+
-i <spec file>, --input-spec <spec file>
76+
location of the swagger spec, as URL or file (required)
77+
78+
-l <language>, --lang <language>
79+
client language to generate (maybe class name in classpath,
80+
required)
81+
82+
-o <output directory>, --output <output directory>
83+
where to write the generated files (current dir by default)
84+
85+
-t <template directory>, --template-dir <template directory>
86+
folder containing the template files
87+
88+
-v, --verbose
89+
verbose mode
7290
```
7391

7492
You can then compile and run the client, as well as unit tests against it:
@@ -91,18 +109,17 @@ It's just as easy--just use the `-i` flag to point to either a server or file.
91109
### Modifying the client library format
92110
Don't like the default swagger client syntax? Want a different language supported? No problem! Swagger codegen processes mustache templates with the [jmustache](https://github.com/samskivert/jmustache) engine. You can modify our templates or make your own.
93111

94-
You can look at `modules/swagger-codegen/src/main/resources/${your-language}` for examples. To make your own templates, create your own files and use the `-t` flag to specify your tempalte folder. It actually is that easy.
112+
You can look at `modules/swagger-codegen/src/main/resources/${your-language}` for examples. To make your own templates, create your own files and use the `-t` flag to specify your template folder. It actually is that easy.
95113

96114
### Making your own codegen modules
97115
If you're starting a project with a new language and don't see what you need, swagger-codegen can help you create a project to generate your own libraries:
98116

99117
```
100-
java -cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
101-
com.wordnik.swagger.codegen.MetaGenerator \
118+
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-cli.jar meta \
102119
-o output/myLibrary -n myClientCodegen -p com.my.company.codegen
103120
```
104121

105-
This will write, in the folder `output/myLibrary`, all the files you need to get started, including a README.md. Once modified and compiled, you can load your library with the codegen and generate clients with your own, custom-rolled logic.
122+
This will write, in the folder `output/myLibrary`, all the files you need to get started, including a README.md. Once modified and compiled, you can load your library with the codegen and generate clients with your own, custom-rolled logic.
106123

107124
### Where is Javascript???
108125
See our [javascript library](http://github.com/swagger-api/swagger-js)--it's completely dynamic and doesn't require

bin/all-petstore.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ fi
2020
cd $APP_DIR
2121
./bin/android-java-petstore.sh
2222
./bin/dynamic-html.sh
23-
./bin/html.sh
23+
./bin/html-petstore.sh
2424
./bin/jaxrs-petstore-server.sh
25-
./bin/java-petstore-filemap.sh
2625
./bin/java-petstore.sh
2726
./bin/php-petstore.sh
2827
./bin/python-petstore.sh

bin/objc-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ fi
2626

2727
# if you've executed sbt assembly previously it will use that instead.
2828
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/objc -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc"
3030

3131
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags

modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/Readme.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/SwaggerCodegen.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
* User: lanwen
1111
* Date: 24.03.15
1212
* Time: 17:56
13+
*
14+
* Command line interface for swagger codegen
15+
* use `swagger-codegen-cli.jar help` for more info
16+
*
17+
* @since 2.1.3-M1
1318
*/
1419
public class SwaggerCodegen {
1520

modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Generate.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ public class Generate implements Runnable {
3131
public static final String TEMPLATE_DIR_PARAM = "templateDir";
3232

3333
@Option(name = {"-v", "--verbose"}, description = "verbose mode")
34-
public boolean verbose;
34+
private boolean verbose;
3535

3636
@Option(name = {"-l", "--lang"}, title = "language", required = true,
3737
description = "client language to generate (maybe class name in classpath, required)")
38-
public String lang;
38+
private String lang;
3939

4040
@Option(name = {"-o", "--output"}, title = "output directory",
4141
description = "where to write the generated files (current dir by default)")
42-
public String output = "";
42+
private String output = "";
4343

4444
@Option(name = {"-i", "--input-spec"}, title = "spec file", required = true,
4545
description = "location of the swagger spec, as URL or file (required)")
46-
public String spec;
46+
private String spec;
4747

4848
@Option(name = {"-t", "--template-dir"}, title = "template directory",
4949
description = "folder containing the template files")
50-
public String templateDir;
50+
private String templateDir;
5151

5252
@Option(name = {"-a", "--auth"}, title = "authorization",
5353
description = "adds authorization headers when fetching the swagger definitions remotely. " +
5454
"Pass in a URL-encoded string of name:header with a comma separating multiple values")
55-
public String auth;
55+
private String auth;
5656

5757
@Override
5858
public void run() {

modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Meta.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@
3333
"specify, and includes default templates to include.")
3434
public class Meta implements Runnable {
3535

36-
public static final Logger LOG = LoggerFactory.getLogger(Meta.class);
36+
private static final Logger LOG = LoggerFactory.getLogger(Meta.class);
3737

38-
public static final String TEMPLATE_DIR_CLASSPATH = "codegen";
39-
public static final String MUSTACHE_EXTENSION = ".mustache";
38+
private static final String TEMPLATE_DIR_CLASSPATH = "codegen";
39+
private static final String MUSTACHE_EXTENSION = ".mustache";
4040

4141
@Option(name = {"-o", "--output"}, title = "output directory",
4242
description = "where to write the generated files (current dir by default)")
43-
public String outputFolder = "";
43+
private String outputFolder = "";
4444

4545
@Option(name = {"-n", "--name"}, title = "name",
4646
description = "the human-readable name of the generator")
47-
public String name = "default";
47+
private String name = "default";
4848

4949
@Option(name = {"-p", "--package"}, title = "package",
5050
description = "the package to put the main class into (defaults to com.wordnik.swagger.codegen)")
51-
public String targetPackage = "com.wordnik.swagger.codegen";
51+
private String targetPackage = "com.wordnik.swagger.codegen";
5252

5353
@Override
5454
public void run() {

modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/Codegen.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
import java.io.File;
1313
import java.util.*;
1414

15+
/**
16+
* @deprecated use instead {@link com.wordnik.swagger.codegen.DefaultGenerator}
17+
* or cli interface from https://github.com/swagger-api/swagger-codegen/pull/547
18+
*/
19+
@Deprecated
1520
public class Codegen extends DefaultGenerator {
1621
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
1722
static String configString;

modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,21 @@ public static String camelize(String word, boolean lowercaseFirstLetter) {
10991099
m = p.matcher(word);
11001100
}
11011101

1102+
// case out dots
1103+
String[] parts = word.split("\\.");
1104+
StringBuilder f = new StringBuilder();
1105+
for(String z : parts) {
1106+
if(z.length() > 0)
1107+
f.append(Character.toUpperCase(z.charAt(0))).append(z.substring(1));
1108+
}
1109+
word = f.toString();
1110+
1111+
m = p.matcher(word);
1112+
while (m.find()) {
1113+
word = m.replaceFirst("" + Character.toUpperCase(m.group(1).charAt(0)) + m.group(1).substring(1)/*.toUpperCase()*/);
1114+
m = p.matcher(word);
1115+
}
1116+
11021117
// Uppercase the class name.
11031118
p = Pattern.compile("(\\.?)(\\w)([^\\.]*)$");
11041119
m = p.matcher(word);

modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/MetaGenerator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
import java.io.Reader;
1717
import java.util.*;
1818

19+
/**
20+
* @deprecated use instead {@link com.wordnik.swagger.codegen.DefaultGenerator}
21+
* or cli interface from https://github.com/swagger-api/swagger-codegen/pull/547
22+
*/
23+
@Deprecated
1924
public class MetaGenerator extends AbstractGenerator {
2025
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
2126
static String configString;

0 commit comments

Comments
 (0)