Skip to content

Commit 618b469

Browse files
committed
Merge branch 'develop_2.0'
Conflicts: README.md bin/Version.scala build.sbt modules/swagger-codegen/src/main/resources/Java/api.mustache modules/swagger-codegen/src/main/resources/android-java/api.mustache modules/swagger-codegen/src/main/resources/nodejs/api.mustache modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m modules/swagger-codegen/src/main/resources/objc/SWGDate.h modules/swagger-codegen/src/main/resources/objc/SWGDate.m modules/swagger-codegen/src/main/resources/objc/SWGFile.m modules/swagger-codegen/src/main/resources/objc/SWGObject.h modules/swagger-codegen/src/main/resources/objc/SWGObject.m modules/swagger-codegen/src/main/resources/objc/api-header.mustache modules/swagger-codegen/src/main/resources/php/api.mustache modules/swagger-codegen/src/main/resources/python/api.mustache modules/swagger-codegen/src/main/resources/scala/apiInvoker.mustache modules/swagger-codegen/src/main/resources/scala/pom.mustache project/build.properties samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java samples/client/petstore/scala/pom.xml samples/client/petstore/scala/src/test/scala/PetApiTest.scala samples/client/petstore/scala/src/test/scala/StoreApiTest.scala samples/client/petstore/scala/src/test/scala/UserApiTest.scala samples/client/wordnik-api�objc/client/SWGAccountApi.h samples/client/wordnik-api�objc/client/SWGAccountApi.m samples/client/wordnik-api�objc/client/SWGApiClient.h samples/client/wordnik-api�objc/client/SWGApiClient.m samples/client/wordnik-api�objc/client/SWGApiTokenStatus.h samples/client/wordnik-api�objc/client/SWGAudioFile.h samples/client/wordnik-api�objc/client/SWGAuthenticationToken.h samples/client/wordnik-api�objc/client/SWGBigram.h samples/client/wordnik-api�objc/client/SWGCitation.h samples/client/wordnik-api�objc/client/SWGCitation.m samples/client/wordnik-api�objc/client/SWGContentProvider.h samples/client/wordnik-api�objc/client/SWGContentProvider.m samples/client/wordnik-api�objc/client/SWGDate.h samples/client/wordnik-api�objc/client/SWGDate.m samples/client/wordnik-api�objc/client/SWGDefinition.h samples/client/wordnik-api�objc/client/SWGDefinition.m samples/client/wordnik-api�objc/client/SWGDefinitionSearchResults.h samples/client/wordnik-api�objc/client/SWGDefinitionSearchResults.m samples/client/wordnik-api�objc/client/SWGExample.h samples/client/wordnik-api�objc/client/SWGExample.m samples/client/wordnik-api�objc/client/SWGExampleSearchResults.h samples/client/wordnik-api�objc/client/SWGExampleSearchResults.m samples/client/wordnik-api�objc/client/SWGExampleUsage.h samples/client/wordnik-api�objc/client/SWGExampleUsage.m samples/client/wordnik-api�objc/client/SWGFacet.h samples/client/wordnik-api�objc/client/SWGFacet.m samples/client/wordnik-api�objc/client/SWGFacetValue.h samples/client/wordnik-api�objc/client/SWGFacetValue.m samples/client/wordnik-api�objc/client/SWGFile.h samples/client/wordnik-api�objc/client/SWGFile.m samples/client/wordnik-api�objc/client/SWGFrequency.h samples/client/wordnik-api�objc/client/SWGFrequency.m samples/client/wordnik-api�objc/client/SWGFrequencySummary.h samples/client/wordnik-api�objc/client/SWGFrequencySummary.m samples/client/wordnik-api�objc/client/SWGLabel.h samples/client/wordnik-api�objc/client/SWGLabel.m samples/client/wordnik-api�objc/client/SWGNote.h samples/client/wordnik-api�objc/client/SWGObject.h samples/client/wordnik-api�objc/client/SWGObject.m samples/client/wordnik-api�objc/client/SWGRelated.h samples/client/wordnik-api�objc/client/SWGScoredWord.h samples/client/wordnik-api�objc/client/SWGSentence.h samples/client/wordnik-api�objc/client/SWGSentence.m samples/client/wordnik-api�objc/client/SWGSimpleDefinition.h samples/client/wordnik-api�objc/client/SWGSimpleExample.h samples/client/wordnik-api�objc/client/SWGStringValue.h samples/client/wordnik-api�objc/client/SWGStringValue.m samples/client/wordnik-api�objc/client/SWGSyllable.h samples/client/wordnik-api�objc/client/SWGTextPron.h samples/client/wordnik-api�objc/client/SWGUser.h samples/client/wordnik-api�objc/client/SWGWordApi.h samples/client/wordnik-api�objc/client/SWGWordList.h samples/client/wordnik-api�objc/client/SWGWordList.m samples/client/wordnik-api�objc/client/SWGWordListApi.h samples/client/wordnik-api�objc/client/SWGWordListApi.m samples/client/wordnik-api�objc/client/SWGWordListWord.h samples/client/wordnik-api�objc/client/SWGWordListsApi.h samples/client/wordnik-api�objc/client/SWGWordListsApi.m samples/client/wordnik-api�objc/client/SWGWordObject.h samples/client/wordnik-api�objc/client/SWGWordOfTheDay.h samples/client/wordnik-api�objc/client/SWGWordOfTheDay.m samples/client/wordnik-api�objc/client/SWGWordSearchResult.h samples/client/wordnik-api�objc/client/SWGWordSearchResults.h samples/client/wordnik-api�objc/client/SWGWordSearchResults.m samples/client/wordnik-api�objc/client/SWGWordsApi.h samples/client/wordnik-api�objc/client/SWGWordsApi.m samples/client/wordnik-api-objc/Podfile samples/client/wordnik-api-objc/client/SWGAccountApi.h samples/client/wordnik-api-objc/client/SWGAccountApi.m samples/client/wordnik-api-objc/client/SWGApiClient.h samples/client/wordnik-api-objc/client/SWGApiClient.m samples/client/wordnik-api-objc/client/SWGApiTokenStatus.h samples/client/wordnik-api-objc/client/SWGApiTokenStatus.m samples/client/wordnik-api-objc/client/SWGAudioFile.h samples/client/wordnik-api-objc/client/SWGAudioFile.m samples/client/wordnik-api-objc/client/SWGAuthenticationToken.h samples/client/wordnik-api-objc/client/SWGAuthenticationToken.m samples/client/wordnik-api-objc/client/SWGBigram.h samples/client/wordnik-api-objc/client/SWGBigram.m samples/client/wordnik-api-objc/client/SWGCitation.h samples/client/wordnik-api-objc/client/SWGCitation.m samples/client/wordnik-api-objc/client/SWGContentProvider.h samples/client/wordnik-api-objc/client/SWGContentProvider.m samples/client/wordnik-api-objc/client/SWGDate.h samples/client/wordnik-api-objc/client/SWGDate.m samples/client/wordnik-api-objc/client/SWGDefinition.h samples/client/wordnik-api-objc/client/SWGDefinition.m samples/client/wordnik-api-objc/client/SWGDefinitionSearchResults.h samples/client/wordnik-api-objc/client/SWGDefinitionSearchResults.m samples/client/wordnik-api-objc/client/SWGExample.h samples/client/wordnik-api-objc/client/SWGExample.m samples/client/wordnik-api-objc/client/SWGExampleSearchResults.h samples/client/wordnik-api-objc/client/SWGExampleSearchResults.m samples/client/wordnik-api-objc/client/SWGExampleUsage.h samples/client/wordnik-api-objc/client/SWGExampleUsage.m samples/client/wordnik-api-objc/client/SWGFacet.h samples/client/wordnik-api-objc/client/SWGFacet.m samples/client/wordnik-api-objc/client/SWGFacetValue.h samples/client/wordnik-api-objc/client/SWGFacetValue.m samples/client/wordnik-api-objc/client/SWGFile.h samples/client/wordnik-api-objc/client/SWGFile.m samples/client/wordnik-api-objc/client/SWGFrequency.h samples/client/wordnik-api-objc/client/SWGFrequency.m samples/client/wordnik-api-objc/client/SWGFrequencySummary.h samples/client/wordnik-api-objc/client/SWGFrequencySummary.m samples/client/wordnik-api-objc/client/SWGLabel.h samples/client/wordnik-api-objc/client/SWGLabel.m samples/client/wordnik-api-objc/client/SWGNote.h samples/client/wordnik-api-objc/client/SWGNote.m samples/client/wordnik-api-objc/client/SWGObject.h samples/client/wordnik-api-objc/client/SWGObject.m samples/client/wordnik-api-objc/client/SWGRelated.h samples/client/wordnik-api-objc/client/SWGRelated.m samples/client/wordnik-api-objc/client/SWGScoredWord.h samples/client/wordnik-api-objc/client/SWGScoredWord.m samples/client/wordnik-api-objc/client/SWGScrabbleScoreResult.h samples/client/wordnik-api-objc/client/SWGScrabbleScoreResult.m samples/client/wordnik-api-objc/client/SWGSentence.h samples/client/wordnik-api-objc/client/SWGSentence.m samples/client/wordnik-api-objc/client/SWGSimpleDefinition.h samples/client/wordnik-api-objc/client/SWGSimpleDefinition.m samples/client/wordnik-api-objc/client/SWGSimpleExample.h samples/client/wordnik-api-objc/client/SWGSimpleExample.m samples/client/wordnik-api-objc/client/SWGStringValue.h samples/client/wordnik-api-objc/client/SWGStringValue.m samples/client/wordnik-api-objc/client/SWGSyllable.h samples/client/wordnik-api-objc/client/SWGSyllable.m samples/client/wordnik-api-objc/client/SWGTextPron.h samples/client/wordnik-api-objc/client/SWGTextPron.m samples/client/wordnik-api-objc/client/SWGUser.h samples/client/wordnik-api-objc/client/SWGUser.m samples/client/wordnik-api-objc/client/SWGWordApi.h samples/client/wordnik-api-objc/client/SWGWordApi.m samples/client/wordnik-api-objc/client/SWGWordList.h samples/client/wordnik-api-objc/client/SWGWordList.m samples/client/wordnik-api-objc/client/SWGWordListApi.h samples/client/wordnik-api-objc/client/SWGWordListApi.m samples/client/wordnik-api-objc/client/SWGWordListWord.h samples/client/wordnik-api-objc/client/SWGWordListWord.m samples/client/wordnik-api-objc/client/SWGWordListsApi.h samples/client/wordnik-api-objc/client/SWGWordListsApi.m samples/client/wordnik-api-objc/client/SWGWordObject.h samples/client/wordnik-api-objc/client/SWGWordObject.m samples/client/wordnik-api-objc/client/SWGWordOfTheDay.h samples/client/wordnik-api-objc/client/SWGWordOfTheDay.m samples/client/wordnik-api-objc/client/SWGWordSearchResult.h samples/client/wordnik-api-objc/client/SWGWordSearchResult.m samples/client/wordnik-api-objc/client/SWGWordSearchResults.h samples/client/wordnik-api-objc/client/SWGWordSearchResults.m samples/client/wordnik-api-objc/client/SWGWordsApi.h samples/client/wordnik-api-objc/client/SWGWordsApi.m samples/client/wordnik-api-php/wordnik/AccountApi.php samples/client/wordnik-api/scala/src/test/scala/AccountApiTest.scala samples/client/wordnik-api/scala/src/test/scala/WordApiTest.scala samples/client/wordnik-api/scala/src/test/scala/WordListApiTest.scala samples/client/wordnik-api/scala/src/test/scala/WordsApiTest.scala samples/client/wordnik/objc/client/SWGAccountApi.h samples/client/wordnik/objc/client/SWGAccountApi.m samples/client/wordnik/objc/client/SWGApiTokenStatus.h samples/client/wordnik/objc/client/SWGAudioFile.h samples/client/wordnik/objc/client/SWGAuthenticationToken.h samples/client/wordnik/objc/client/SWGBigram.h samples/client/wordnik/objc/client/SWGCitation.h samples/client/wordnik/objc/client/SWGCitation.m samples/client/wordnik/objc/client/SWGContentProvider.h samples/client/wordnik/objc/client/SWGContentProvider.m samples/client/wordnik/objc/client/SWGDefinition.h samples/client/wordnik/objc/client/SWGDefinition.m samples/client/wordnik/objc/client/SWGDefinitionSearchResults.h samples/client/wordnik/objc/client/SWGDefinitionSearchResults.m samples/client/wordnik/objc/client/SWGExample.h samples/client/wordnik/objc/client/SWGExample.m samples/client/wordnik/objc/client/SWGExampleSearchResults.h samples/client/wordnik/objc/client/SWGExampleSearchResults.m samples/client/wordnik/objc/client/SWGExampleUsage.h samples/client/wordnik/objc/client/SWGExampleUsage.m samples/client/wordnik/objc/client/SWGFacet.h samples/client/wordnik/objc/client/SWGFacet.m samples/client/wordnik/objc/client/SWGFacetValue.h samples/client/wordnik/objc/client/SWGFacetValue.m samples/client/wordnik/objc/client/SWGFile.h samples/client/wordnik/objc/client/SWGFrequency.h samples/client/wordnik/objc/client/SWGFrequency.m samples/client/wordnik/objc/client/SWGFrequencySummary.h samples/client/wordnik/objc/client/SWGFrequencySummary.m samples/client/wordnik/objc/client/SWGLabel.h samples/client/wordnik/objc/client/SWGLabel.m samples/client/wordnik/objc/client/SWGNote.h samples/client/wordnik/objc/client/SWGRelated.h samples/client/wordnik/objc/client/SWGScoredWord.h samples/client/wordnik/objc/client/SWGSentence.h samples/client/wordnik/objc/client/SWGSentence.m samples/client/wordnik/objc/client/SWGSimpleDefinition.h samples/client/wordnik/objc/client/SWGSimpleExample.h samples/client/wordnik/objc/client/SWGStringValue.h samples/client/wordnik/objc/client/SWGStringValue.m samples/client/wordnik/objc/client/SWGSyllable.h samples/client/wordnik/objc/client/SWGTextPron.h samples/client/wordnik/objc/client/SWGUser.h samples/client/wordnik/objc/client/SWGWordApi.h samples/client/wordnik/objc/client/SWGWordList.h samples/client/wordnik/objc/client/SWGWordList.m samples/client/wordnik/objc/client/SWGWordListApi.h samples/client/wordnik/objc/client/SWGWordListApi.m samples/client/wordnik/objc/client/SWGWordListWord.h samples/client/wordnik/objc/client/SWGWordListsApi.h samples/client/wordnik/objc/client/SWGWordListsApi.m samples/client/wordnik/objc/client/SWGWordObject.h samples/client/wordnik/objc/client/SWGWordOfTheDay.h samples/client/wordnik/objc/client/SWGWordOfTheDay.m samples/client/wordnik/objc/client/SWGWordSearchResult.h samples/client/wordnik/objc/client/SWGWordSearchResults.h samples/client/wordnik/objc/client/SWGWordSearchResults.m samples/client/wordnik/objc/client/SWGWordsApi.h samples/client/wordnik/objc/client/SWGWordsApi.m samples/server-generator/node/README.md samples/server/petstore/jaxrs/src/main/java/io/swagger/model/Pet.java samples/server/petstore/nodejs/app/apis/PetApi.js samples/server/petstore/nodejs/app/apis/StoreApi.js samples/server/petstore/nodejs/app/apis/UserApi.js sbt src/main/resources/objc/api-body.mustache src/main/resources/php/Swagger.mustache src/main/resources/python/swagger.mustache src/main/scala/com/wordnik/swagger/codegen/BasicAndroidJavaClient.scala src/main/scala/com/wordnik/swagger/codegen/BasicGenerator.scala src/main/scala/com/wordnik/swagger/codegen/BasicPythonGenerator.scala src/main/scala/com/wordnik/swagger/codegen/BasicScalaGenerator.scala src/main/scala/com/wordnik/swagger/codegen/Codegen.scala src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala src/main/scala/com/wordnik/swagger/codegen/model/AuthorizationModels.scala src/main/scala/com/wordnik/swagger/codegen/spec/SwaggerSpecValidator.scala src/main/scala/com/wordnik/swagger/codegen/util/RemoteUrl.scala src/test/scala/CodegenTest.scala
2 parents ece072a + 72feda8 commit 618b469

File tree

1,203 files changed

+55701
-57814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,203 files changed

+55701
-57814
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ target
2828
.lib
2929
atlassian-ide-plugin.xml
3030
.DS_Store
31-
*~

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
language: scala
2-
scala:
3-
- 2.10.0
1+
language: java
2+
script: mvn verify
3+
jdk:
4+
- oraclejdk7

LICENSE

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

README.md

Lines changed: 122 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.png)](https://travis-ci.org/swagger-api/swagger-codegen)
44

55
## Overview
6-
This is the swagger codegen project, which allows generation of client libraries automatically from a
7-
Swagger-compliant server.
6+
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
87

98
## What's Swagger?
109

@@ -14,128 +13,85 @@ The goal of Swagger™ is to define a standard, language-agnostic interface to R
1413
Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
1514

1615

17-
## Compatibility
18-
The Swagger Specification has undergone 3 revisions since initial creation in 2010. Compatibility between swagger-codegen and the Swagger specification is as follows:
16+
## Compatability
17+
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification:
1918

20-
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
19+
Swagger Codegen Version | Release Date | Swagger Spec compatability | Notes
2120
----------------------- | ------------ | -------------------------- | -----
22-
2.1.0 (in development) | n/a | 1.0, 1.1, 1.2, 2.0 | [branch develop_2.0](https://github.com/swagger-api/swagger-codegen/tree/develop_2.0)
23-
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/2.0.17)
21+
2.1.0-M1 | 2015-02-16 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.0-M1](https://github.com/swagger-api/swagger-codegen/tree/v2.1.0-M1)
22+
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)
2423
1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1)
2524

2625

2726
### Prerequisites
2827
You need the following installed and available in your $PATH:
2928

30-
* [Java 1.7](http://java.oracle.com)
31-
32-
Note! Some folks have had issues with OOM errors with java version "1.6.0_51". It's strongly suggested that you upgrade to 1.7!
29+
* [Java 7](http://java.oracle.com)
3330

3431
* [Apache maven 3.0.3 or greater](http://maven.apache.org/)
3532

36-
* [Scala 2.10.4](http://www.scala-lang.org)
37-
38-
* [sbt (only download if you're building on Windows)](http://www.scala-sbt.org/)
39-
40-
You also need to add the scala binary to your PATH.
41-
42-
After cloning the project, you need to build it from source with this command:
33+
After cloning the project, you can build it from source with this command:
4334

4435
```
45-
./sbt assembly
36+
mvn package
4637
```
4738

48-
or for Windows...
39+
### To generate a sample client library
40+
You can build a client against Wordnik's [petstore](http://petstore.swagger.io) API as follows:
4941

5042
```
51-
sbt assembly
43+
./bin/java-petstore.sh
5244
```
5345

46+
This will run the generator with this command:
5447

55-
### To generate a sample client library
56-
You can build a client against Wordnik's [petstore](http://petstore.swagger.wordnik.com) API as follows:
57-
5848
```
59-
./bin/scala-petstore.sh
49+
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.0-M1.jar \
50+
-i http://petstore.swagger.io/v2/swagger.json \
51+
-l java \
52+
-o samples/client/petstore/java
53+
```
54+
55+
With a number of options. You can get the options with the -h flag:
6056
```
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, java, jaxrs, nodejs, objc, scalatra,
68+
scala, dynamic-html, html, swagger, tizen, php,
69+
python]
70+
-o,--output <arg> where to write the generated files
71+
-t,--template-dir <arg> folder containing the template files
72+
```
6173

62-
This will run the script in [samples/client/petstore/ScalaPetstoreCodegen.scala](https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) and create the client. You can then
63-
compile and run the client, as well as unit tests against it:
74+
You can then compile and run the client, as well as unit tests against it:
6475

6576
```
66-
cd samples/client/petstore/scala
77+
cd samples/client/petstore/java
6778
mvn package
6879
```
6980

7081
Other languages have petstore samples, too:
7182
```
72-
./bin/flash-petstore.sh
83+
./bin/android-petstore.sh
7384
./bin/java-petstore.sh
7485
./bin/objc-petstore.sh
75-
./bin/php-petstore.sh
76-
./bin/python-petstore.sh
77-
./bin/python3-petstore.sh
78-
./bin/ruby-petstore.sh
7986
```
8087

8188
### Generating libraries from your server
82-
It's just as easy--you can either run the default generators:
83-
84-
```
85-
./bin/runscala.sh com.wordnik.swagger.codegen.BasicScalaGenerator http://petstore.swagger.wordnik.com/api/api-docs special-key
86-
```
87-
88-
Replace `Scala` with `Flash`, `Java`, `Objc`, `PHP`, `Python`, `Python3`, `Ruby`.
89-
90-
You will probably want to override some of the defaults--like packages, etc. For doing this, just create a scala
91-
script with the overrides you want. Follow [ScalaPetstoreCodegen](https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) as an example:
92-
93-
For example, create `src/main/scala/MyCodegen.scala` with these contents:
94-
95-
```scala
96-
import com.wordnik.swagger.codegen.BasicScalaGenerator
97-
98-
object MyCodegen extends BasicScalaGenerator {
99-
def main(args: Array[String]) = generateClient(args)
100-
101-
// location of templates
102-
override def templateDir = "scala"
103-
104-
// where to write generated code
105-
override def destinationDir = "client/scala/src/main/scala"
106-
107-
// api invoker package
108-
override def invokerPackage = "com.myapi.client"
109-
110-
// package for models
111-
override def modelPackage = Some("com.myapi.client.model")
112-
113-
// package for api classes
114-
override def apiPackage = Some("com.myapi.client.api")
115-
116-
// supporting classes
117-
override def supportingFiles = List(
118-
("apiInvoker.mustache", destinationDir + java.io.File.separator + packageName.replaceAll("\\.", java.io.File.separator), "ApiInvoker.scala"),
119-
("pom.mustache", destinationDir, "pom.xml")
120-
)
121-
}
122-
```
123-
124-
Now you can generate your client like this:
125-
126-
```
127-
./bin/runscala.sh src/main/scala/MyCodegen.scala http://my.api.com/resources.json super-secret-key
128-
```
129-
130-
w00t! Thanks to the scala interpretor, you didn't even need to recompile.
89+
It's just as easy--just use the `-i` flag to point to either a server or file.
13190

13291
### Modifying the client library format
133-
Don't like the default swagger client syntax? Want a different language supported? No problem! Swagger codegen
134-
processes mustache templates with the [scalate](http://scalate.fusesource.org/) engine. You can modify our templates or
135-
make your own.
92+
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.
13693

137-
You can look at `src/main/resources/${your-language}` for examples. To make your own templates, create your own files
138-
and override the `templateDir` in your script to point to the right place. It actually is that easy.
94+
You can look at `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.
13995

14096
### Where is Javascript???
14197
See our [javascript library](http://github.com/swagger-api/swagger-js)--it's completely dynamic and doesn't require
@@ -148,102 +104,132 @@ If you don't want to call your server, you can save the swagger spec files into
148104
to the code generator like this:
149105

150106
```
151-
-DfileMap=/path/to/resource-listing
152-
```
153-
154-
Or for example:
155-
```
156-
./bin/java-petstore-filemap.sh
107+
-i ./modules/swagger-codegen/src/test/resources/2_0/petstore.json
157108
```
158109

159-
Which simple passes `-DfileMap=src/test/resources/petstore` as an argument. Great for creating libraries on your
160-
ci server... or while coding on an airplane.
110+
Great for creating libraries on your ci server, from the [Swagger Editor](http://editor.swagger.io)... or while coding on an airplane.
161111

162-
### Validating your swagger spec
163-
You can use the validation tool to see that your server is creating a proper spec file. If you want to learn
164-
more about the spec file and format, please see [swagger-spec](https://github.com/swagger-api/swagger-spec). This
165-
tool will read the server and generate a report of any violations of the spec. If there are violations, the
166-
client codegen and ui may not work correctly.
112+
### Customizing the generator
167113

168-
To validate an api and write output to ./swagger-errors.html:
114+
There are different aspects of customizing the code generator beyond just creating or modifying templates. Each language has a supporting configuration file to handle different type mappings, etc:
169115

170116
```
171-
./bin/validate.sh http://petstore.swagger.wordnik.com/api/api-docs "specia-key" ./swagger-errors.html
117+
$ ls -1 modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/
118+
AndroidClientCodegen.java
119+
JavaClientCodegen.java
120+
JaxRSServerCodegen.java
121+
NodeJSServerCodegen.java
122+
ObjcClientCodegen.java
123+
PhpClientCodegen.java
124+
PythonClientCodegen.java
125+
ScalaClientCodegen.java
126+
ScalatraServerCodegen.java
127+
StaticDocCodegen.java
128+
StaticHtmlGenerator.java
129+
SwaggerGenerator.java
130+
TizenClientCodegen.java
172131
```
173132

174-
### Generating static api documentation
175-
If you need to make static pages or don't want the sandbox of the swagger-ui, you can use the codegen to build them. Remember, the engine is just using mustache templates--the output format is your call.
133+
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc., you may want to extend these.
134+
135+
To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:
176136

177137
```
178-
./bin/static-docs.sh
138+
package com.mycompany.swagger.codegen;
139+
140+
import com.wordnik.swagger.codegen.languages.*;
141+
142+
public class MyObjcCodegen extends ObjcClientCodegen {
143+
static {
144+
PREFIX = "HELO";
145+
}
146+
}
179147
```
180148

181-
Will produce the output here:
149+
and specify the `classname` when running the generator:
182150

183151
```
184-
https://github.com/swagger-api/swagger-codegen/tree/master/samples/swagger-static-docs/docs
152+
-i com.mycompany.swagger.codegen.MyObjcCodegen
185153
```
186154

187-
which is based on these templates:
155+
Your subclass will now be loaded and overrides the `PREFIX` value in the superclass.
156+
157+
### Validating your swagger spec
158+
159+
You have options. The easiest is to use our [online validator](https://github.com/swagger-api/validator-badge) which not only will let you validate your spec, but with the debug flag, you can see what's wrong with your spec. For example:
160+
161+
http://online.swagger.io/validator/debug?url=http://petstore.swagger.io/v2/swagger.json
162+
163+
### Generating dynamic html api documentation
164+
165+
To do so, just use the `-l dynamic-html` flag when reading a spec file. This creates HTML documentation that is available as a single-page application with AJAX. To view the documentation:
188166

189167
```
190-
https://github.com/swagger-api/swagger-codegen/tree/master/src/main/resources/swagger-static
168+
cd samples/dynamic-html/
169+
npm install
170+
node .
191171
```
192172

193-
and looks like this
173+
Which launches a node.js server so the AJAX calls have a place to go.
194174

195-
![Image](https://raw.github.com/swagger-api/swagger-codegen/master/samples/docs/swagger-static-docs/static-docs.png)
196175

197-
### To build a server stub
176+
### Generating static html api documentation
198177

199-
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:
178+
To do so, just use the `-l html` flag when reading a spec file. This creates a single, simple HTML file with embedded css so you can ship it as an email attachment, or load it from your filesystem:
200179

201-
* [javascript node.js Server generator](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/node)
180+
```
181+
cd samples/html/
182+
open index.html
183+
```
202184

203-
* [ruby sinatra generator](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/sinatra)
204185

205-
* [scala scalatra generator](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/scalatra)
186+
### To build a server stub
206187

207-
* [java jax-rs generator](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/java-jaxrs)
188+
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:
208189

190+
### node.js
191+
```
192+
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.0-M1.jar \
193+
-i http://petstore.swagger.io/v2/swagger.json \
194+
-l nodejs \
195+
-o samples/server/petstore/nodejs
196+
```
209197

210-
### Migrating from Swagger 1.1 to 1.2 format
198+
### rails-grape
199+
#### Not yet migrated to this branch
211200

212-
If you've spent time hand-crafting your swagger spec files, you can use the [SpecConverter](https://github.com/swagger-api/swagger-codegen/blob/master/src/main/scala/com/wordnik/swagger/codegen/SpecConverter.scala) to do the dirty work. For example:
213201

214-
```bash
215-
$ ./bin/update-spec.sh http://developer.wordnik.com/v4/resources.json wordnik-developer
216-
writing file wordnik-developer/api-docs
217-
calling: http://developer.wordnik.com/v4/account.json
218-
calling: http://developer.wordnik.com/v4/word.json
219-
calling: http://developer.wordnik.com/v4/words.json
220-
calling: http://developer.wordnik.com/v4/wordList.json
221-
calling: http://developer.wordnik.com/v4/wordLists.json
222-
writing file wordnik-developer/account
223-
writing file wordnik-developer/word
224-
writing file wordnik-developer/words
225-
writing file wordnik-developer/wordList
226-
writing file wordnik-developer/wordLists
202+
### scala scalatra
203+
```
204+
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.0-M1.jar \
205+
-i http://petstore.swagger.io/v2/swagger.json \
206+
-l scalatra \
207+
-o samples/server/petstore/scalatra
227208
```
228209

229-
Will read the 1.1 spec from wordnik developer and write it into the folder called `wordnik-developer`.
210+
### java jax-rs
230211

212+
```
213+
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.0-M1.jar \
214+
-i http://petstore.swagger.io/v2/swagger.json \
215+
-l jaxrs \
216+
-o samples/server/petstore/jaxrs
217+
```
231218

232219
### To build the codegen library
233220

234221
This will create the swagger-codegen library from source.
235222

236223
```
237-
./sbt assembly
224+
mvn package
238225
```
239226

240-
Note! The templates are included in the library generated. If you want to modify the templates, you'll need to
241-
either repackage the library OR modify your codegen script to use a file path!
227+
Note! The templates are included in the library generated. If you want to modify the templates, you'll need to either repackage the library OR specify a path to your scripts
242228

243229
License
244230
-------
245231

246-
Copyright 2014 Reverb Technologies, Inc.
232+
Copyright 2015 Reverb Technologies, Inc.
247233

248234
Licensed under the Apache License, Version 2.0 (the "License");
249235
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)