forked from loafle/openapi-generator-original
		
	Merge remote-tracking branch 'origin/master' into 2.3.0
This commit is contained in:
		
						commit
						766b04a2bd
					
				
							
								
								
									
										4
									
								
								.github/ISSUE_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/ISSUE_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							@ -5,7 +5,7 @@ Also please indicate in the issue title which language/library is concerned. Eg:
 | 
			
		||||
 | 
			
		||||
##### Description
 | 
			
		||||
 | 
			
		||||
<!-- describe what is the issue and why this is a problem for you. -->
 | 
			
		||||
<!-- describe what is the question, suggestion or issue and why this is a problem for you. -->
 | 
			
		||||
 | 
			
		||||
##### Swagger-codegen version
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,7 @@ Also please indicate in the issue title which language/library is concerned. Eg:
 | 
			
		||||
 | 
			
		||||
##### Related issues
 | 
			
		||||
 | 
			
		||||
<!-- has a similar issue been reported before? -->
 | 
			
		||||
<!-- has a similar issue been reported before? Please do a search in https://github.com/swagger-api/swagger-codegen/issues?utf8=%E2%9C%93&q=is%3Aissue%20 -->
 | 
			
		||||
 | 
			
		||||
##### Suggest a Fix
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								.github/PULL_REQUEST_TEMPLATE.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.github/PULL_REQUEST_TEMPLATE.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
### PR checklist
 | 
			
		||||
 | 
			
		||||
- [ ] Read the [contribution guildelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md).
 | 
			
		||||
- [ ] Ran the shell/batch script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run`./bin/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
 | 
			
		||||
- [ ] Filed the PR against the correct branch: master for non-breaking changes and `2.3.0` branch for breaking (non-backward compatible) changes.
 | 
			
		||||
 | 
			
		||||
### Description of the PR
 | 
			
		||||
 | 
			
		||||
(details of the change, additional tests that have been done, reference to the issue for tracking, etc)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -56,6 +56,8 @@ samples/client/petstore/qt5cpp/PetStore/Makefile
 | 
			
		||||
#Java/Android
 | 
			
		||||
**/.gradle
 | 
			
		||||
samples/client/petstore/java/hello.txt
 | 
			
		||||
samples/client/petstore/java/okhttp-gson/hello.txt
 | 
			
		||||
samples/client/petstore/java/jersey1/hello.txt
 | 
			
		||||
samples/client/petstore/java/jersey2-java8/hello.txt
 | 
			
		||||
samples/client/petstore/android/default/hello.txt
 | 
			
		||||
samples/client/petstore/android/volley/.gradle/
 | 
			
		||||
 | 
			
		||||
@ -28,6 +28,10 @@ before_install:
 | 
			
		||||
  - cat /etc/hosts
 | 
			
		||||
 | 
			
		||||
install:
 | 
			
		||||
  # Add Godeps dependencies to GOPATH and PATH
 | 
			
		||||
   - eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)"
 | 
			
		||||
   - export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
 | 
			
		||||
   - export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH"
 | 
			
		||||
 | 
			
		||||
script:
 | 
			
		||||
  - mvn verify -Psamples
 | 
			
		||||
 | 
			
		||||
@ -72,3 +72,4 @@ To start the CI tests, you can run `mvn verify -Psamples` (assuming you've all t
 | 
			
		||||
- Add test case(s) to cover the change
 | 
			
		||||
- Document the fix in the code to make the code more readable
 | 
			
		||||
- Make sure test cases passed after the change (one way is to leverage https://travis-ci.org/ to run the CI tests)
 | 
			
		||||
- File a PR with meaningful title, description and commit messages. A good example is [PR-3306](https://github.com/swagger-api/swagger-codegen/pull/3306)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								README.md
									
									
									
									
									
								
							@ -1,9 +1,10 @@
 | 
			
		||||
# Swagger Code Generator
 | 
			
		||||
 | 
			
		||||
[](https://travis-ci.org/swagger-api/swagger-codegen)
 | 
			
		||||
[](https://travis-ci.org/swagger-api/swagger-codegen)
 | 
			
		||||
[](https://app.shippable.com/projects/5782588a3be4f4faa56c5bea)
 | 
			
		||||
[](https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu)
 | 
			
		||||
[](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project)
 | 
			
		||||
[](http://issuestats.com/github/swagger-api/swagger-codegen) [](http://issuestats.com/github/swagger-api/swagger-codegen)
 | 
			
		||||
[](https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu)
 | 
			
		||||
 | 
			
		||||
:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star:
 | 
			
		||||
 | 
			
		||||
@ -60,8 +61,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
 | 
			
		||||
Swagger Codegen Version    | Release Date | OpenAPI Spec compatibility | Notes
 | 
			
		||||
-------------------------- | ------------ | -------------------------- | -----
 | 
			
		||||
2.3.0 (upcoming minor release) | TBD   | 1.0, 1.1, 1.2, 2.0   | Minor release with breaking changes
 | 
			
		||||
2.2.1 (upcoming patch release) | TBD   | 1.0, 1.1, 1.2, 2.0   | Patch release with non-breaking changes
 | 
			
		||||
2.2.0 (**current stable**) | 2016-07-15   | 1.0, 1.1, 1.2, 2.0   | [tag v2.2.0](https://github.com/swagger-api/swagger-codegen/tree/v2.2.0)
 | 
			
		||||
2.2.2 (upcoming patch release) | TBD   | 1.0, 1.1, 1.2, 2.0   | Patch release (without breaking changes)
 | 
			
		||||
2.2.1 (**current stable**) | 2016-08-07   | 1.0, 1.1, 1.2, 2.0   | [tag v2.2.1](https://github.com/swagger-api/swagger-codegen/tree/v2.2.1)
 | 
			
		||||
2.1.6 | 2016-04-06   | 1.0, 1.1, 1.2, 2.0   | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6)
 | 
			
		||||
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)
 | 
			
		||||
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)
 | 
			
		||||
@ -71,7 +72,7 @@ Swagger Codegen Version    | Release Date | OpenAPI Spec compatibility | Notes
 | 
			
		||||
If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum):
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.0/swagger-codegen-cli-2.2.0.jar -O swagger-codegen-cli.jar
 | 
			
		||||
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.1/swagger-codegen-cli-2.2.1.jar -O swagger-codegen-cli.jar
 | 
			
		||||
 | 
			
		||||
java -jar swagger-codegen-cli.jar help
 | 
			
		||||
```
 | 
			
		||||
@ -150,7 +151,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
 | 
			
		||||
```
 | 
			
		||||
(if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`)
 | 
			
		||||
 | 
			
		||||
You can also download the JAR (latest relesae) directly from [maven.org]( http://central.maven.org/maven2/io/swagger/swagger-codegen/2.2.0/swagger-codegen-2.2.0.jar)
 | 
			
		||||
You can also download the JAR (latest relesae) directly from [maven.org](http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.1/swagger-codegen-cli-2.2.1.jar )
 | 
			
		||||
 | 
			
		||||
To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate`
 | 
			
		||||
 | 
			
		||||
@ -754,14 +755,17 @@ Here are some companies/projects using Swagger Codegen in production. To add you
 | 
			
		||||
- [Conplement](http://www.conplement.de/)
 | 
			
		||||
- [Cupix](http://www.cupix.com)
 | 
			
		||||
- [DBBest Technologies](https://www.dbbest.com)
 | 
			
		||||
- [DecentFoX](http://decentfox.com/)
 | 
			
		||||
- [DocuSign](https://www.docusign.com)
 | 
			
		||||
- [Ergon](http://www.ergon.ch/)
 | 
			
		||||
- [EMC](https://www.emc.com/)
 | 
			
		||||
- [eureka](http://eure.jp/)
 | 
			
		||||
- [everystory.us](http://everystory.us)
 | 
			
		||||
- [Expected Behavior](http://www.expectedbehavior.com/)
 | 
			
		||||
- [Finder](http://en.finder.pl/)
 | 
			
		||||
- [FH Münster - University of Applied Sciences](http://www.fh-muenster.de)
 | 
			
		||||
- [Gear Zero Network](https://www.gearzero.ca)
 | 
			
		||||
- [Germin8](http://www.germin8.com)
 | 
			
		||||
- [GraphHopper](https://graphhopper.com/)
 | 
			
		||||
- [Gravitate Solutions](http://gravitatesolutions.com/)
 | 
			
		||||
- [IMS Health](http://www.imshealth.com/en/solution-areas/technology-and-applications)
 | 
			
		||||
@ -778,14 +782,17 @@ Here are some companies/projects using Swagger Codegen in production. To add you
 | 
			
		||||
- [OSDN](https://osdn.jp)
 | 
			
		||||
- [PagerDuty](https://www.pagerduty.com)
 | 
			
		||||
- [Pepipost](https://www.pepipost.com)
 | 
			
		||||
- [Plexxi](http://www.plexxi.com)
 | 
			
		||||
- [Pixoneye](http://www.pixoneye.com/)
 | 
			
		||||
- [PostAffiliatePro](https://www.postaffiliatepro.com/)
 | 
			
		||||
- [QuantiModo](https://quantimo.do/)
 | 
			
		||||
- [Rapid7](https://rapid7.com/)
 | 
			
		||||
- [Reload! A/S](https://reload.dk/) 
 | 
			
		||||
- [REstore](https://www.restore.eu)
 | 
			
		||||
- [Revault Sàrl](http://revault.ch)
 | 
			
		||||
- [Royal Bank of Canada (RBC)](http://www.rbc.com/canada.html)
 | 
			
		||||
- [SCOOP Software GmbH](http://www.scoop-software.de)
 | 
			
		||||
- [Skurt](http://www.skurt.com)
 | 
			
		||||
- [SmartRecruiters](https://www.smartrecruiters.com/)
 | 
			
		||||
- [StyleRecipe](http://stylerecipe.co.jp)
 | 
			
		||||
- [Svenska Spel AB](https://www.svenskaspel.se/)
 | 
			
		||||
@ -799,7 +806,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
 | 
			
		||||
 | 
			
		||||
# Swagger Codegen Core Team
 | 
			
		||||
 | 
			
		||||
Swaagger Codegen core team members are contributors who have been making signficiant contributions (review issues, fix bugs, make enhancements, etc) to the project on a regular basis.
 | 
			
		||||
Swaagger Codegen core team members are contributors who have been making significant contributions (review issues, fix bugs, make enhancements, etc) to the project on a regular basis.
 | 
			
		||||
 | 
			
		||||
## API Clients
 | 
			
		||||
| Languages     | Core Team (join date) | 
 | 
			
		||||
@ -868,6 +875,7 @@ Here is a list of template creators:
 | 
			
		||||
 * Server Stubs
 | 
			
		||||
   * C# ASP.NET5: @jimschubert
 | 
			
		||||
   * C# NancyFX: @mstefaniuk
 | 
			
		||||
   * Erlang Server: @galaxie
 | 
			
		||||
   * Go Server: @guohuang
 | 
			
		||||
   * Haskell Servant: @algas
 | 
			
		||||
   * Java Spring Boot: @diyfr
 | 
			
		||||
@ -876,6 +884,9 @@ Here is a list of template creators:
 | 
			
		||||
   * PHP Lumen: @abcsum
 | 
			
		||||
   * PHP Slim: @jfastnacht
 | 
			
		||||
   * Ruby on Rails 5: @zlx 
 | 
			
		||||
 * Documentation
 | 
			
		||||
   * HTML Doc 2: @jhitchcock
 | 
			
		||||
   * Confluence Wiki: @jhitchcock
 | 
			
		||||
 | 
			
		||||
## How to join the core team
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								appveyor.yml
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								appveyor.yml
									
									
									
									
									
								
							@ -1,7 +1,9 @@
 | 
			
		||||
# for CI with appveyor.yml
 | 
			
		||||
# Ref: http://www.yegor256.com/2015/01/10/windows-appveyor-maven.html
 | 
			
		||||
version: '{build}'
 | 
			
		||||
version: '{branch}-{build}'
 | 
			
		||||
os: Windows Server 2012
 | 
			
		||||
hosts:
 | 
			
		||||
  petstore.swagger.io: 127.0.0.1
 | 
			
		||||
install:
 | 
			
		||||
  - ps: |
 | 
			
		||||
      Add-Type -AssemblyName System.IO.Compression.FileSystem
 | 
			
		||||
@ -15,9 +17,17 @@ install:
 | 
			
		||||
  - cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;%PATH%
 | 
			
		||||
  - cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g
 | 
			
		||||
  - cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
 | 
			
		||||
  - cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
 | 
			
		||||
  - git clone https://github.com/wing328/swagger-samples
 | 
			
		||||
  - ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs"
 | 
			
		||||
build_script:
 | 
			
		||||
  - nuget restore samples\client\petstore\csharp\SwaggerClient\IO.Swagger.sln
 | 
			
		||||
  - msbuild samples\client\petstore\csharp\SwaggerClient\IO.Swagger.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
 | 
			
		||||
  - mvn clean install --batch-mode
 | 
			
		||||
test_script:
 | 
			
		||||
  # test c# API client
 | 
			
		||||
  - nunit-console samples\client\petstore\csharp\SwaggerClient\src\IO.Swagger.Test\bin\Debug\IO.Swagger.Test.dll --result=myresults.xml;format=AppVeyor
 | 
			
		||||
  # generate all petstore clients
 | 
			
		||||
  - .\bin\windows\run-all-petstore.cmd
 | 
			
		||||
cache:
 | 
			
		||||
  - C:\maven\
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								bin/android-petstore-all.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										5
									
								
								bin/android-petstore-all.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
./bin/android-petstore-httpclient.sh
 | 
			
		||||
./bin/android-petstore-volley.sh
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										31
									
								
								bin/cwiki-petstore.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								bin/cwiki-petstore.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
SCRIPT="$0"
 | 
			
		||||
 | 
			
		||||
while [ -h "$SCRIPT" ] ; do
 | 
			
		||||
  ls=`ls -ld "$SCRIPT"`
 | 
			
		||||
  link=`expr "$ls" : '.*-> \(.*\)$'`
 | 
			
		||||
  if expr "$link" : '/.*' > /dev/null; then
 | 
			
		||||
    SCRIPT="$link"
 | 
			
		||||
  else
 | 
			
		||||
    SCRIPT=`dirname "$SCRIPT"`/"$link"
 | 
			
		||||
  fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [ ! -d "${APP_DIR}" ]; then
 | 
			
		||||
  APP_DIR=`dirname "$SCRIPT"`/..
 | 
			
		||||
  APP_DIR=`cd "${APP_DIR}"; pwd`
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
 | 
			
		||||
 | 
			
		||||
if [ ! -f "$executable" ]
 | 
			
		||||
then
 | 
			
		||||
  mvn clean package
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l cwiki -o samples/documentation/cwiki"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
							
								
								
									
										31
									
								
								bin/erlang-petstore-server.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								bin/erlang-petstore-server.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
SCRIPT="$0"
 | 
			
		||||
 | 
			
		||||
while [ -h "$SCRIPT" ] ; do
 | 
			
		||||
  ls=`ls -ld "$SCRIPT"`
 | 
			
		||||
  link=`expr "$ls" : '.*-> \(.*\)$'`
 | 
			
		||||
  if expr "$link" : '/.*' > /dev/null; then
 | 
			
		||||
    SCRIPT="$link"
 | 
			
		||||
  else
 | 
			
		||||
    SCRIPT=`dirname "$SCRIPT"`/"$link"
 | 
			
		||||
  fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [ ! -d "${APP_DIR}" ]; then
 | 
			
		||||
  APP_DIR=`dirname "$SCRIPT"`/..
 | 
			
		||||
  APP_DIR=`cd "${APP_DIR}"; pwd`
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
 | 
			
		||||
 | 
			
		||||
if [ ! -f "$executable" ]
 | 
			
		||||
then
 | 
			
		||||
  mvn clean package
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/erlang-server -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l erlang-server -o samples/server/petstore/erlang-server"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
@ -26,6 +26,6 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l go -o samples/client/petstore/go/go-petstore -DpackageName=petstore "
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l go -o samples/client/petstore/go/go-petstore -DpackageName=petstore "
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,6 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaInflector -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l inflector -o samples/server/petstore/java-inflector"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaInflector -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l inflector -o samples/server/petstore/java-inflector"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/jersey1 -DhideGenerationTimestamp=true --library=jersey1"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Java -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/jersey1 -DhideGenerationTimestamp=true --library=jersey1"
 | 
			
		||||
 | 
			
		||||
echo "Removing files and folders under samples/client/petstore/java/jersey1/src/main"
 | 
			
		||||
rm -rf samples/client/petstore/java/jersey1/src/main
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								bin/javascript-petstore-all.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								bin/javascript-petstore-all.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
./bin/javascript-petstore.sh
 | 
			
		||||
./bin/javascript-promise-petstore.sh
 | 
			
		||||
@ -26,6 +26,6 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf -o samples/server/petstore/jaxrs-cxf -DhideGenerationTimestamp=true"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf -o samples/server/petstore/jaxrs-cxf -DhideGenerationTimestamp=true"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1 -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey1 -DhideGenerationTimestamp=true --library=jersey1 --artifact-id=swagger-jaxrs-jersey1-server"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1 -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey1 -DhideGenerationTimestamp=true --library=jersey1 --artifact-id=swagger-jaxrs-jersey1-server"
 | 
			
		||||
 | 
			
		||||
echo "Removing files and folders under samples/server/petstore/jaxrs/jersey1/src/main"
 | 
			
		||||
rm -rf samples/server/petstore/jaxrs/jersey1/src/main
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey2 -DhideGenerationTimestamp=true"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey2 -DhideGenerationTimestamp=true"
 | 
			
		||||
 | 
			
		||||
echo "Removing files and folders under samples/server/petstore/jaxrs/jersey2/src/main"
 | 
			
		||||
rm -rf samples/server/petstore/jaxrs/jersey2/src/main
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,6 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy/joda -DhideGenerationTimestamp=true -c ./bin/jaxrs-resteasy-joda-petstore-server.json"
 | 
			
		||||
ags="$@ generate --artifact-id swagger-jaxrs-resteasy-joda-server -t modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy/joda -DhideGenerationTimestamp=true -c ./bin/jaxrs-resteasy-joda-petstore-server.json"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,6 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy/default -DhideGenerationTimestamp=true"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy/default -DhideGenerationTimestamp=true"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										31
									
								
								bin/nancyfx-petstore-server.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								bin/nancyfx-petstore-server.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
SCRIPT="$0"
 | 
			
		||||
 | 
			
		||||
while [ -h "$SCRIPT" ] ; do
 | 
			
		||||
  ls=`ls -ld "$SCRIPT"`
 | 
			
		||||
  link=`expr "$ls" : '.*-> \(.*\)$'`
 | 
			
		||||
  if expr "$link" : '/.*' > /dev/null; then
 | 
			
		||||
    SCRIPT="$link"
 | 
			
		||||
  else
 | 
			
		||||
    SCRIPT=`dirname "$SCRIPT"`/"$link"
 | 
			
		||||
  fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [ ! -d "${APP_DIR}" ]; then
 | 
			
		||||
  APP_DIR=`dirname "$SCRIPT"`/..
 | 
			
		||||
  APP_DIR=`cd "${APP_DIR}"; pwd`
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
 | 
			
		||||
 | 
			
		||||
if [ ! -f "$executable" ]
 | 
			
		||||
then
 | 
			
		||||
  mvn clean package
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/nancyfx -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l nancyfx -o samples/server/petstore/nancyfx"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
							
								
								
									
										7
									
								
								bin/spring-all-pestore.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								bin/spring-all-pestore.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
./bin/spring-cloud-feign-petstore.sh
 | 
			
		||||
./bin/spring-stubs.sh
 | 
			
		||||
./bin/spring-mvc-petstore-j8-async-server.sh
 | 
			
		||||
./bin/springboot-petstore-server.sh
 | 
			
		||||
./bin/spring-mvc-petstore-server.sh
 | 
			
		||||
@ -26,6 +26,6 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring --library spring-mvc -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json -DhideGenerationTimestamp=true,java8=true,async=true"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring --library spring-mvc -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json -DhideGenerationTimestamp=true,java8=true,async=true"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,6 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring -c bin/spring-mvc-petstore-server.json -o samples/server/petstore/spring-mvc -DhideGenerationTimestamp=true"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -c bin/spring-mvc-petstore-server.json -o samples/server/petstore/spring-mvc -DhideGenerationTimestamp=true"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring -o samples/server/petstore/springboot -DhideGenerationTimestamp=true"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpring -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot -DhideGenerationTimestamp=true"
 | 
			
		||||
 | 
			
		||||
echo "Removing files and folders under samples/server/petstore/springboot/src/main"
 | 
			
		||||
rm -rf samples/server/petstore/springboot/src/main
 | 
			
		||||
 | 
			
		||||
@ -34,3 +34,7 @@ java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore-promisekit.json -o samples/client/petstore/swift/promisekit"
 | 
			
		||||
echo "#### Petstore Swift API client (promisekit) ####"
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore-rxswift.json -o samples/client/petstore/swift/rxswift"
 | 
			
		||||
echo "#### Petstore Swift API client (rxswift) ####"
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								bin/swift-petstore-rxswift.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								bin/swift-petstore-rxswift.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "podSummary": "PetstoreClient",
 | 
			
		||||
  "podHomepage": "https://github.com/swagger-api/swagger-codegen",
 | 
			
		||||
  "podAuthors": "",
 | 
			
		||||
  "projectName": "PetstoreClient",
 | 
			
		||||
  "responseAs": "RxSwift"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								bin/swift-petstore-rxswift.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								bin/swift-petstore-rxswift.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
SCRIPT="$0"
 | 
			
		||||
 | 
			
		||||
while [ -h "$SCRIPT" ] ; do
 | 
			
		||||
  ls=`ls -ld "$SCRIPT"`
 | 
			
		||||
  link=`expr "$ls" : '.*-> \(.*\)$'`
 | 
			
		||||
  if expr "$link" : '/.*' > /dev/null; then
 | 
			
		||||
    SCRIPT="$link"
 | 
			
		||||
  else
 | 
			
		||||
    SCRIPT=`dirname "$SCRIPT"`/"$link"
 | 
			
		||||
  fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [ ! -d "${APP_DIR}" ]; then
 | 
			
		||||
  APP_DIR=`dirname "$SCRIPT"`/..
 | 
			
		||||
  APP_DIR=`cd "${APP_DIR}"; pwd`
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
 | 
			
		||||
 | 
			
		||||
if [ ! -f "$executable" ]
 | 
			
		||||
then
 | 
			
		||||
  mvn clean package
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# if you've executed sbt assembly previously it will use that instead.
 | 
			
		||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
			
		||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore-rxswift.json -o samples/client/petstore/swift/rxswift"
 | 
			
		||||
 | 
			
		||||
java $JAVA_OPTS -jar $executable $ags
 | 
			
		||||
@ -5,6 +5,6 @@ If Not Exist %executable% (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
 | 
			
		||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l nancyfx -o samples\server\petstore\nancyfx\
 | 
			
		||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l nancyfx -o samples\server\petstore\nancyfx\
 | 
			
		||||
 | 
			
		||||
java %JAVA_OPTS% -jar %executable% %ags%
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
 | 
			
		||||
<plugin>
 | 
			
		||||
    <groupId>io.swagger</groupId>
 | 
			
		||||
    <artifactId>swagger-codegen-maven-plugin</artifactId>
 | 
			
		||||
    <version>2.1.5-SNAPSHOT</version>
 | 
			
		||||
    <version>2.2.2-SNAPSHOT</version>
 | 
			
		||||
    <executions>
 | 
			
		||||
        <execution>
 | 
			
		||||
            <goals>
 | 
			
		||||
 | 
			
		||||
@ -12,7 +12,7 @@
 | 
			
		||||
            <plugin>
 | 
			
		||||
                <groupId>io.swagger</groupId>
 | 
			
		||||
                <artifactId>swagger-codegen-maven-plugin</artifactId>
 | 
			
		||||
                <version>2.1.5-SNAPSHOT</version>
 | 
			
		||||
                <version>2.2.2-SNAPSHOT</version>
 | 
			
		||||
                <executions>
 | 
			
		||||
                    <execution>
 | 
			
		||||
                        <goals>
 | 
			
		||||
 | 
			
		||||
@ -93,7 +93,7 @@ paths:
 | 
			
		||||
      tags:
 | 
			
		||||
      - "pet"
 | 
			
		||||
      summary: "Finds Pets by status"
 | 
			
		||||
      description: "Multiple status values can be provided with comma seperated strings"
 | 
			
		||||
      description: "Multiple status values can be provided with comma separated strings"
 | 
			
		||||
      operationId: "findPetsByStatus"
 | 
			
		||||
      produces:
 | 
			
		||||
      - "application/xml"
 | 
			
		||||
@ -130,7 +130,7 @@ paths:
 | 
			
		||||
      tags:
 | 
			
		||||
      - "pet"
 | 
			
		||||
      summary: "Finds Pets by tags"
 | 
			
		||||
      description: "Muliple tags can be provided with comma seperated strings. Use\
 | 
			
		||||
      description: "Multiple tags can be provided with comma separated strings. Use\
 | 
			
		||||
        \ tag1, tag2, tag3 for testing."
 | 
			
		||||
      operationId: "findPetsByTags"
 | 
			
		||||
      produces:
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@ public class ConfigParser {
 | 
			
		||||
            Iterator<Map.Entry<String, JsonNode>> optionNodes = rootNode.fields();
 | 
			
		||||
 | 
			
		||||
            while (optionNodes.hasNext()) {
 | 
			
		||||
                Map.Entry<String, JsonNode> optionNode = (Map.Entry<String, JsonNode>) optionNodes.next();
 | 
			
		||||
                Map.Entry<String, JsonNode> optionNode = optionNodes.next();
 | 
			
		||||
 | 
			
		||||
                if (optionNode.getValue().isValueNode()) {
 | 
			
		||||
                    config.setOption(optionNode.getKey(), optionNode.getValue().asText());
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,6 @@ package io.swagger.codegen;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.ServiceLoader;
 | 
			
		||||
@ -124,9 +123,8 @@ public class Codegen extends DefaultGenerator {
 | 
			
		||||
    public static List<CodegenConfig> getExtensions() {
 | 
			
		||||
        ServiceLoader<CodegenConfig> loader = ServiceLoader.load(CodegenConfig.class);
 | 
			
		||||
        List<CodegenConfig> output = new ArrayList<CodegenConfig>();
 | 
			
		||||
        Iterator<CodegenConfig> itr = loader.iterator();
 | 
			
		||||
        while (itr.hasNext()) {
 | 
			
		||||
            output.add(itr.next());
 | 
			
		||||
        for (CodegenConfig aLoader : loader) {
 | 
			
		||||
            output.add(aLoader);
 | 
			
		||||
        }
 | 
			
		||||
        return output;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -10,6 +10,8 @@ import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.samskivert.mustache.Mustache.Compiler;
 | 
			
		||||
 | 
			
		||||
public interface CodegenConfig {
 | 
			
		||||
    CodegenType getTag();
 | 
			
		||||
 | 
			
		||||
@ -77,6 +79,10 @@ public interface CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    List<SupportingFile> supportingFiles();
 | 
			
		||||
 | 
			
		||||
    String getInputSpec();
 | 
			
		||||
 | 
			
		||||
    void setInputSpec(String inputSpec);
 | 
			
		||||
 | 
			
		||||
    String getOutputDir();
 | 
			
		||||
 | 
			
		||||
    void setOutputDir(String dir);
 | 
			
		||||
@ -117,6 +123,8 @@ public interface CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    void processSwagger(Swagger swagger);
 | 
			
		||||
 | 
			
		||||
    Compiler processCompiler(Compiler compiler);
 | 
			
		||||
 | 
			
		||||
    String sanitizeTag(String tag);
 | 
			
		||||
 | 
			
		||||
    String toApiFilename(String name);
 | 
			
		||||
 | 
			
		||||
@ -127,4 +127,6 @@ public class CodegenConstants {
 | 
			
		||||
    public static final String GENERATE_MODEL_TESTS = "generateModelTests";
 | 
			
		||||
    public static final String GENERATE_MODEL_TESTS_DESC = "Specifies that model tests are to be generated.";
 | 
			
		||||
 | 
			
		||||
    public static final String HIDE_GENERATION_TIMESTAMP = "hideGenerationTimestamp";
 | 
			
		||||
    public static final String HIDE_GENERATION_TIMESTAMP_DESC = "Hides the generation timestamp.";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -30,9 +30,7 @@ public final class CodegenModelFactory {
 | 
			
		||||
        Class<?> classType = typeMapping.get(type);
 | 
			
		||||
        try {
 | 
			
		||||
            return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
 | 
			
		||||
        } catch (InstantiationException e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        } catch (IllegalAccessException e) {
 | 
			
		||||
        } catch (IllegalAccessException | InstantiationException e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -281,7 +281,7 @@ public class CodegenOperation {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        int result = responseHeaders != null ? responseHeaders.hashCode() : 0;
 | 
			
		||||
        int result = responseHeaders.hashCode();
 | 
			
		||||
        result = 31 * result + (hasAuthMethods != null ? hasAuthMethods.hashCode() : 0);
 | 
			
		||||
        result = 31 * result + (hasConsumes != null ? hasConsumes.hashCode() : 0);
 | 
			
		||||
        result = 31 * result + (hasProduces != null ? hasProduces.hashCode() : 0);
 | 
			
		||||
 | 
			
		||||
@ -46,6 +46,8 @@ public class CodegenProperty implements Cloneable {
 | 
			
		||||
    public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
 | 
			
		||||
    public Boolean isInherited;
 | 
			
		||||
    public String nameInCamelCase; // property name in camel case
 | 
			
		||||
    // enum name based on the property name, usually use as a prefix (e.g. VAR_NAME) for enum name (e.g. VAR_NAME_VALUE1)
 | 
			
		||||
    public String enumName; 
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
@ -111,6 +113,7 @@ public class CodegenProperty implements Cloneable {
 | 
			
		||||
        result = prime * result + ((isListContainer == null) ? 0 : isListContainer.hashCode());
 | 
			
		||||
        result = prime * result + Objects.hashCode(isInherited);
 | 
			
		||||
        result = prime * result + Objects.hashCode(nameInCamelCase);
 | 
			
		||||
        result = prime * result + Objects.hashCode(enumName);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -271,6 +274,9 @@ public class CodegenProperty implements Cloneable {
 | 
			
		||||
        if (!Objects.equals(this.nameInCamelCase, other.nameInCamelCase)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (!Objects.equals(this.enumName, other.enumName)) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@ public class CodegenResponse {
 | 
			
		||||
 | 
			
		||||
        CodegenResponse that = (CodegenResponse) o;
 | 
			
		||||
 | 
			
		||||
        if (headers != null ? !headers.equals(that.headers) : that.headers != null)
 | 
			
		||||
        if (!headers.equals(that.headers))
 | 
			
		||||
            return false;
 | 
			
		||||
        if (code != null ? !code.equals(that.code) : that.code != null)
 | 
			
		||||
            return false;
 | 
			
		||||
@ -71,7 +71,7 @@ public class CodegenResponse {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        int result = headers != null ? headers.hashCode() : 0;
 | 
			
		||||
        int result = headers.hashCode();
 | 
			
		||||
        result = 31 * result + (code != null ? code.hashCode() : 0);
 | 
			
		||||
        result = 31 * result + (message != null ? message.hashCode() : 0);
 | 
			
		||||
        result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0);
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,8 @@ package io.swagger.codegen;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Function;
 | 
			
		||||
import com.google.common.collect.Lists;
 | 
			
		||||
import com.samskivert.mustache.Mustache.Compiler;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.examples.ExampleGenerator;
 | 
			
		||||
import io.swagger.models.ArrayModel;
 | 
			
		||||
import io.swagger.models.ComposedModel;
 | 
			
		||||
@ -72,6 +74,7 @@ import java.util.regex.Pattern;
 | 
			
		||||
public class DefaultCodegen {
 | 
			
		||||
    protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
 | 
			
		||||
    
 | 
			
		||||
    protected String inputSpec;
 | 
			
		||||
    protected String outputFolder = "";
 | 
			
		||||
    protected Set<String> defaultIncludes = new HashSet<String>();
 | 
			
		||||
    protected Map<String, String> typeMapping = new HashMap<String, String>();
 | 
			
		||||
@ -103,10 +106,11 @@ public class DefaultCodegen {
 | 
			
		||||
    protected Boolean ensureUniqueParams = true;
 | 
			
		||||
    protected String gitUserId, gitRepoId, releaseNote;
 | 
			
		||||
    protected String httpUserAgent;
 | 
			
		||||
    protected Boolean hideGenerationTimestamp = true;
 | 
			
		||||
    // How to encode special characters like $
 | 
			
		||||
    // They are translated to words like "Dollar" and prefixed with '
 | 
			
		||||
    // Then translated back during JSON encoding and decoding
 | 
			
		||||
    protected Map<Character, String> specialCharReplacements = new HashMap<Character, String>();
 | 
			
		||||
    protected Map<String, String> specialCharReplacements = new HashMap<String, String>();
 | 
			
		||||
 | 
			
		||||
    public List<CliOption> cliOptions() {
 | 
			
		||||
        return cliOptions;
 | 
			
		||||
@ -253,7 +257,7 @@ public class DefaultCodegen {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the enum default value in the language specifed format
 | 
			
		||||
     * Return the enum default value in the language specified format
 | 
			
		||||
     * 
 | 
			
		||||
     * @param value enum variable name
 | 
			
		||||
     * @param datatype data type
 | 
			
		||||
@ -264,7 +268,7 @@ public class DefaultCodegen {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the enum value in the language specifed format
 | 
			
		||||
     * Return the enum value in the language specified format
 | 
			
		||||
     * e.g. status becomes "status"
 | 
			
		||||
     * 
 | 
			
		||||
     * @param value enum variable name
 | 
			
		||||
@ -327,6 +331,12 @@ public class DefaultCodegen {
 | 
			
		||||
    public void processSwagger(Swagger swagger) {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // override with any special handling of the JMustache compiler
 | 
			
		||||
    @SuppressWarnings("unused")
 | 
			
		||||
    public Compiler processCompiler(Compiler compiler) {
 | 
			
		||||
    	return compiler;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // override with any special text escaping logic
 | 
			
		||||
    @SuppressWarnings("static-method")
 | 
			
		||||
    public String escapeText(String input) {
 | 
			
		||||
@ -349,7 +359,7 @@ public class DefaultCodegen {
 | 
			
		||||
     * @return string with unsafe characters removed or escaped
 | 
			
		||||
     */
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        LOGGER.warn("escapeUnsafeCharacters should be overriden in the code generator with proper logic to escape unsafe characters");
 | 
			
		||||
        LOGGER.warn("escapeUnsafeCharacters should be overridden in the code generator with proper logic to escape unsafe characters");
 | 
			
		||||
        // doing nothing by default and code generator should implement
 | 
			
		||||
        // the logic to prevent code injection
 | 
			
		||||
        // later we'll make this method abstract to make sure
 | 
			
		||||
@ -363,7 +373,7 @@ public class DefaultCodegen {
 | 
			
		||||
     * @return string with quotation mark removed or escaped
 | 
			
		||||
     */
 | 
			
		||||
    public String escapeQuotationMark(String input) {
 | 
			
		||||
        LOGGER.warn("escapeQuotationMark should be overriden in the code generator with proper logic to escape single/double quote");
 | 
			
		||||
        LOGGER.warn("escapeQuotationMark should be overridden in the code generator with proper logic to escape single/double quote");
 | 
			
		||||
        return input.replace("\"", "\\\"");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -499,6 +509,14 @@ public class DefaultCodegen {
 | 
			
		||||
        return outputFolder();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getInputSpec() {
 | 
			
		||||
        return inputSpec;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setInputSpec(String inputSpec) {
 | 
			
		||||
        this.inputSpec = inputSpec;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTemplateDir(String templateDir) {
 | 
			
		||||
        this.templateDir = templateDir;
 | 
			
		||||
    }
 | 
			
		||||
@ -534,7 +552,7 @@ public class DefaultCodegen {
 | 
			
		||||
     * @return properly-escaped pattern
 | 
			
		||||
     */
 | 
			
		||||
    public String toRegularExpression(String pattern) {
 | 
			
		||||
        return escapeText(pattern);
 | 
			
		||||
        return escapeText(addRegularExpressionDelimiter(pattern));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -780,30 +798,60 @@ public class DefaultCodegen {
 | 
			
		||||
        cliOptions.add(CliOption.newBoolean(CodegenConstants.ENSURE_UNIQUE_PARAMS, CodegenConstants
 | 
			
		||||
                .ENSURE_UNIQUE_PARAMS_DESC).defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
 | 
			
		||||
        // initalize special character mapping
 | 
			
		||||
        // initialize special character mapping
 | 
			
		||||
        initalizeSpecialCharacterMapping();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Initalize special character mapping
 | 
			
		||||
     * Initialize special character mapping
 | 
			
		||||
     */
 | 
			
		||||
    protected void initalizeSpecialCharacterMapping() {
 | 
			
		||||
        // Initialize special characters
 | 
			
		||||
        specialCharReplacements.put('$', "Dollar");
 | 
			
		||||
        specialCharReplacements.put('^', "Caret");
 | 
			
		||||
        specialCharReplacements.put('|', "Pipe");
 | 
			
		||||
        specialCharReplacements.put('=', "Equal");
 | 
			
		||||
        specialCharReplacements.put('*', "Star");
 | 
			
		||||
        specialCharReplacements.put('-', "Minus");
 | 
			
		||||
        specialCharReplacements.put('&', "Ampersand");
 | 
			
		||||
        specialCharReplacements.put('%', "Percent");
 | 
			
		||||
        specialCharReplacements.put('#', "Hash");
 | 
			
		||||
        specialCharReplacements.put('@', "At");
 | 
			
		||||
        specialCharReplacements.put('!', "Exclamation");
 | 
			
		||||
        specialCharReplacements.put('+', "Plus");
 | 
			
		||||
        specialCharReplacements.put(':', "Colon");
 | 
			
		||||
        specialCharReplacements.put('>', "GreaterThan");
 | 
			
		||||
        specialCharReplacements.put('<', "LessThan");
 | 
			
		||||
        specialCharReplacements.put("$", "Dollar");
 | 
			
		||||
        specialCharReplacements.put("^", "Caret");
 | 
			
		||||
        specialCharReplacements.put("|", "Pipe");
 | 
			
		||||
        specialCharReplacements.put("=", "Equal");
 | 
			
		||||
        specialCharReplacements.put("*", "Star");
 | 
			
		||||
        specialCharReplacements.put("-", "Minus");
 | 
			
		||||
        specialCharReplacements.put("&", "Ampersand");
 | 
			
		||||
        specialCharReplacements.put("%", "Percent");
 | 
			
		||||
        specialCharReplacements.put("#", "Hash");
 | 
			
		||||
        specialCharReplacements.put("@", "At");
 | 
			
		||||
        specialCharReplacements.put("!", "Exclamation");
 | 
			
		||||
        specialCharReplacements.put("+", "Plus");
 | 
			
		||||
        specialCharReplacements.put(":", "Colon");
 | 
			
		||||
        specialCharReplacements.put(">", "Greater_Than");
 | 
			
		||||
        specialCharReplacements.put("<", "Less_Than");
 | 
			
		||||
        specialCharReplacements.put(".", "Period");
 | 
			
		||||
        specialCharReplacements.put("_", "Underscore");
 | 
			
		||||
        specialCharReplacements.put("?", "Question_Mark");
 | 
			
		||||
        specialCharReplacements.put(",", "Comma");
 | 
			
		||||
        specialCharReplacements.put("'", "Quote");
 | 
			
		||||
        specialCharReplacements.put("\"", "Double_Quote");
 | 
			
		||||
        specialCharReplacements.put("/", "Slash");
 | 
			
		||||
        specialCharReplacements.put("\\", "Back_Slash");
 | 
			
		||||
        specialCharReplacements.put("(", "Left_Parenthesis");
 | 
			
		||||
        specialCharReplacements.put(")", "Right_Parenthesis");
 | 
			
		||||
        specialCharReplacements.put("{", "Left_Curly_Bracket");
 | 
			
		||||
        specialCharReplacements.put("}", "Right_Curly_Bracket");
 | 
			
		||||
        specialCharReplacements.put("[", "Left_Square_Bracket");
 | 
			
		||||
        specialCharReplacements.put("]", "Right_Square_Bracket");
 | 
			
		||||
        specialCharReplacements.put("~", "Tilde");
 | 
			
		||||
        specialCharReplacements.put("`", "Backtick");
 | 
			
		||||
 | 
			
		||||
        specialCharReplacements.put("<=", "Less_Than_Or_Equal_To");
 | 
			
		||||
        specialCharReplacements.put(">=", "Greater_Than_Or_Equal_To");
 | 
			
		||||
        specialCharReplacements.put("!=", "Not_Equal");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the symbol name of a symbol
 | 
			
		||||
     *
 | 
			
		||||
     * @param input Symbol (e.g. $)
 | 
			
		||||
     * @return Symbol name (e.g. Dollar)
 | 
			
		||||
     */
 | 
			
		||||
    protected String getSymbolName(String input) {
 | 
			
		||||
        return specialCharReplacements.get(input);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -838,7 +886,7 @@ public class DefaultCodegen {
 | 
			
		||||
                    paramPart.append(param.getName()).append("=");
 | 
			
		||||
                    paramPart.append("{");
 | 
			
		||||
                    if (qp.getCollectionFormat() != null) {
 | 
			
		||||
                        paramPart.append(param.getName() + "1");
 | 
			
		||||
                        paramPart.append(param.getName()).append("1");
 | 
			
		||||
                        if ("csv".equals(qp.getCollectionFormat())) {
 | 
			
		||||
                            paramPart.append(",");
 | 
			
		||||
                        } else if ("pipes".equals(qp.getCollectionFormat())) {
 | 
			
		||||
@ -847,7 +895,7 @@ public class DefaultCodegen {
 | 
			
		||||
                            paramPart.append("\t");
 | 
			
		||||
                        } else if ("multi".equals(qp.getCollectionFormat())) {
 | 
			
		||||
                            paramPart.append("&").append(param.getName()).append("=");
 | 
			
		||||
                            paramPart.append(param.getName() + "2");
 | 
			
		||||
                            paramPart.append(param.getName()).append("2");
 | 
			
		||||
                        }
 | 
			
		||||
                    } else {
 | 
			
		||||
                        paramPart.append(param.getName());
 | 
			
		||||
@ -1334,7 +1382,7 @@ public class DefaultCodegen {
 | 
			
		||||
 | 
			
		||||
        property.name = toVarName(name);
 | 
			
		||||
        property.baseName = name;
 | 
			
		||||
        property.nameInCamelCase = camelize(name, false);
 | 
			
		||||
        property.nameInCamelCase = camelize(property.name, false);
 | 
			
		||||
        property.description = escapeText(p.getDescription());
 | 
			
		||||
        property.unescapedDescription = p.getDescription();
 | 
			
		||||
        property.getter = "get" + getterAndSetterCapitalize(name);
 | 
			
		||||
@ -1355,7 +1403,8 @@ public class DefaultCodegen {
 | 
			
		||||
            property.exclusiveMaximum = np.getExclusiveMaximum();
 | 
			
		||||
 | 
			
		||||
            // check if any validation rule defined
 | 
			
		||||
            if (property.minimum != null || property.maximum != null || property.exclusiveMinimum != null || property.exclusiveMaximum != null)
 | 
			
		||||
            // exclusive* are noop without corresponding min/max
 | 
			
		||||
            if (property.minimum != null || property.maximum != null)
 | 
			
		||||
                property.hasValidation = true;
 | 
			
		||||
 | 
			
		||||
            // legacy support
 | 
			
		||||
@ -1525,7 +1574,7 @@ public class DefaultCodegen {
 | 
			
		||||
                List<String> _enum = sp.getEnum();
 | 
			
		||||
                property._enum = new ArrayList<String>();
 | 
			
		||||
                for(String i : _enum) {
 | 
			
		||||
                  property._enum.add(i.toString());
 | 
			
		||||
                  property._enum.add(i);
 | 
			
		||||
                }
 | 
			
		||||
                property.isEnum = true;
 | 
			
		||||
 | 
			
		||||
@ -1543,7 +1592,7 @@ public class DefaultCodegen {
 | 
			
		||||
                List<String> _enum = sp.getEnum();
 | 
			
		||||
                property._enum = new ArrayList<String>();
 | 
			
		||||
                for(String i : _enum) {
 | 
			
		||||
                  property._enum.add(i.toString());
 | 
			
		||||
                  property._enum.add(i);
 | 
			
		||||
                }
 | 
			
		||||
                property.isEnum = true;
 | 
			
		||||
 | 
			
		||||
@ -1559,6 +1608,7 @@ public class DefaultCodegen {
 | 
			
		||||
        // this can cause issues for clients which don't support enums
 | 
			
		||||
        if (property.isEnum) {
 | 
			
		||||
            property.datatypeWithEnum = toEnumName(property);
 | 
			
		||||
            property.enumName = toEnumName(property);
 | 
			
		||||
        } else {
 | 
			
		||||
            property.datatypeWithEnum = property.datatype;
 | 
			
		||||
        }
 | 
			
		||||
@ -1606,11 +1656,14 @@ public class DefaultCodegen {
 | 
			
		||||
            property.items = innerProperty;
 | 
			
		||||
            // inner item is Enum
 | 
			
		||||
            if (isPropertyInnerMostEnum(property)) {
 | 
			
		||||
                // isEnum is set to true when the type is an enum
 | 
			
		||||
                // or the inner type of an array/map is an enum
 | 
			
		||||
                property.isEnum = true;
 | 
			
		||||
                // update datatypeWithEnum and default value for array
 | 
			
		||||
                // e.g. List<string> => List<StatusEnum>
 | 
			
		||||
                updateDataTypeWithEnumForArray(property);
 | 
			
		||||
 | 
			
		||||
                // set allowable values to enum values (including array/map of enum)
 | 
			
		||||
                property.allowableValues = getInnerEnumAllowableValues(property);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -1633,10 +1686,14 @@ public class DefaultCodegen {
 | 
			
		||||
            property.items = innerProperty;
 | 
			
		||||
            // inner item is Enum
 | 
			
		||||
            if (isPropertyInnerMostEnum(property)) {
 | 
			
		||||
                // isEnum is set to true when the type is an enum
 | 
			
		||||
                // or the inner type of an array/map is an enum
 | 
			
		||||
                property.isEnum = true;
 | 
			
		||||
                // update datatypeWithEnum and default value for map
 | 
			
		||||
                // e.g. Dictionary<string, string> => Dictionary<string, StatusEnum>
 | 
			
		||||
                updateDataTypeWithEnumForMap(property);
 | 
			
		||||
                // set allowable values to enum values (including array/map of enum)
 | 
			
		||||
                property.allowableValues = getInnerEnumAllowableValues(property);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -1657,6 +1714,17 @@ public class DefaultCodegen {
 | 
			
		||||
        return currentProperty.isEnum;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected Map<String, Object> getInnerEnumAllowableValues(CodegenProperty property) {
 | 
			
		||||
        CodegenProperty currentProperty = property;
 | 
			
		||||
        while (currentProperty != null && (Boolean.TRUE.equals(currentProperty.isMapContainer)
 | 
			
		||||
                    || Boolean.TRUE.equals(currentProperty.isListContainer))) {
 | 
			
		||||
            currentProperty = currentProperty.items;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return currentProperty.allowableValues;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Update datatypeWithEnum for array container
 | 
			
		||||
     * @param property Codegen property
 | 
			
		||||
@ -1670,9 +1738,13 @@ public class DefaultCodegen {
 | 
			
		||||
        // set both datatype and datetypeWithEnum as only the inner type is enum
 | 
			
		||||
        property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType, toEnumName(baseItem));
 | 
			
		||||
 | 
			
		||||
        // naming the enum with respect to the language enum naming convention
 | 
			
		||||
        // e.g. remove [], {} from array/map of enum
 | 
			
		||||
        property.enumName = toEnumName(property);
 | 
			
		||||
 | 
			
		||||
        // set default value for variable with inner enum
 | 
			
		||||
        if (property.defaultValue != null) {
 | 
			
		||||
            property.defaultValue = property.defaultValue.replace(property.items.baseType, toEnumName(property.items));
 | 
			
		||||
            property.defaultValue = property.defaultValue.replace(baseItem.baseType, toEnumName(baseItem));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1689,6 +1761,10 @@ public class DefaultCodegen {
 | 
			
		||||
        // set both datatype and datetypeWithEnum as only the inner type is enum
 | 
			
		||||
        property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));
 | 
			
		||||
 | 
			
		||||
        // naming the enum with respect to the language enum naming convention
 | 
			
		||||
        // e.g. remove [], {} from array/map of enum
 | 
			
		||||
        property.enumName = toEnumName(property);
 | 
			
		||||
 | 
			
		||||
        // set default value for variable with inner enum
 | 
			
		||||
        if (property.defaultValue != null) {
 | 
			
		||||
            property.defaultValue = property.defaultValue.replace(", " + property.items.baseType, ", " + toEnumName(property.items));
 | 
			
		||||
@ -2195,8 +2271,8 @@ public class DefaultCodegen {
 | 
			
		||||
            p.uniqueItems = qp.isUniqueItems();
 | 
			
		||||
            p.multipleOf = qp.getMultipleOf();
 | 
			
		||||
 | 
			
		||||
            if (p.maximum != null || p.exclusiveMaximum != null ||
 | 
			
		||||
                    p.minimum != null || p.exclusiveMinimum != null ||
 | 
			
		||||
            // exclusive* are noop without corresponding min/max
 | 
			
		||||
            if (p.maximum != null || p.minimum != null ||
 | 
			
		||||
                    p.maxLength != null || p.minLength != null ||
 | 
			
		||||
                    p.maxItems != null || p.minItems != null ||
 | 
			
		||||
                    p.pattern != null) {
 | 
			
		||||
@ -2279,28 +2355,28 @@ public class DefaultCodegen {
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isString)) {
 | 
			
		||||
            p.example = p.paramName + "_example";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isBoolean)) {
 | 
			
		||||
            p.example = new String("true");
 | 
			
		||||
            p.example = "true";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isLong)) {
 | 
			
		||||
            p.example = new String("789");
 | 
			
		||||
            p.example = "789";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isInteger)) {
 | 
			
		||||
            p.example = new String("56");
 | 
			
		||||
            p.example = "56";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isFloat)) {
 | 
			
		||||
            p.example = new String("3.4");
 | 
			
		||||
            p.example = "3.4";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isDouble)) {
 | 
			
		||||
            p.example = new String("1.2");
 | 
			
		||||
            p.example = "1.2";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isBinary)) {
 | 
			
		||||
            p.example = new String("BINARY_DATA_HERE");
 | 
			
		||||
            p.example = "BINARY_DATA_HERE";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isByteArray)) {
 | 
			
		||||
            p.example = new String("B");
 | 
			
		||||
            p.example = "B";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isDate)) {
 | 
			
		||||
            p.example = new String("2013-10-20");
 | 
			
		||||
            p.example = "2013-10-20";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isDateTime)) {
 | 
			
		||||
            p.example = new String("2013-10-20T19:20:30+01:00");
 | 
			
		||||
            p.example = "2013-10-20T19:20:30+01:00";
 | 
			
		||||
        } else if (param instanceof FormParameter &&
 | 
			
		||||
                ("file".equalsIgnoreCase(((FormParameter) param).getType()) ||
 | 
			
		||||
                "file".equals(p.baseType))) {
 | 
			
		||||
            p.isFile = true;
 | 
			
		||||
            p.example = new String("/path/to/file.txt");
 | 
			
		||||
            p.example = "/path/to/file.txt";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // set the parameter excample value
 | 
			
		||||
@ -2455,8 +2531,7 @@ public class DefaultCodegen {
 | 
			
		||||
                // must be root tmpPath
 | 
			
		||||
                builder.append("root");
 | 
			
		||||
            }
 | 
			
		||||
            for (int i = 0; i < parts.length; i++) {
 | 
			
		||||
                String part = parts[i];
 | 
			
		||||
            for (String part : parts) {
 | 
			
		||||
                if (part.length() > 0) {
 | 
			
		||||
                    if (builder.toString().length() == 0) {
 | 
			
		||||
                        part = Character.toLowerCase(part.charAt(0)) + part.substring(1);
 | 
			
		||||
@ -2511,10 +2586,10 @@ public class DefaultCodegen {
 | 
			
		||||
        if (objs != null) {
 | 
			
		||||
            for (int i = 0; i < objs.size(); i++) {
 | 
			
		||||
                if (i > 0) {
 | 
			
		||||
                    objs.get(i).secondaryParam = new Boolean(true);
 | 
			
		||||
                    objs.get(i).secondaryParam = true;
 | 
			
		||||
                }
 | 
			
		||||
                if (i < objs.size() - 1) {
 | 
			
		||||
                    objs.get(i).hasMore = new Boolean(true);
 | 
			
		||||
                    objs.get(i).hasMore = true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@ -2525,7 +2600,7 @@ public class DefaultCodegen {
 | 
			
		||||
        if (objs != null) {
 | 
			
		||||
            for (int i = 0; i < objs.size() - 1; i++) {
 | 
			
		||||
                if (i > 0) {
 | 
			
		||||
                    objs.put("secondaryParam", new Boolean(true));
 | 
			
		||||
                    objs.put("secondaryParam", true);
 | 
			
		||||
                }
 | 
			
		||||
                if (i < objs.size() - 1) {
 | 
			
		||||
                    objs.put("hasMore", true);
 | 
			
		||||
@ -3097,7 +3172,7 @@ public class DefaultCodegen {
 | 
			
		||||
     */
 | 
			
		||||
    public void setParameterBooleanFlagWithCodegenProperty(CodegenParameter parameter, CodegenProperty property) {
 | 
			
		||||
        if (parameter == null) {
 | 
			
		||||
            LOGGER.error("Codegen Parameter cannnot be null.");
 | 
			
		||||
            LOGGER.error("Codegen Parameter cannot be null.");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -3199,4 +3274,19 @@ public class DefaultCodegen {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If the pattern misses the delimiter, add "/" to the beginning and end
 | 
			
		||||
     * Otherwise, return the original pattern
 | 
			
		||||
     *
 | 
			
		||||
     * @param pattern the pattern (regular expression)
 | 
			
		||||
     * @return the pattern with delimiter
 | 
			
		||||
     */
 | 
			
		||||
    public String addRegularExpressionDelimiter(String pattern) {
 | 
			
		||||
        if (pattern != null && !pattern.matches("^/.*")) {
 | 
			
		||||
            return "/" + pattern + "/";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return pattern;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -140,6 +140,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
 | 
			
		||||
 | 
			
		||||
        config.additionalProperties().put("generatedDate", DateTime.now().toString());
 | 
			
		||||
        config.additionalProperties().put("generatorClass", config.getClass().toString());
 | 
			
		||||
        config.additionalProperties().put("inputSpec", config.getInputSpec());
 | 
			
		||||
        
 | 
			
		||||
        if (swagger.getInfo() != null) {
 | 
			
		||||
            Info info = swagger.getInfo();
 | 
			
		||||
@ -153,7 +154,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
 | 
			
		||||
            if (StringUtils.isEmpty(info.getDescription())) {
 | 
			
		||||
                // set a default description if none if provided
 | 
			
		||||
                config.additionalProperties().put("appDescription",
 | 
			
		||||
                        "No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)");
 | 
			
		||||
                        "No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)");
 | 
			
		||||
            } else {
 | 
			
		||||
                config.additionalProperties().put("appDescription",
 | 
			
		||||
                        config.escapeText(info.getDescription()));
 | 
			
		||||
@ -280,6 +281,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
 | 
			
		||||
                    try {
 | 
			
		||||
                        //don't generate models that have an import mapping
 | 
			
		||||
                        if(config.importMapping().containsKey(name)) {
 | 
			
		||||
                            LOGGER.info("Model " + name + " not imported due to import mapping");
 | 
			
		||||
                            continue;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
@ -411,7 +413,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
 | 
			
		||||
                    // Pass sortParamsByRequiredFlag through to the Mustache template...
 | 
			
		||||
                    boolean sortParamsByRequiredFlag = true;
 | 
			
		||||
                    if (this.config.additionalProperties().containsKey(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG)) {
 | 
			
		||||
                        sortParamsByRequiredFlag = Boolean.valueOf((String)this.config.additionalProperties().get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG).toString());
 | 
			
		||||
                        sortParamsByRequiredFlag = Boolean.valueOf(this.config.additionalProperties().get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG).toString());
 | 
			
		||||
                    }
 | 
			
		||||
                    operation.put("sortParamsByRequiredFlag", sortParamsByRequiredFlag);
 | 
			
		||||
 | 
			
		||||
@ -505,6 +507,13 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
 | 
			
		||||
        bundle.put("modelPackage", config.modelPackage());
 | 
			
		||||
        List<CodegenSecurity> authMethods = config.fromSecurity(swagger.getSecurityDefinitions());
 | 
			
		||||
        if (authMethods != null && !authMethods.isEmpty()) {
 | 
			
		||||
            // sort auth methods to maintain the same order
 | 
			
		||||
            Collections.sort(authMethods, new Comparator<CodegenSecurity>() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public int compare(CodegenSecurity one, CodegenSecurity another) {
 | 
			
		||||
                    return ObjectUtils.compare(one.name, another.name);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            bundle.put("authMethods", authMethods);
 | 
			
		||||
            bundle.put("hasAuthMethods", true);
 | 
			
		||||
        }
 | 
			
		||||
@ -559,7 +568,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
 | 
			
		||||
                        if(ignoreProcessor.allowsFile(new File(outputFilename))) {
 | 
			
		||||
                            if (templateFile.endsWith("mustache")) {
 | 
			
		||||
                                String template = readTemplate(templateFile);
 | 
			
		||||
                                Template tmpl = Mustache.compiler()
 | 
			
		||||
                                Mustache.Compiler compiler = Mustache.compiler();
 | 
			
		||||
                                compiler = config.processCompiler(compiler);                                
 | 
			
		||||
                                Template tmpl = compiler
 | 
			
		||||
                                        .withLoader(new Mustache.TemplateLoader() {
 | 
			
		||||
                                            @Override
 | 
			
		||||
                                            public Reader getTemplate(String name) {
 | 
			
		||||
@ -640,7 +651,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
 | 
			
		||||
        if(ignoreProcessor.allowsFile(new File(outputFilename.replaceAll("//", "/")))) {
 | 
			
		||||
            String templateFile = getFullTemplateFile(config, templateName);
 | 
			
		||||
            String template = readTemplate(templateFile);
 | 
			
		||||
            Template tmpl = Mustache.compiler()
 | 
			
		||||
            Mustache.Compiler compiler = Mustache.compiler();
 | 
			
		||||
            compiler = config.processCompiler(compiler);                                
 | 
			
		||||
            Template tmpl = compiler
 | 
			
		||||
                    .withLoader(new Mustache.TemplateLoader() {
 | 
			
		||||
                        @Override
 | 
			
		||||
                        public Reader getTemplate(String name) {
 | 
			
		||||
 | 
			
		||||
@ -45,27 +45,26 @@ public class InlineModelResolver {
 | 
			
		||||
                                BodyParameter bp = (BodyParameter) parameter;
 | 
			
		||||
                                if (bp.getSchema() != null) {
 | 
			
		||||
                                    Model model = bp.getSchema();
 | 
			
		||||
                                    if(model instanceof ModelImpl) {
 | 
			
		||||
                                    if (model instanceof ModelImpl) {
 | 
			
		||||
                                        ModelImpl obj = (ModelImpl) model;
 | 
			
		||||
                                        if (obj.getType() == null || "object".equals(obj.getType())) {
 | 
			
		||||
                                            if (obj.getProperties() != null && obj.getProperties().size() > 0) {
 | 
			
		||||
                                                flattenProperties(obj.getProperties(), pathname);
 | 
			
		||||
                                                String modelName = resolveModelName( obj.getTitle(), bp.getName());
 | 
			
		||||
                                                String modelName = resolveModelName(obj.getTitle(), bp.getName());
 | 
			
		||||
                                                bp.setSchema(new RefModel(modelName));
 | 
			
		||||
                                                addGenerated(modelName, model);
 | 
			
		||||
                                                swagger.addDefinition(modelName, model);
 | 
			
		||||
                                            }
 | 
			
		||||
                                        }
 | 
			
		||||
                                    }
 | 
			
		||||
                                    else if (model instanceof ArrayModel) {
 | 
			
		||||
                                    } else if (model instanceof ArrayModel) {
 | 
			
		||||
                                        ArrayModel am = (ArrayModel) model;
 | 
			
		||||
                                        Property inner = am.getItems();
 | 
			
		||||
 | 
			
		||||
                                        if(inner instanceof ObjectProperty) {
 | 
			
		||||
                                        if (inner instanceof ObjectProperty) {
 | 
			
		||||
                                            ObjectProperty op = (ObjectProperty) inner;
 | 
			
		||||
                                            if (op.getProperties() != null && op.getProperties().size() > 0) {
 | 
			
		||||
                                                flattenProperties(op.getProperties(), pathname);
 | 
			
		||||
                                                String modelName = resolveModelName( op.getTitle(), bp.getName());
 | 
			
		||||
                                                String modelName = resolveModelName(op.getTitle(), bp.getName());
 | 
			
		||||
                                                Model innerModel = modelFromProperty(op, modelName);
 | 
			
		||||
                                                String existing = matchGenerated(innerModel);
 | 
			
		||||
                                                if (existing != null) {
 | 
			
		||||
@ -91,13 +90,13 @@ public class InlineModelResolver {
 | 
			
		||||
                                if (property instanceof ObjectProperty) {
 | 
			
		||||
                                    ObjectProperty op = (ObjectProperty) property;
 | 
			
		||||
                                    if (op.getProperties() != null && op.getProperties().size() > 0) {
 | 
			
		||||
					String modelName = resolveModelName( op.getTitle(),"inline_response_" + key);
 | 
			
		||||
                                        String modelName = resolveModelName(op.getTitle(), "inline_response_" + key);
 | 
			
		||||
                                        Model model = modelFromProperty(op, modelName);
 | 
			
		||||
                                        String existing = matchGenerated(model);
 | 
			
		||||
                                        if (existing != null) {
 | 
			
		||||
                                            response.setSchema(new RefProperty(existing));
 | 
			
		||||
                                            response.setSchema(this.makeRefProperty(existing, property));
 | 
			
		||||
                                        } else {
 | 
			
		||||
                                            response.setSchema(new RefProperty(modelName));
 | 
			
		||||
                                            response.setSchema(this.makeRefProperty(modelName, property));
 | 
			
		||||
                                            addGenerated(modelName, model);
 | 
			
		||||
                                            swagger.addDefinition(modelName, model);
 | 
			
		||||
                                        }
 | 
			
		||||
@ -106,17 +105,18 @@ public class InlineModelResolver {
 | 
			
		||||
                                    ArrayProperty ap = (ArrayProperty) property;
 | 
			
		||||
                                    Property inner = ap.getItems();
 | 
			
		||||
 | 
			
		||||
                                    if(inner instanceof ObjectProperty) {
 | 
			
		||||
                                    if (inner instanceof ObjectProperty) {
 | 
			
		||||
                                        ObjectProperty op = (ObjectProperty) inner;
 | 
			
		||||
                                        if (op.getProperties() != null && op.getProperties().size() > 0) {
 | 
			
		||||
                                            flattenProperties(op.getProperties(), pathname);
 | 
			
		||||
					String modelName = resolveModelName( op.getTitle(),"inline_response_" + key);
 | 
			
		||||
                                            String modelName = resolveModelName(op.getTitle(),
 | 
			
		||||
                                                    "inline_response_" + key);
 | 
			
		||||
                                            Model innerModel = modelFromProperty(op, modelName);
 | 
			
		||||
                                            String existing = matchGenerated(innerModel);
 | 
			
		||||
                                            if (existing != null) {
 | 
			
		||||
                                            	ap.setItems(new RefProperty(existing));
 | 
			
		||||
                                                ap.setItems(this.makeRefProperty(existing, op));
 | 
			
		||||
                                            } else {
 | 
			
		||||
                                                ap.setItems(new RefProperty(modelName));
 | 
			
		||||
                                                ap.setItems(this.makeRefProperty(modelName, op));
 | 
			
		||||
                                                addGenerated(modelName, innerModel);
 | 
			
		||||
                                                swagger.addDefinition(modelName, innerModel);
 | 
			
		||||
                                            }
 | 
			
		||||
@ -126,11 +126,12 @@ public class InlineModelResolver {
 | 
			
		||||
                                    MapProperty mp = (MapProperty) property;
 | 
			
		||||
 | 
			
		||||
                                    Property innerProperty = mp.getAdditionalProperties();
 | 
			
		||||
                                    if(innerProperty instanceof ObjectProperty) {
 | 
			
		||||
                                    if (innerProperty instanceof ObjectProperty) {
 | 
			
		||||
                                        ObjectProperty op = (ObjectProperty) innerProperty;
 | 
			
		||||
                                        if (op.getProperties() != null && op.getProperties().size() > 0) {
 | 
			
		||||
                                            flattenProperties(op.getProperties(), pathname);
 | 
			
		||||
					String modelName = resolveModelName( op.getTitle(),"inline_response_" + key);
 | 
			
		||||
                                            String modelName = resolveModelName(op.getTitle(),
 | 
			
		||||
                                                    "inline_response_" + key);
 | 
			
		||||
                                            Model innerModel = modelFromProperty(op, modelName);
 | 
			
		||||
                                            String existing = matchGenerated(innerModel);
 | 
			
		||||
                                            if (existing != null) {
 | 
			
		||||
@ -167,7 +168,7 @@ public class InlineModelResolver {
 | 
			
		||||
                    if (inner instanceof ObjectProperty) {
 | 
			
		||||
                        ObjectProperty op = (ObjectProperty) inner;
 | 
			
		||||
                        if (op.getProperties() != null && op.getProperties().size() > 0) {
 | 
			
		||||
                            String innerModelName = uniqueName(modelName + "_inner");
 | 
			
		||||
                            String innerModelName = resolveModelName(op.getTitle(), modelName + "_inner");
 | 
			
		||||
                            Model innerModel = modelFromProperty(op, innerModelName);
 | 
			
		||||
                            String existing = matchGenerated(innerModel);
 | 
			
		||||
                            if (existing == null) {
 | 
			
		||||
@ -179,16 +180,19 @@ public class InlineModelResolver {
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                } else if (model instanceof ComposedModel) {
 | 
			
		||||
                    ComposedModel m = (ComposedModel) model;
 | 
			
		||||
                    Map<String, Property> properties = m.getChild().getProperties();
 | 
			
		||||
                    flattenProperties(properties, modelName);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String resolveModelName(String title, String key ) {
 | 
			
		||||
    private String resolveModelName(String title, String key) {
 | 
			
		||||
        if (title == null) {
 | 
			
		||||
            return uniqueName(key);
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
        } else {
 | 
			
		||||
            return uniqueName(title);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -211,7 +215,11 @@ public class InlineModelResolver {
 | 
			
		||||
    public String uniqueName(String key) {
 | 
			
		||||
        int count = 0;
 | 
			
		||||
        boolean done = false;
 | 
			
		||||
        key = key.replaceAll("[^a-z_\\.A-Z0-9 ]", ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
 | 
			
		||||
        key = key.replaceAll("[^a-z_\\.A-Z0-9 ]", ""); // FIXME: a parameter
 | 
			
		||||
                                                       // should not be
 | 
			
		||||
                                                       // assigned. Also declare
 | 
			
		||||
                                                       // the methods parameters
 | 
			
		||||
                                                       // as 'final'.
 | 
			
		||||
        while (!done) {
 | 
			
		||||
            String name = key;
 | 
			
		||||
            if (count > 0) {
 | 
			
		||||
@ -235,12 +243,12 @@ public class InlineModelResolver {
 | 
			
		||||
        Map<String, Model> modelsToAdd = new HashMap<String, Model>();
 | 
			
		||||
        for (String key : properties.keySet()) {
 | 
			
		||||
            Property property = properties.get(key);
 | 
			
		||||
            if (property instanceof ObjectProperty &&
 | 
			
		||||
                    ((ObjectProperty)property).getProperties() != null &&
 | 
			
		||||
                    ((ObjectProperty)property).getProperties().size() > 0) {
 | 
			
		||||
                String modelName = uniqueName(path + "_" + key);
 | 
			
		||||
            if (property instanceof ObjectProperty && ((ObjectProperty) property).getProperties() != null
 | 
			
		||||
                    && ((ObjectProperty) property).getProperties().size() > 0) {
 | 
			
		||||
 | 
			
		||||
                ObjectProperty op = (ObjectProperty) property;
 | 
			
		||||
 | 
			
		||||
                String modelName = resolveModelName(op.getTitle(), path + "_" + key);
 | 
			
		||||
                Model model = modelFromProperty(op, modelName);
 | 
			
		||||
 | 
			
		||||
                String existing = matchGenerated(model);
 | 
			
		||||
@ -261,7 +269,7 @@ public class InlineModelResolver {
 | 
			
		||||
                    ObjectProperty op = (ObjectProperty) inner;
 | 
			
		||||
                    if (op.getProperties() != null && op.getProperties().size() > 0) {
 | 
			
		||||
                        flattenProperties(op.getProperties(), path);
 | 
			
		||||
                        String modelName = uniqueName(path + "_" + key);
 | 
			
		||||
                        String modelName = resolveModelName(op.getTitle(), path + "_" + key);
 | 
			
		||||
                        Model innerModel = modelFromProperty(op, modelName);
 | 
			
		||||
                        String existing = matchGenerated(innerModel);
 | 
			
		||||
                        if (existing != null) {
 | 
			
		||||
@ -281,7 +289,7 @@ public class InlineModelResolver {
 | 
			
		||||
                    ObjectProperty op = (ObjectProperty) inner;
 | 
			
		||||
                    if (op.getProperties() != null && op.getProperties().size() > 0) {
 | 
			
		||||
                        flattenProperties(op.getProperties(), path);
 | 
			
		||||
                        String modelName = uniqueName(path + "_" + key);
 | 
			
		||||
                        String modelName = resolveModelName(op.getTitle(), path + "_" + key);
 | 
			
		||||
                        Model innerModel = modelFromProperty(op, modelName);
 | 
			
		||||
                        String existing = matchGenerated(innerModel);
 | 
			
		||||
                        if (existing != null) {
 | 
			
		||||
@ -312,9 +320,10 @@ public class InlineModelResolver {
 | 
			
		||||
        String example = null;
 | 
			
		||||
 | 
			
		||||
        Object obj = object.getExample();
 | 
			
		||||
        if(obj != null) {
 | 
			
		||||
        if (obj != null) {
 | 
			
		||||
            example = obj.toString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Property inner = object.getItems();
 | 
			
		||||
        if (inner instanceof ObjectProperty) {
 | 
			
		||||
            ArrayModel model = new ArrayModel();
 | 
			
		||||
@ -323,6 +332,7 @@ public class InlineModelResolver {
 | 
			
		||||
            model.setItems(object.getItems());
 | 
			
		||||
            return model;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -331,7 +341,7 @@ public class InlineModelResolver {
 | 
			
		||||
        String example = null;
 | 
			
		||||
 | 
			
		||||
        Object obj = object.getExample();
 | 
			
		||||
        if(obj != null) {
 | 
			
		||||
        if (obj != null) {
 | 
			
		||||
            example = obj.toString();
 | 
			
		||||
        }
 | 
			
		||||
        String name = object.getName();
 | 
			
		||||
@ -358,7 +368,7 @@ public class InlineModelResolver {
 | 
			
		||||
        String example = null;
 | 
			
		||||
 | 
			
		||||
        Object obj = object.getExample();
 | 
			
		||||
        if(obj != null) {
 | 
			
		||||
        if (obj != null) {
 | 
			
		||||
            example = obj.toString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -370,6 +380,32 @@ public class InlineModelResolver {
 | 
			
		||||
        return model;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Make a RefProperty
 | 
			
		||||
     * 
 | 
			
		||||
     * @param ref
 | 
			
		||||
     * @param property
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public Property makeRefProperty(String ref, Property property) {
 | 
			
		||||
        RefProperty newProperty = new RefProperty(ref);
 | 
			
		||||
        this.copyVendorExtensions(property, newProperty);
 | 
			
		||||
        return newProperty;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Copy vendor extensions from Property to another Property
 | 
			
		||||
     * 
 | 
			
		||||
     * @param source
 | 
			
		||||
     * @param target
 | 
			
		||||
     */
 | 
			
		||||
    public void copyVendorExtensions(Property source, AbstractProperty target) {
 | 
			
		||||
        Map<String, Object> vendorExtensions = source.getVendorExtensions();
 | 
			
		||||
        for (String extName : vendorExtensions.keySet()) {
 | 
			
		||||
            target.setVendorExtension(extName, vendorExtensions.get(extName));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isSkipMatches() {
 | 
			
		||||
        return skipMatches;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,6 @@ import java.io.IOException;
 | 
			
		||||
import java.io.Reader;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.ServiceLoader;
 | 
			
		||||
@ -40,9 +39,8 @@ public class MetaGenerator extends AbstractGenerator {
 | 
			
		||||
    public static List<CodegenConfig> getExtensions() {
 | 
			
		||||
        ServiceLoader<CodegenConfig> loader = ServiceLoader.load(CodegenConfig.class);
 | 
			
		||||
        List<CodegenConfig> output = new ArrayList<CodegenConfig>();
 | 
			
		||||
        Iterator<CodegenConfig> itr = loader.iterator();
 | 
			
		||||
        while (itr.hasNext()) {
 | 
			
		||||
            output.add(itr.next());
 | 
			
		||||
        for (CodegenConfig config : loader) {
 | 
			
		||||
            output.add(config);
 | 
			
		||||
        }
 | 
			
		||||
        return output;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -151,7 +151,7 @@ public class CodegenConfigurator {
 | 
			
		||||
        File f = new File(templateDir);
 | 
			
		||||
 | 
			
		||||
        // check to see if the folder exists
 | 
			
		||||
        if (!(f != null && f.exists() && f.isDirectory())) {
 | 
			
		||||
        if (!(f.exists() && f.isDirectory())) {
 | 
			
		||||
            throw new IllegalArgumentException("Template directory " + templateDir + " does not exist."); 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -352,6 +352,7 @@ public class CodegenConfigurator {
 | 
			
		||||
 | 
			
		||||
        CodegenConfig config = CodegenConfigLoader.forName(lang);
 | 
			
		||||
 | 
			
		||||
        config.setInputSpec(inputSpec);
 | 
			
		||||
        config.setOutputDir(outputDir);
 | 
			
		||||
        config.setSkipOverwrite(skipOverwrite);
 | 
			
		||||
 | 
			
		||||
@ -413,7 +414,7 @@ public class CodegenConfigurator {
 | 
			
		||||
                codegenConfig.additionalProperties().put(opt, dynamicProperties.get(opt));
 | 
			
		||||
            }
 | 
			
		||||
            else if(systemProperties.containsKey(opt)) {
 | 
			
		||||
                codegenConfig.additionalProperties().put(opt, systemProperties.get(opt).toString());
 | 
			
		||||
                codegenConfig.additionalProperties().put(opt, systemProperties.get(opt));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -99,15 +99,15 @@ public class ExampleGenerator {
 | 
			
		||||
        } else if (property instanceof DecimalProperty) {
 | 
			
		||||
            return new BigDecimal(1.3579);
 | 
			
		||||
        } else if (property instanceof DoubleProperty) {
 | 
			
		||||
            return new Double(3.149);
 | 
			
		||||
            return 3.149;
 | 
			
		||||
        } else if (property instanceof FileProperty) {
 | 
			
		||||
            return "";  // TODO
 | 
			
		||||
        } else if (property instanceof FloatProperty) {
 | 
			
		||||
            return new Float(1.23);
 | 
			
		||||
            return 1.23f;
 | 
			
		||||
        } else if (property instanceof IntegerProperty) {
 | 
			
		||||
            return new Integer(123);
 | 
			
		||||
            return 123;
 | 
			
		||||
        } else if (property instanceof LongProperty) {
 | 
			
		||||
            return new Long(123456789);
 | 
			
		||||
            return 123456789L;
 | 
			
		||||
        } else if (property instanceof MapProperty) {
 | 
			
		||||
            Map<String, Object> mp = new HashMap<String, Object>();
 | 
			
		||||
            if (property.getName() != null) {
 | 
			
		||||
 | 
			
		||||
@ -26,10 +26,8 @@ public abstract class Rule {
 | 
			
		||||
        if(syntax == null) return this.definition;
 | 
			
		||||
 | 
			
		||||
        StringBuilder sb = new StringBuilder();
 | 
			
		||||
        for (int i = 0; i < syntax.size(); i++) {
 | 
			
		||||
            Part current = syntax.get(i);
 | 
			
		||||
 | 
			
		||||
            switch(current.getToken()){
 | 
			
		||||
        for (Part current : syntax) {
 | 
			
		||||
            switch (current.getToken()) {
 | 
			
		||||
                case MATCH_ALL:
 | 
			
		||||
                case MATCH_ANY:
 | 
			
		||||
                case ESCAPED_EXCLAMATION:
 | 
			
		||||
 | 
			
		||||
@ -41,6 +41,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
 | 
			
		||||
    public AbstractCSharpCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // C# does not use import mapping
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        outputFolder = "generated-code" + File.separator + this.getName();
 | 
			
		||||
        embeddedTemplateDir = templateDir = this.getName();
 | 
			
		||||
 | 
			
		||||
@ -463,7 +466,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            StringProperty dp = (StringProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return "\"" + dp.getDefault().toString() + "\"";
 | 
			
		||||
                return "\"" + dp.getDefault() + "\"";
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            BooleanProperty dp = (BooleanProperty) p;
 | 
			
		||||
 | 
			
		||||
@ -6,6 +6,7 @@ import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.ListIterator;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.regex.Pattern;
 | 
			
		||||
 | 
			
		||||
@ -244,10 +245,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
 | 
			
		||||
        importMapping.put("ApiModelProperty", "io.swagger.annotations.ApiModelProperty");
 | 
			
		||||
        importMapping.put("ApiModel", "io.swagger.annotations.ApiModel");
 | 
			
		||||
        importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
 | 
			
		||||
        importMapping.put("JsonCreator", "com.fasterxml.jackson.annotation.JsonCreator");
 | 
			
		||||
        importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue");
 | 
			
		||||
        importMapping.put("SerializedName", "com.google.gson.annotations.SerializedName");
 | 
			
		||||
        importMapping.put("Objects", "java.util.Objects");
 | 
			
		||||
        importMapping.put("StringUtil", invokerPackage + ".StringUtil");
 | 
			
		||||
        // import JsonCreator if JsonProperty is imported
 | 
			
		||||
        // used later in recursive import in postProcessingModels
 | 
			
		||||
        importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator");
 | 
			
		||||
 | 
			
		||||
        if(additionalProperties.containsKey(DATE_LIBRARY)) {
 | 
			
		||||
            setDateLibrary(additionalProperties.get("dateLibrary").toString());
 | 
			
		||||
@ -346,7 +351,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
 | 
			
		||||
        name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
 | 
			
		||||
 | 
			
		||||
        if ("class".equals(name.toLowerCase())) {
 | 
			
		||||
            return "PropertyClass";
 | 
			
		||||
            return "propertyClass";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if("_".equals(name)) {
 | 
			
		||||
@ -597,7 +602,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
 | 
			
		||||
        if(codegenModel.description != null) {
 | 
			
		||||
            codegenModel.imports.add("ApiModel");
 | 
			
		||||
        }
 | 
			
		||||
        if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
 | 
			
		||||
        if (allDefinitions != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
 | 
			
		||||
            final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
 | 
			
		||||
            final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
 | 
			
		||||
            codegenModel = AbstractJavaCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
 | 
			
		||||
@ -638,6 +643,23 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessModels(Map<String, Object> objs) {
 | 
			
		||||
        // recursively add import for mapping one type to multiple imports
 | 
			
		||||
        List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
 | 
			
		||||
        if (recursiveImports == null)
 | 
			
		||||
            return objs;
 | 
			
		||||
 | 
			
		||||
        ListIterator<Map<String, String>> listIterator = recursiveImports.listIterator();
 | 
			
		||||
        while (listIterator.hasNext()) {
 | 
			
		||||
            String _import = listIterator.next().get("import");
 | 
			
		||||
            // if the import package happens to be found in the importMapping (key)
 | 
			
		||||
            // add the corresponding import package to the list
 | 
			
		||||
            if (importMapping.containsKey(_import)) {
 | 
			
		||||
                Map<String, String> newImportMap= new HashMap<String, String>();
 | 
			
		||||
                newImportMap.put("import", importMapping.get(_import));
 | 
			
		||||
                listIterator.add(newImportMap);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return postProcessModelsEnum(objs);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -729,6 +751,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toEnumVarName(String value, String datatype) {
 | 
			
		||||
        // for symbol, e.g. $, #
 | 
			
		||||
        if (getSymbolName(value) != null) {
 | 
			
		||||
            return getSymbolName(value).toUpperCase();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // number
 | 
			
		||||
        if ("Integer".equals(datatype) || "Long".equals(datatype) ||
 | 
			
		||||
            "Float".equals(datatype) || "Double".equals(datatype)) {
 | 
			
		||||
 | 
			
		||||
@ -33,6 +33,8 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
 | 
			
		||||
        modelPackage = "io.swagger.model";
 | 
			
		||||
 | 
			
		||||
        additionalProperties.put("title", title);
 | 
			
		||||
        // java inflector uses the jackson lib
 | 
			
		||||
        additionalProperties.put("jackson", "true");
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption("title", "a title describing the application"));
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,646 @@
 | 
			
		||||
package io.swagger.codegen.languages;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.CliOption;
 | 
			
		||||
import io.swagger.codegen.CodegenConfig;
 | 
			
		||||
import io.swagger.codegen.CodegenConstants;
 | 
			
		||||
import io.swagger.codegen.CodegenOperation;
 | 
			
		||||
import io.swagger.codegen.CodegenParameter;
 | 
			
		||||
import io.swagger.codegen.CodegenProperty;
 | 
			
		||||
import io.swagger.codegen.CodegenType;
 | 
			
		||||
import io.swagger.codegen.DefaultCodegen;
 | 
			
		||||
import io.swagger.codegen.SupportingFile;
 | 
			
		||||
import io.swagger.models.properties.*;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.regex.Matcher;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
 | 
			
		||||
public abstract class AbstractPhpCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    static Logger LOGGER = LoggerFactory.getLogger(AbstractPhpCodegen.class);
 | 
			
		||||
 | 
			
		||||
    public static final String VARIABLE_NAMING_CONVENTION = "variableNamingConvention";
 | 
			
		||||
    public static final String PACKAGE_PATH = "packagePath";
 | 
			
		||||
    public static final String SRC_BASE_PATH = "srcBasePath";
 | 
			
		||||
    // composerVendorName/composerProjectName has be replaced by gitUserId/gitRepoId. prepare to remove these.
 | 
			
		||||
    // public static final String COMPOSER_VENDOR_NAME = "composerVendorName";
 | 
			
		||||
    // public static final String COMPOSER_PROJECT_NAME = "composerProjectName";
 | 
			
		||||
    // protected String composerVendorName = null;
 | 
			
		||||
    // protected String composerProjectName = null;
 | 
			
		||||
    protected String invokerPackage = "php";
 | 
			
		||||
    protected String packagePath = "php-base";
 | 
			
		||||
    protected String artifactVersion = null;
 | 
			
		||||
    protected String srcBasePath = "lib";
 | 
			
		||||
    protected String testBasePath = "test";
 | 
			
		||||
    protected String docsBasePath = "docs";
 | 
			
		||||
    protected String apiDirName = "Api";
 | 
			
		||||
    protected String modelDirName = "Model";
 | 
			
		||||
    protected String variableNamingConvention= "snake_case";
 | 
			
		||||
    protected String apiDocPath = docsBasePath + "/" + apiDirName;
 | 
			
		||||
    protected String modelDocPath = docsBasePath + "/" + modelDirName;
 | 
			
		||||
 | 
			
		||||
    public AbstractPhpCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        modelTemplateFiles.put("model.mustache", ".php");
 | 
			
		||||
        apiTemplateFiles.put("api.mustache", ".php");
 | 
			
		||||
        apiTestTemplateFiles.put("api_test.mustache", ".php");
 | 
			
		||||
        modelDocTemplateFiles.put("model_doc.mustache", ".md");
 | 
			
		||||
        apiDocTemplateFiles.put("api_doc.mustache", ".md");
 | 
			
		||||
       
 | 
			
		||||
        apiPackage = invokerPackage + "\\" + apiDirName;
 | 
			
		||||
        modelPackage = invokerPackage + "\\" + modelDirName;
 | 
			
		||||
 | 
			
		||||
        setReservedWordsLowerCase(
 | 
			
		||||
                Arrays.asList(
 | 
			
		||||
                    // local variables used in api methods (endpoints)
 | 
			
		||||
                    "resourcePath", "httpBody", "queryParams", "headerParams",
 | 
			
		||||
                    "formParams", "_header_accept", "_tempBody",
 | 
			
		||||
 | 
			
		||||
                    // PHP reserved words
 | 
			
		||||
                    "__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        // ref: http://php.net/manual/en/language.types.intro.php
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>(
 | 
			
		||||
                Arrays.asList(
 | 
			
		||||
                        "bool",
 | 
			
		||||
                        "boolean",
 | 
			
		||||
                        "int",
 | 
			
		||||
                        "integer",
 | 
			
		||||
                        "double",
 | 
			
		||||
                        "float",
 | 
			
		||||
                        "string",
 | 
			
		||||
                        "object",
 | 
			
		||||
                        "DateTime",
 | 
			
		||||
                        "mixed",
 | 
			
		||||
                        "number",
 | 
			
		||||
                        "void",
 | 
			
		||||
                        "byte")
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        instantiationTypes.put("array", "array");
 | 
			
		||||
        instantiationTypes.put("map", "map");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // provide primitives to mustache template
 | 
			
		||||
        String primitives = "'" + StringUtils.join(languageSpecificPrimitives, "', '") + "'";
 | 
			
		||||
        additionalProperties.put("primitives", primitives);
 | 
			
		||||
 | 
			
		||||
        // ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
 | 
			
		||||
        typeMapping = new HashMap<String, String>();
 | 
			
		||||
        typeMapping.put("integer", "int");
 | 
			
		||||
        typeMapping.put("long", "int");
 | 
			
		||||
        typeMapping.put("number", "float");
 | 
			
		||||
        typeMapping.put("float", "float");
 | 
			
		||||
        typeMapping.put("double", "double");
 | 
			
		||||
        typeMapping.put("string", "string");
 | 
			
		||||
        typeMapping.put("byte", "int");
 | 
			
		||||
        typeMapping.put("boolean", "bool");
 | 
			
		||||
        typeMapping.put("Date", "\\DateTime");
 | 
			
		||||
        typeMapping.put("DateTime", "\\DateTime");
 | 
			
		||||
        typeMapping.put("file", "\\SplFileObject");
 | 
			
		||||
        typeMapping.put("map", "map");
 | 
			
		||||
        typeMapping.put("array", "array");
 | 
			
		||||
        typeMapping.put("list", "array");
 | 
			
		||||
        typeMapping.put("object", "object");
 | 
			
		||||
        typeMapping.put("binary", "string");
 | 
			
		||||
        typeMapping.put("ByteArray", "string");
 | 
			
		||||
        typeMapping.put("UUID", "string");
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(VARIABLE_NAMING_CONVENTION, "naming convention of variable name, e.g. camelCase.")
 | 
			
		||||
                .defaultValue("snake_case"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay\\Pets"));
 | 
			
		||||
        cliOptions.add(new CliOption(PACKAGE_PATH, "The main package name for classes. e.g. GeneratedPetstore"));
 | 
			
		||||
        cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory under packagePath to serve as source root."));
 | 
			
		||||
        // cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next swagger-codegen release"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.GIT_USER_ID, CodegenConstants.GIT_USER_ID_DESC));
 | 
			
		||||
        // cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next swagger-codegen release"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(PACKAGE_PATH)) {
 | 
			
		||||
            this.setPackagePath((String) additionalProperties.get(PACKAGE_PATH));
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(PACKAGE_PATH, packagePath);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(SRC_BASE_PATH)) {
 | 
			
		||||
            this.setSrcBasePath((String) additionalProperties.get(SRC_BASE_PATH));
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(SRC_BASE_PATH, srcBasePath);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
 | 
			
		||||
            this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
 | 
			
		||||
        //     this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
 | 
			
		||||
        // } else {
 | 
			
		||||
        //     additionalProperties.put(COMPOSER_PROJECT_NAME, composerProjectName);
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(CodegenConstants.GIT_USER_ID)) {
 | 
			
		||||
            this.setGitUserId((String) additionalProperties.get(CodegenConstants.GIT_USER_ID));
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.GIT_USER_ID, gitUserId);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // if (additionalProperties.containsKey(COMPOSER_VENDOR_NAME)) {
 | 
			
		||||
        //     this.setComposerVendorName((String) additionalProperties.get(COMPOSER_VENDOR_NAME));
 | 
			
		||||
        // } else {
 | 
			
		||||
        //     additionalProperties.put(COMPOSER_VENDOR_NAME, composerVendorName);
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(CodegenConstants.GIT_REPO_ID)) {
 | 
			
		||||
            this.setGitRepoId((String) additionalProperties.get(CodegenConstants.GIT_REPO_ID));
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.GIT_REPO_ID, gitRepoId);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
 | 
			
		||||
            this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(VARIABLE_NAMING_CONVENTION)) {
 | 
			
		||||
            this.setParameterNamingConvention((String) additionalProperties.get(VARIABLE_NAMING_CONVENTION));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));
 | 
			
		||||
 | 
			
		||||
        // make api and model doc path available in mustache template
 | 
			
		||||
        additionalProperties.put("apiDocPath", apiDocPath);
 | 
			
		||||
        additionalProperties.put("modelDocPath", modelDocPath);
 | 
			
		||||
 | 
			
		||||
        // make test path available in mustache template
 | 
			
		||||
        additionalProperties.put("testBasePath", testBasePath);
 | 
			
		||||
 | 
			
		||||
        // // apache v2 license
 | 
			
		||||
        // supportingFiles.add(new SupportingFile("LICENSE", getPackagePath(), "LICENSE"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPackagePath() {
 | 
			
		||||
        return packagePath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String toPackagePath(String packageName, String basePath) {
 | 
			
		||||
        packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
 | 
			
		||||
        if (basePath != null && basePath.length() > 0) {
 | 
			
		||||
            basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        String regFirstPathSeparator;
 | 
			
		||||
        if ("/".equals(File.separator)) { // for mac, linux
 | 
			
		||||
            regFirstPathSeparator = "^/";
 | 
			
		||||
        } else { // for windows
 | 
			
		||||
            regFirstPathSeparator = "^\\\\";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        String regLastPathSeparator;
 | 
			
		||||
        if ("/".equals(File.separator)) { // for mac, linux
 | 
			
		||||
            regLastPathSeparator = "/$";
 | 
			
		||||
        } else { // for windows
 | 
			
		||||
            regLastPathSeparator = "\\\\$";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return (getPackagePath() + File.separatorChar + basePath
 | 
			
		||||
                    // Replace period, backslash, forward slash with file separator in package name
 | 
			
		||||
                    + packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
 | 
			
		||||
                    // Trim prefix file separators from package path
 | 
			
		||||
                    .replaceAll(regFirstPathSeparator, ""))
 | 
			
		||||
                    // Trim trailing file separators from the overall path
 | 
			
		||||
                    .replaceAll(regLastPathSeparator+ "$", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeReservedWord(String name) {
 | 
			
		||||
        return "_" + name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiFileFolder() {
 | 
			
		||||
        return (outputFolder + "/" + toPackagePath(apiPackage, srcBasePath));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String modelFileFolder() {
 | 
			
		||||
        return (outputFolder + "/" + toPackagePath(modelPackage, srcBasePath));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiTestFileFolder() {
 | 
			
		||||
        return (outputFolder + "/" + getPackagePath() + "/" + testBasePath + "/" + apiDirName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String modelTestFileFolder() {
 | 
			
		||||
        return (outputFolder + "/" + getPackagePath() + "/" + testBasePath + "/" + modelDirName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiDocFileFolder() {
 | 
			
		||||
        return (outputFolder + "/" + getPackagePath() + "/" + apiDocPath);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String modelDocFileFolder() {
 | 
			
		||||
        return (outputFolder + "/" + getPackagePath() + "/" + modelDocPath);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toModelDocFilename(String name) {
 | 
			
		||||
        return toModelName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toApiDocFilename(String name) {
 | 
			
		||||
        return toApiName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getTypeDeclaration(inner) + "[]";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
            return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        } else if (p instanceof RefProperty) {
 | 
			
		||||
            String type = super.getTypeDeclaration(p);
 | 
			
		||||
            return (!languageSpecificPrimitives.contains(type))
 | 
			
		||||
                    ? "\\" + modelPackage + "\\" + type : type;
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(String name) {
 | 
			
		||||
        if (!languageSpecificPrimitives.contains(name)) {
 | 
			
		||||
            return "\\" + modelPackage + "\\" + name;
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSwaggerType(Property p) {
 | 
			
		||||
        String swaggerType = super.getSwaggerType(p);
 | 
			
		||||
        String type = null;
 | 
			
		||||
        if (typeMapping.containsKey(swaggerType)) {
 | 
			
		||||
            type = typeMapping.get(swaggerType);
 | 
			
		||||
            if (languageSpecificPrimitives.contains(type)) {
 | 
			
		||||
                return type;
 | 
			
		||||
            } else if (instantiationTypes.containsKey(type)) {
 | 
			
		||||
                return type;
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            type = swaggerType;
 | 
			
		||||
        }
 | 
			
		||||
        if (type == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        return toModelName(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setInvokerPackage(String invokerPackage) {
 | 
			
		||||
        this.invokerPackage = invokerPackage;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setArtifactVersion(String artifactVersion) {
 | 
			
		||||
        this.artifactVersion = artifactVersion;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPackagePath(String packagePath) {
 | 
			
		||||
        this.packagePath = packagePath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSrcBasePath(String srcBasePath) {
 | 
			
		||||
        this.srcBasePath = srcBasePath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setParameterNamingConvention(String variableNamingConvention) {
 | 
			
		||||
        this.variableNamingConvention = variableNamingConvention;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // public void setComposerVendorName(String composerVendorName) {
 | 
			
		||||
    //     this.composerVendorName = composerVendorName;
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    // public void setComposerProjectName(String composerProjectName) {
 | 
			
		||||
    //     this.composerProjectName = composerProjectName;
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toVarName(String name) {
 | 
			
		||||
        // sanitize name
 | 
			
		||||
        name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
 | 
			
		||||
 | 
			
		||||
        if ("camelCase".equals(variableNamingConvention)) {
 | 
			
		||||
          // return the name in camelCase style
 | 
			
		||||
          // phone_number => phoneNumber
 | 
			
		||||
          name =  camelize(name, true);
 | 
			
		||||
        } else { // default to snake case
 | 
			
		||||
          // return the name in underscore style
 | 
			
		||||
          // PhoneNumber => phone_number
 | 
			
		||||
          name =  underscore(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // parameter name starting with number won't compile
 | 
			
		||||
        // need to escape it by appending _ at the beginning
 | 
			
		||||
        if (name.matches("^\\d.*")) {
 | 
			
		||||
            name = "_" + name;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toParamName(String name) {
 | 
			
		||||
        // should be the same as variable name
 | 
			
		||||
        return toVarName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toModelName(String name) {
 | 
			
		||||
        // remove [ 
 | 
			
		||||
        name = name.replaceAll("\\]", "");
 | 
			
		||||
 | 
			
		||||
        // Note: backslash ("\\") is allowed for e.g. "\\DateTime"
 | 
			
		||||
        name = name.replaceAll("[^\\w\\\\]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
 | 
			
		||||
 | 
			
		||||
        // remove dollar sign
 | 
			
		||||
        name = name.replaceAll("$", "");
 | 
			
		||||
 | 
			
		||||
        // model name cannot use reserved keyword
 | 
			
		||||
        if (isReservedWord(name)) {
 | 
			
		||||
            LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
 | 
			
		||||
            name = "model_" + name; // e.g. return => ModelReturn (after camelize)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // model name starts with number
 | 
			
		||||
        if (name.matches("^\\d.*")) {
 | 
			
		||||
            LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
 | 
			
		||||
            name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // add prefix and/or suffic only if name does not start wth \ (e.g. \DateTime)
 | 
			
		||||
        if (!name.matches("^\\\\.*")) {
 | 
			
		||||
            name = modelNamePrefix + name + modelNameSuffix;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // camelize the model name
 | 
			
		||||
        // phone_number => PhoneNumber
 | 
			
		||||
        return camelize(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toModelFilename(String name) {
 | 
			
		||||
        // should be the same as the model name
 | 
			
		||||
        return toModelName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toModelTestFilename(String name) {
 | 
			
		||||
        // should be the same as the model name
 | 
			
		||||
        return toModelName(name) + "Test";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toOperationId(String operationId) {
 | 
			
		||||
        // throw exception if method name is empty
 | 
			
		||||
        if (StringUtils.isEmpty(operationId)) {
 | 
			
		||||
            throw new RuntimeException("Empty method name (operationId) not allowed");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // method name cannot use reserved keyword, e.g. return
 | 
			
		||||
        if (isReservedWord(operationId)) {
 | 
			
		||||
            LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
 | 
			
		||||
            operationId = "call_" + operationId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return camelize(sanitizeName(operationId), true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the default value of the property
 | 
			
		||||
     *
 | 
			
		||||
     * @param p Swagger property object
 | 
			
		||||
     * @return string presentation of the default value of the property
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toDefaultValue(Property p) {
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            StringProperty dp = (StringProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return "'" + dp.getDefault() + "'";
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            BooleanProperty dp = (BooleanProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return dp.getDefault().toString();
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof DateProperty) {
 | 
			
		||||
            // TODO
 | 
			
		||||
        } else if (p instanceof DateTimeProperty) {
 | 
			
		||||
            // TODO
 | 
			
		||||
        } else if (p instanceof DoubleProperty) {
 | 
			
		||||
            DoubleProperty dp = (DoubleProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return dp.getDefault().toString();
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof FloatProperty) {
 | 
			
		||||
            FloatProperty dp = (FloatProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return dp.getDefault().toString();
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof IntegerProperty) {
 | 
			
		||||
            IntegerProperty dp = (IntegerProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return dp.getDefault().toString();
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof LongProperty) {
 | 
			
		||||
            LongProperty dp = (LongProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return dp.getDefault().toString();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setParameterExampleValue(CodegenParameter p) {
 | 
			
		||||
        String example;
 | 
			
		||||
 | 
			
		||||
        if (p.defaultValue == null) {
 | 
			
		||||
            example = p.example;
 | 
			
		||||
        } else {
 | 
			
		||||
            example = p.defaultValue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        String type = p.baseType;
 | 
			
		||||
        if (type == null) {
 | 
			
		||||
            type = p.dataType;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ("String".equalsIgnoreCase(type)) {
 | 
			
		||||
            if (example == null) {
 | 
			
		||||
                example = p.paramName + "_example";
 | 
			
		||||
            }
 | 
			
		||||
            example = "\"" + escapeText(example) + "\"";
 | 
			
		||||
        } else if ("Integer".equals(type) || "int".equals(type)) {
 | 
			
		||||
            if (example == null) {
 | 
			
		||||
                example = "56";
 | 
			
		||||
            }
 | 
			
		||||
        } else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) {
 | 
			
		||||
            if (example == null) {
 | 
			
		||||
                example = "3.4";
 | 
			
		||||
            }
 | 
			
		||||
        } else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) {
 | 
			
		||||
            if (example == null) {
 | 
			
		||||
                example = "True";
 | 
			
		||||
            }
 | 
			
		||||
        } else if ("\\SplFileObject".equalsIgnoreCase(type)) {
 | 
			
		||||
            if (example == null) {
 | 
			
		||||
                example = "/path/to/file";
 | 
			
		||||
            }
 | 
			
		||||
            example = "\"" + escapeText(example) + "\"";
 | 
			
		||||
        } else if ("Date".equalsIgnoreCase(type)) {
 | 
			
		||||
            if (example == null) {
 | 
			
		||||
                example = "2013-10-20";
 | 
			
		||||
            }
 | 
			
		||||
            example = "new \\DateTime(\"" + escapeText(example) + "\")";
 | 
			
		||||
        } else if ("DateTime".equalsIgnoreCase(type)) {
 | 
			
		||||
            if (example == null) {
 | 
			
		||||
                example = "2013-10-20T19:20:30+01:00";
 | 
			
		||||
            }
 | 
			
		||||
            example = "new \\DateTime(\"" + escapeText(example) + "\")";
 | 
			
		||||
        } else if (!languageSpecificPrimitives.contains(type)) {
 | 
			
		||||
            // type is a model class, e.g. User
 | 
			
		||||
            example = "new " + type + "()";
 | 
			
		||||
        } else {
 | 
			
		||||
            LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (example == null) {
 | 
			
		||||
            example = "NULL";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isListContainer)) {
 | 
			
		||||
            example = "array(" + example + ")";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isMapContainer)) {
 | 
			
		||||
            example = "array('key' => " + example + ")";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        p.example = example;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toEnumValue(String value, String datatype) {
 | 
			
		||||
        if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
 | 
			
		||||
            return value;
 | 
			
		||||
        } else {
 | 
			
		||||
            return "\'" + escapeText(value) + "\'";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toEnumDefaultValue(String value, String datatype) {
 | 
			
		||||
        return datatype + "_" + value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toEnumVarName(String name, String datatype) {
 | 
			
		||||
        // for symbol, e.g. $, #
 | 
			
		||||
        if (getSymbolName(name) != null) {
 | 
			
		||||
            return (getSymbolName(name)).toUpperCase();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // number
 | 
			
		||||
        if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
 | 
			
		||||
            String varName = name;
 | 
			
		||||
            varName = varName.replaceAll("-", "MINUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\+", "PLUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\.", "_DOT_");
 | 
			
		||||
            return varName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // string
 | 
			
		||||
        String enumName = sanitizeName(underscore(name).toUpperCase());
 | 
			
		||||
        enumName = enumName.replaceFirst("^_", "");
 | 
			
		||||
        enumName = enumName.replaceFirst("_$", "");
 | 
			
		||||
 | 
			
		||||
        if (enumName.matches("\\d.*")) { // starts with number
 | 
			
		||||
            return "_" + enumName;
 | 
			
		||||
        } else {
 | 
			
		||||
            return enumName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toEnumName(CodegenProperty property) {
 | 
			
		||||
        String enumName = underscore(toModelName(property.name)).toUpperCase();
 | 
			
		||||
 | 
			
		||||
        if (enumName.matches("\\d.*")) { // starts with number
 | 
			
		||||
            return "_" + enumName;
 | 
			
		||||
        } else {
 | 
			
		||||
            return enumName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessModels(Map<String, Object> objs) {
 | 
			
		||||
        // process enum in models
 | 
			
		||||
        return postProcessModelsEnum(objs);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
 | 
			
		||||
        Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
 | 
			
		||||
        List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
 | 
			
		||||
        for (CodegenOperation op : operationList) {
 | 
			
		||||
            op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
 | 
			
		||||
        }
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeQuotationMark(String input) {
 | 
			
		||||
        // remove ' to avoid code injection
 | 
			
		||||
        return input.replace("'", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("*/", "");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,184 @@
 | 
			
		||||
package io.swagger.codegen.languages;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.CliOption;
 | 
			
		||||
import io.swagger.codegen.CodegenConstants;
 | 
			
		||||
import io.swagger.codegen.DefaultCodegen;
 | 
			
		||||
import io.swagger.models.properties.ArrayProperty;
 | 
			
		||||
import io.swagger.models.properties.BooleanProperty;
 | 
			
		||||
import io.swagger.models.properties.DateProperty;
 | 
			
		||||
import io.swagger.models.properties.DateTimeProperty;
 | 
			
		||||
import io.swagger.models.properties.DoubleProperty;
 | 
			
		||||
import io.swagger.models.properties.FloatProperty;
 | 
			
		||||
import io.swagger.models.properties.IntegerProperty;
 | 
			
		||||
import io.swagger.models.properties.LongProperty;
 | 
			
		||||
import io.swagger.models.properties.MapProperty;
 | 
			
		||||
import io.swagger.models.properties.Property;
 | 
			
		||||
import io.swagger.models.properties.StringProperty;
 | 
			
		||||
 | 
			
		||||
public abstract class AbstractScalaCodegen extends DefaultCodegen {
 | 
			
		||||
 | 
			
		||||
    protected String modelPropertyNaming = "camelCase";
 | 
			
		||||
    protected String invokerPackage = "io.swagger.client";
 | 
			
		||||
    protected String sourceFolder = "src/main/scala";
 | 
			
		||||
 | 
			
		||||
    public AbstractScalaCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        languageSpecificPrimitives.addAll(Arrays.asList(
 | 
			
		||||
                        "String",
 | 
			
		||||
                        "boolean",
 | 
			
		||||
                        "Boolean",
 | 
			
		||||
                        "Double",
 | 
			
		||||
                        "Int",
 | 
			
		||||
                        "Long",
 | 
			
		||||
                        "Float",
 | 
			
		||||
                        "Object",
 | 
			
		||||
                        "Any",
 | 
			
		||||
                        "List",
 | 
			
		||||
                        "Seq",
 | 
			
		||||
                        "Map"));
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
 | 
			
		||||
            this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSourceFolder(String sourceFolder) {
 | 
			
		||||
        this.sourceFolder = sourceFolder;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getSourceFolder() {
 | 
			
		||||
        return sourceFolder;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeReservedWord(String name) {
 | 
			
		||||
        return "_" + name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String modelFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
    
 | 
			
		||||
            return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSwaggerType(Property p) {
 | 
			
		||||
        String swaggerType = super.getSwaggerType(p);
 | 
			
		||||
        String type = null;
 | 
			
		||||
        if (typeMapping.containsKey(swaggerType)) {
 | 
			
		||||
            type = typeMapping.get(swaggerType);
 | 
			
		||||
            if (languageSpecificPrimitives.contains(type)) {
 | 
			
		||||
                return toModelName(type);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            type = swaggerType;
 | 
			
		||||
        }
 | 
			
		||||
        return toModelName(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toInstantiationType(Property p) {
 | 
			
		||||
        if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty ap = (MapProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getAdditionalProperties());
 | 
			
		||||
            return instantiationTypes.get("map") + "[String, " + inner + "]";
 | 
			
		||||
        } else if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getItems());
 | 
			
		||||
            return instantiationTypes.get("array") + "[" + inner + "]";
 | 
			
		||||
        } else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toDefaultValue(Property p) {
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DateProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DateTimeProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DoubleProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof FloatProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof IntegerProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof LongProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty ap = (MapProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getAdditionalProperties());
 | 
			
		||||
            return "new HashMap[String, " + inner + "]() ";
 | 
			
		||||
        } else if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getItems());
 | 
			
		||||
            return "new ListBuffer[" + inner + "]() ";
 | 
			
		||||
        } else {
 | 
			
		||||
            return "null";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessModels(Map<String, Object> objs) {
 | 
			
		||||
        // remove model imports to avoid warnings for importing class in the same package in Scala
 | 
			
		||||
        List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
 | 
			
		||||
        final String prefix = modelPackage() + ".";
 | 
			
		||||
        Iterator<Map<String, String>> iterator = imports.iterator();
 | 
			
		||||
        while (iterator.hasNext()) {
 | 
			
		||||
            String _import = iterator.next().get("import");
 | 
			
		||||
            if (_import.startsWith(prefix)) iterator.remove();
 | 
			
		||||
        }
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toModelFilename(String name) {
 | 
			
		||||
        // should be the same as the model name
 | 
			
		||||
        return toModelName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("*/", "*_/").replace("/*", "/_*");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -3,14 +3,17 @@ package io.swagger.codegen.languages;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.TreeSet;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.CliOption;
 | 
			
		||||
import io.swagger.codegen.CodegenConfig;
 | 
			
		||||
import io.swagger.codegen.CodegenConstants;
 | 
			
		||||
import io.swagger.codegen.CodegenModel;
 | 
			
		||||
import io.swagger.codegen.CodegenProperty;
 | 
			
		||||
import io.swagger.codegen.CodegenType;
 | 
			
		||||
import io.swagger.codegen.DefaultCodegen;
 | 
			
		||||
@ -26,6 +29,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
 | 
			
		||||
 | 
			
		||||
    public AbstractTypeScriptClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as TS does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        supportsInheritance = true;
 | 
			
		||||
        setReservedWordsLowerCase(Arrays.asList(
 | 
			
		||||
                // local variable names used in API methods (endpoints)
 | 
			
		||||
@ -252,7 +260,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toEnumValue(String value, String datatype) {
 | 
			
		||||
        if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
 | 
			
		||||
        if ("number".equals(datatype)) {
 | 
			
		||||
            return value;
 | 
			
		||||
        } else {
 | 
			
		||||
            return "\'" + escapeText(value) + "\'";
 | 
			
		||||
@ -266,9 +274,15 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toEnumVarName(String name, String datatype) {
 | 
			
		||||
        // for symbol, e.g. $, #
 | 
			
		||||
        if (getSymbolName(name) != null) {
 | 
			
		||||
            return camelize(getSymbolName(name));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // number
 | 
			
		||||
        if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
 | 
			
		||||
            String varName = new String(name);
 | 
			
		||||
        if ("number".equals(datatype)) {
 | 
			
		||||
            String varName = "NUMBER_" + name;
 | 
			
		||||
 | 
			
		||||
            varName = varName.replaceAll("-", "MINUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\+", "PLUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\.", "_DOT_");
 | 
			
		||||
@ -305,7 +319,20 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessModels(Map<String, Object> objs) {
 | 
			
		||||
        // process enum in models
 | 
			
		||||
        return postProcessModelsEnum(objs);
 | 
			
		||||
        List<Object> models = (List<Object>) postProcessModelsEnum(objs).get("models");
 | 
			
		||||
        for (Object _mo : models) {
 | 
			
		||||
            Map<String, Object> mo = (Map<String, Object>) _mo;
 | 
			
		||||
            CodegenModel cm = (CodegenModel) mo.get("model");
 | 
			
		||||
            cm.imports = new TreeSet(cm.imports);
 | 
			
		||||
            for (CodegenProperty var : cm.vars) {
 | 
			
		||||
                // name enum with model name, e.g. StatuEnum => Pet.StatusEnum
 | 
			
		||||
                if (Boolean.TRUE.equals(var.isEnum)) {
 | 
			
		||||
                    var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "." + var.enumName);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSupportsES6(Boolean value) {
 | 
			
		||||
 | 
			
		||||
@ -12,7 +12,6 @@ import io.swagger.codegen.CodegenProperty;
 | 
			
		||||
import io.swagger.codegen.CodegenResponse;
 | 
			
		||||
import io.swagger.codegen.CodegenSecurity;
 | 
			
		||||
import io.swagger.codegen.CodegenType;
 | 
			
		||||
import io.swagger.codegen.DefaultCodegen;
 | 
			
		||||
import io.swagger.codegen.SupportingFile;
 | 
			
		||||
import io.swagger.models.auth.SecuritySchemeDefinition;
 | 
			
		||||
import io.swagger.models.properties.ArrayProperty;
 | 
			
		||||
@ -42,13 +41,11 @@ import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
public class AkkaScalaClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
 | 
			
		||||
    protected String mainPackage = "io.swagger.client";
 | 
			
		||||
    protected String invokerPackage = mainPackage + ".core";
 | 
			
		||||
    protected String groupId = "io.swagger";
 | 
			
		||||
    protected String artifactId = "swagger-client";
 | 
			
		||||
    protected String artifactVersion = "1.0.0";
 | 
			
		||||
    protected String sourceFolder = "src/main/scala";
 | 
			
		||||
    protected String resourcesFolder = "src/main/resources";
 | 
			
		||||
    protected String configKey = "apiRequest";
 | 
			
		||||
    protected int defaultTimeoutInMs = 5000;
 | 
			
		||||
@ -75,6 +72,7 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon
 | 
			
		||||
        embeddedTemplateDir = templateDir = "akka-scala";
 | 
			
		||||
        apiPackage = mainPackage + ".api";
 | 
			
		||||
        modelPackage = mainPackage + ".model";
 | 
			
		||||
        invokerPackage = mainPackage + ".core";
 | 
			
		||||
 | 
			
		||||
        setReservedWordsLowerCase(
 | 
			
		||||
                Arrays.asList(
 | 
			
		||||
@ -135,25 +133,8 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon
 | 
			
		||||
        typeMapping.put("file", "File");
 | 
			
		||||
        typeMapping.put("number", "Double");
 | 
			
		||||
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>(
 | 
			
		||||
                Arrays.asList(
 | 
			
		||||
                        "String",
 | 
			
		||||
                        "boolean",
 | 
			
		||||
                        "Boolean",
 | 
			
		||||
                        "Double",
 | 
			
		||||
                        "Int",
 | 
			
		||||
                        "Long",
 | 
			
		||||
                        "Float",
 | 
			
		||||
                        "Object",
 | 
			
		||||
                        "List",
 | 
			
		||||
                        "Seq",
 | 
			
		||||
                        "Map")
 | 
			
		||||
        );
 | 
			
		||||
        instantiationTypes.put("array", "ListBuffer");
 | 
			
		||||
        instantiationTypes.put("map", "Map");
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@ -176,16 +157,6 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon
 | 
			
		||||
        return "`" + name + "`";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String modelFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
 | 
			
		||||
        if (registerNonStandardStatusCodes) {
 | 
			
		||||
@ -218,21 +189,6 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon
 | 
			
		||||
        return super.postProcessOperations(objs);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
 | 
			
		||||
            return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<CodegenSecurity> fromSecurity(Map<String, SecuritySchemeDefinition> schemes) {
 | 
			
		||||
        final List<CodegenSecurity> codegenSecurities = super.fromSecurity(schemes);
 | 
			
		||||
@ -297,36 +253,6 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon
 | 
			
		||||
        return formatIdentifier(property.baseName, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSwaggerType(Property p) {
 | 
			
		||||
        String swaggerType = super.getSwaggerType(p);
 | 
			
		||||
        String type;
 | 
			
		||||
        if (typeMapping.containsKey(swaggerType)) {
 | 
			
		||||
            type = typeMapping.get(swaggerType);
 | 
			
		||||
            if (languageSpecificPrimitives.contains(type)) {
 | 
			
		||||
                return toModelName(type);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            type = swaggerType;
 | 
			
		||||
        }
 | 
			
		||||
        return toModelName(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toInstantiationType(Property p) {
 | 
			
		||||
        if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty ap = (MapProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getAdditionalProperties());
 | 
			
		||||
            return instantiationTypes.get("map") + "[String, " + inner + "]";
 | 
			
		||||
        } else if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getItems());
 | 
			
		||||
            return instantiationTypes.get("array") + "[" + inner + "]";
 | 
			
		||||
        } else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toDefaultValue(Property p) {
 | 
			
		||||
        if (!p.getRequired()) {
 | 
			
		||||
@ -419,9 +345,4 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon
 | 
			
		||||
        // remove " to avoid code injection
 | 
			
		||||
        return input.replace("\"", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("*/", "*_/").replace("/*", "/_*");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,31 +4,16 @@ import io.swagger.codegen.CliOption;
 | 
			
		||||
import io.swagger.codegen.CodegenConfig;
 | 
			
		||||
import io.swagger.codegen.CodegenConstants;
 | 
			
		||||
import io.swagger.codegen.CodegenType;
 | 
			
		||||
import io.swagger.codegen.DefaultCodegen;
 | 
			
		||||
import io.swagger.codegen.SupportingFile;
 | 
			
		||||
import io.swagger.models.properties.ArrayProperty;
 | 
			
		||||
import io.swagger.models.properties.BooleanProperty;
 | 
			
		||||
import io.swagger.models.properties.DateProperty;
 | 
			
		||||
import io.swagger.models.properties.DateTimeProperty;
 | 
			
		||||
import io.swagger.models.properties.DoubleProperty;
 | 
			
		||||
import io.swagger.models.properties.FloatProperty;
 | 
			
		||||
import io.swagger.models.properties.IntegerProperty;
 | 
			
		||||
import io.swagger.models.properties.LongProperty;
 | 
			
		||||
import io.swagger.models.properties.MapProperty;
 | 
			
		||||
import io.swagger.models.properties.Property;
 | 
			
		||||
import io.swagger.models.properties.StringProperty;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
 | 
			
		||||
public class AsyncScalaClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    protected String invokerPackage = "io.swagger.client";
 | 
			
		||||
public class AsyncScalaClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
 | 
			
		||||
    protected String groupId = "io.swagger";
 | 
			
		||||
    protected String artifactId = "swagger-async-scala-client";
 | 
			
		||||
    protected String artifactVersion = "1.0.0";
 | 
			
		||||
    protected String sourceFolder = "src/main/scala";
 | 
			
		||||
    protected String clientName = "SwaggerClient";
 | 
			
		||||
    protected String authScheme = "";
 | 
			
		||||
    protected boolean authPreemptive;
 | 
			
		||||
@ -94,24 +79,8 @@ public class AsyncScalaClientCodegen extends DefaultCodegen implements CodegenCo
 | 
			
		||||
        typeMapping.put("object", "Any");
 | 
			
		||||
        typeMapping.put("file", "File");
 | 
			
		||||
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>(
 | 
			
		||||
                Arrays.asList(
 | 
			
		||||
                        "String",
 | 
			
		||||
                        "boolean",
 | 
			
		||||
                        "Boolean",
 | 
			
		||||
                        "Double",
 | 
			
		||||
                        "Int",
 | 
			
		||||
                        "Long",
 | 
			
		||||
                        "Float",
 | 
			
		||||
                        "Object",
 | 
			
		||||
                        "List",
 | 
			
		||||
                        "Map")
 | 
			
		||||
        );
 | 
			
		||||
        instantiationTypes.put("array", "ListBuffer");
 | 
			
		||||
        instantiationTypes.put("map", "HashMap");
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@ -128,95 +97,4 @@ public class AsyncScalaClientCodegen extends DefaultCodegen implements CodegenCo
 | 
			
		||||
    public String getHelp() {
 | 
			
		||||
        return "Generates an Asynchronous Scala client library.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeReservedWord(String name) {
 | 
			
		||||
        return "_" + name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String modelFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
 | 
			
		||||
            return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSwaggerType(Property p) {
 | 
			
		||||
        String swaggerType = super.getSwaggerType(p);
 | 
			
		||||
        String type = null;
 | 
			
		||||
        if (typeMapping.containsKey(swaggerType)) {
 | 
			
		||||
            type = typeMapping.get(swaggerType);
 | 
			
		||||
            if (languageSpecificPrimitives.contains(type)) {
 | 
			
		||||
                return toModelName(type);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            type = swaggerType;
 | 
			
		||||
        }
 | 
			
		||||
        return toModelName(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toInstantiationType(Property p) {
 | 
			
		||||
        if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty ap = (MapProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getAdditionalProperties());
 | 
			
		||||
            return instantiationTypes.get("map") + "[String, " + inner + "]";
 | 
			
		||||
        } else if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getItems());
 | 
			
		||||
            return instantiationTypes.get("array") + "[" + inner + "]";
 | 
			
		||||
        } else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toDefaultValue(Property p) {
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DateProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DateTimeProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DoubleProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof FloatProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof IntegerProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof LongProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty ap = (MapProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getAdditionalProperties());
 | 
			
		||||
            return "new HashMap[String, " + inner + "]() ";
 | 
			
		||||
        } else if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getItems());
 | 
			
		||||
            return "new ListBuffer[" + inner + "]() ";
 | 
			
		||||
        } else {
 | 
			
		||||
            return "null";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -96,6 +96,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
 | 
			
		||||
        cliOptions.add(framework);
 | 
			
		||||
 | 
			
		||||
        // CLI Switches
 | 
			
		||||
        addSwitch(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC,
 | 
			
		||||
                this.hideGenerationTimestamp);
 | 
			
		||||
 | 
			
		||||
        addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
 | 
			
		||||
                CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC,
 | 
			
		||||
                this.sortParamsByRequiredFlag);
 | 
			
		||||
@ -127,13 +131,23 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
 | 
			
		||||
        addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
 | 
			
		||||
                CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
 | 
			
		||||
                this.optionalEmitDefaultValue);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
        Boolean excludeTests = false;
 | 
			
		||||
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                    Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Boolean excludeTests = false;
 | 
			
		||||
        if(additionalProperties.containsKey(CodegenConstants.EXCLUDE_TESTS)) {
 | 
			
		||||
            excludeTests = Boolean.valueOf(additionalProperties.get(CodegenConstants.EXCLUDE_TESTS).toString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,95 @@
 | 
			
		||||
package io.swagger.codegen.languages;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.*;
 | 
			
		||||
import io.swagger.models.properties.ArrayProperty;
 | 
			
		||||
import io.swagger.models.properties.MapProperty;
 | 
			
		||||
import io.swagger.models.properties.Property;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class ConfluenceWikiGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    private static final String ALL_OPERATIONS = "";
 | 
			
		||||
    protected String invokerPackage = "io.swagger.client";
 | 
			
		||||
    protected String groupId = "io.swagger";
 | 
			
		||||
    protected String artifactId = "swagger-client";
 | 
			
		||||
    protected String artifactVersion = "1.0.0";
 | 
			
		||||
 | 
			
		||||
    public ConfluenceWikiGenerator() {
 | 
			
		||||
        super();
 | 
			
		||||
        outputFolder = "docs";
 | 
			
		||||
        embeddedTemplateDir = templateDir = "confluenceWikiDocs";
 | 
			
		||||
 | 
			
		||||
        defaultIncludes = new HashSet<String>();
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption("appName", "short name of the application"));
 | 
			
		||||
        cliOptions.add(new CliOption("appDescription", "description of the application"));
 | 
			
		||||
        cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application"));
 | 
			
		||||
        cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application"));
 | 
			
		||||
        cliOptions.add(new CliOption("licenseInfo", "a short description of the license"));
 | 
			
		||||
        cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
 | 
			
		||||
        
 | 
			
		||||
        additionalProperties.put("appName", "Swagger Sample");
 | 
			
		||||
        additionalProperties.put("appDescription", "A sample swagger server");
 | 
			
		||||
        additionalProperties.put("infoUrl", "https://helloreverb.com");
 | 
			
		||||
        additionalProperties.put("infoEmail", "hello@helloreverb.com");
 | 
			
		||||
        additionalProperties.put("licenseInfo", "All rights reserved");
 | 
			
		||||
        additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
 | 
			
		||||
        additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
 | 
			
		||||
        additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
 | 
			
		||||
        additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
 | 
			
		||||
        additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
 | 
			
		||||
 | 
			
		||||
        supportingFiles.add(new SupportingFile("index.mustache", "", "confluence-markup.txt"));
 | 
			
		||||
        reservedWords = new HashSet<String>();
 | 
			
		||||
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>();
 | 
			
		||||
        importMapping = new HashMap<String, String>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public CodegenType getTag() {
 | 
			
		||||
        return CodegenType.DOCUMENTATION;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return "cwiki";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getHelp() {
 | 
			
		||||
        return "Generates confluence wiki markup.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
 | 
			
		||||
            return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
 | 
			
		||||
        Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
 | 
			
		||||
        List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
 | 
			
		||||
        for (CodegenOperation op : operationList) {
 | 
			
		||||
            op.httpMethod = op.httpMethod.toLowerCase();
 | 
			
		||||
        }
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -24,6 +24,11 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
 | 
			
		||||
 | 
			
		||||
    public CsharpDotNet2ClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as C# (2.0) does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        outputFolder = "generated-code" + File.separator + "CsharpDotNet2";
 | 
			
		||||
        modelTemplateFiles.put("model.mustache", ".cs");
 | 
			
		||||
        apiTemplateFiles.put("api.mustache", ".cs");
 | 
			
		||||
 | 
			
		||||
@ -28,6 +28,11 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    public DartClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as dart does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        outputFolder = "generated-code/dart";
 | 
			
		||||
        modelTemplateFiles.put("model.mustache", ".dart");
 | 
			
		||||
        apiTemplateFiles.put("api.mustache", ".dart");
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,280 @@
 | 
			
		||||
package io.swagger.codegen.languages;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.core.JsonGenerator;
 | 
			
		||||
import com.fasterxml.jackson.core.JsonProcessingException;
 | 
			
		||||
import com.fasterxml.jackson.databind.JsonSerializer;
 | 
			
		||||
import com.fasterxml.jackson.databind.SerializerProvider;
 | 
			
		||||
import com.fasterxml.jackson.databind.module.SimpleModule;
 | 
			
		||||
import com.google.common.collect.ArrayListMultimap;
 | 
			
		||||
import com.google.common.collect.Lists;
 | 
			
		||||
import com.google.common.collect.Multimap;
 | 
			
		||||
import io.swagger.codegen.*;
 | 
			
		||||
import io.swagger.models.*;
 | 
			
		||||
import io.swagger.util.Json;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
 | 
			
		||||
public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    private static final Logger LOGGER = LoggerFactory.getLogger(ErlangServerCodegen.class);
 | 
			
		||||
 | 
			
		||||
    protected String apiVersion = "1.0.0";
 | 
			
		||||
    protected String apiPath = "src";
 | 
			
		||||
    protected String packageName = "swagger";
 | 
			
		||||
 | 
			
		||||
    public ErlangServerCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // set the output folder here
 | 
			
		||||
        outputFolder = "generated-code/erlang-server";
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
 | 
			
		||||
            setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Models.  You can write model files using the modelTemplateFiles map.
 | 
			
		||||
         * if you want to create one template for file, you can do so here.
 | 
			
		||||
         * for multiple files for model, just put another entry in the `modelTemplateFiles` with
 | 
			
		||||
         * a different extension
 | 
			
		||||
         */
 | 
			
		||||
        modelTemplateFiles.clear();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Api classes.  You can write classes for each Api file with the apiTemplateFiles map.
 | 
			
		||||
         * as with models, add multiple entries with different extensions for multiple files per
 | 
			
		||||
         * class
 | 
			
		||||
         */
 | 
			
		||||
        apiTemplateFiles.put(
 | 
			
		||||
            "handler.mustache",   // the template to use
 | 
			
		||||
            ".erl");       // the extension for each file to write
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Template Location.  This is the location which templates will be read from.  The generator
 | 
			
		||||
         * will use the resource stream to attempt to read the templates.
 | 
			
		||||
         */
 | 
			
		||||
        embeddedTemplateDir = templateDir = "erlang-server";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Reserved words.  Override this with reserved words specific to your language
 | 
			
		||||
         */
 | 
			
		||||
        setReservedWordsLowerCase(
 | 
			
		||||
            Arrays.asList(
 | 
			
		||||
                "after","and","andalso","band","begin","bnot","bor","bsl","bsr","bxor","case",
 | 
			
		||||
                "catch","cond","div","end","fun","if","let","not","of","or","orelse","receive",
 | 
			
		||||
                "rem","try","when","xor"
 | 
			
		||||
            )
 | 
			
		||||
       );
 | 
			
		||||
 | 
			
		||||
        instantiationTypes.clear();
 | 
			
		||||
 | 
			
		||||
        typeMapping.clear();
 | 
			
		||||
        typeMapping.put("enum", "binary");
 | 
			
		||||
        typeMapping.put("date", "date");
 | 
			
		||||
        typeMapping.put("datetime", "datetime");
 | 
			
		||||
        typeMapping.put("boolean", "boolean");
 | 
			
		||||
        typeMapping.put("string", "binary");
 | 
			
		||||
        typeMapping.put("integer", "integer");
 | 
			
		||||
        typeMapping.put("int", "integer");
 | 
			
		||||
        typeMapping.put("float", "integer");
 | 
			
		||||
        typeMapping.put("long", "integer");
 | 
			
		||||
        typeMapping.put("double", "float");
 | 
			
		||||
        typeMapping.put("array", "list");
 | 
			
		||||
        typeMapping.put("map", "map");
 | 
			
		||||
        typeMapping.put("number", "integer");
 | 
			
		||||
        typeMapping.put("bigdecimal", "float");
 | 
			
		||||
        typeMapping.put("List", "list");
 | 
			
		||||
        typeMapping.put("object", "object");
 | 
			
		||||
        typeMapping.put("file", "file");
 | 
			
		||||
        typeMapping.put("binary", "binary");
 | 
			
		||||
        typeMapping.put("bytearray", "binary");
 | 
			
		||||
        typeMapping.put("byte", "binary");
 | 
			
		||||
        typeMapping.put("uuid", "binary");
 | 
			
		||||
        typeMapping.put("password", "binary");
 | 
			
		||||
 | 
			
		||||
        cliOptions.clear();
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Erlang package name (convention: lowercase).")
 | 
			
		||||
            .defaultValue(this.packageName));
 | 
			
		||||
        /**
 | 
			
		||||
         * Additional Properties.  These values can be passed to the templates and
 | 
			
		||||
         * are available in models, apis, and supporting files
 | 
			
		||||
         */
 | 
			
		||||
        additionalProperties.put("apiVersion", apiVersion);
 | 
			
		||||
        additionalProperties.put("apiPath", apiPath);
 | 
			
		||||
        /**
 | 
			
		||||
         * Supporting Files.  You can write single files for the generator with the
 | 
			
		||||
         * entire object tree available.  If the input file has a suffix of `.mustache
 | 
			
		||||
         * it will be processed by the template engine.  Otherwise, it will be copied
 | 
			
		||||
         */
 | 
			
		||||
        supportingFiles.add(new SupportingFile("rebar.config.mustache","", "rebar.config"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("app.src.mustache", "", "src" + File.separator + this.packageName + ".app.src"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("router.mustache", "",  toSourceFilePath("router", "erl")));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("api.mustache", "",  toSourceFilePath("api", "erl")));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("server.mustache", "",  toSourceFilePath("server", "erl")));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("utils.mustache", "",  toSourceFilePath("utils", "erl")));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("auth.mustache", "",  toSourceFilePath("auth", "erl")));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("swagger.mustache", "", toPrivFilePath("swagger", "json")));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("default_logic_handler.mustache", "",  toSourceFilePath("default_logic_handler", "erl")));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("logic_handler.mustache", "",  toSourceFilePath("logic_handler", "erl")));
 | 
			
		||||
        writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiPackage() {
 | 
			
		||||
        return apiPath;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Configures the type of generator.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the CodegenType for this generator
 | 
			
		||||
     * @see io.swagger.codegen.CodegenType
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public CodegenType getTag() {
 | 
			
		||||
        return CodegenType.SERVER;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Configures a friendly name for the generator.  This will be used by the generator
 | 
			
		||||
     * to select the library with the -l flag.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the friendly name for the generator
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return "erlang-server";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns human-friendly help for the generator.  Provide the consumer with help
 | 
			
		||||
     * tips, parameters here
 | 
			
		||||
     *
 | 
			
		||||
     * @return A string value for the help message
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getHelp() {
 | 
			
		||||
        return "Generates an Erlang server library (beta) using the Swagger Codegen project. By default, " +
 | 
			
		||||
                "it will also generate service classes, which can be disabled with the `-Dnoservice` environment variable.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toApiName(String name) {
 | 
			
		||||
        if (name.length() == 0) {
 | 
			
		||||
            return this.packageName + "_default_handler";
 | 
			
		||||
        }
 | 
			
		||||
        return this.packageName + "_" + underscore(name) + "_handler";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
 | 
			
		||||
     * those terms here.  This logic is only called if a variable matches the reseved words
 | 
			
		||||
     *
 | 
			
		||||
     * @return the escaped term
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeReservedWord(String name) {
 | 
			
		||||
        return name + "_";  // add an underscore to the name
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Location to write api files.  You can use the apiPackage() as defined when the class is
 | 
			
		||||
     * instantiated
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiFileFolder() {
 | 
			
		||||
        return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toModelName(String name) {
 | 
			
		||||
        return camelize(toModelFilename(name));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toOperationId(String operationId) {
 | 
			
		||||
        // method name cannot use reserved keyword, e.g. return
 | 
			
		||||
        if (isReservedWord(operationId)) {
 | 
			
		||||
            LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
 | 
			
		||||
            operationId = "call_" + operationId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return camelize(operationId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toApiFilename(String name) {
 | 
			
		||||
        return toHandlerName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
 | 
			
		||||
        Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
 | 
			
		||||
        List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
 | 
			
		||||
        for (CodegenOperation op : operationList) {
 | 
			
		||||
            if (op.path != null) {
 | 
			
		||||
                op.path = op.path.replaceAll("\\{(.*?)\\}", ":$1");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
 | 
			
		||||
        Swagger swagger = (Swagger)objs.get("swagger");
 | 
			
		||||
        if(swagger != null) {
 | 
			
		||||
            try {
 | 
			
		||||
                objs.put("swagger-json", Json.mapper().writeValueAsString(swagger));
 | 
			
		||||
            } catch (JsonProcessingException e) {
 | 
			
		||||
                LOGGER.error(e.getMessage(), e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return super.postProcessSupportingFileData(objs);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPackageName(String packageName) {
 | 
			
		||||
        this.packageName = packageName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected String toHandlerName(String name) {
 | 
			
		||||
        return toModuleName(name) + "_handler";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected String toModuleName(String name) {
 | 
			
		||||
        return this.packageName + "_" + underscore(name.replaceAll("-", "_"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected String toSourceFilePath(String name, String extension) {
 | 
			
		||||
        return "src" + File.separator +  toModuleName(name) + "." + extension;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected String toIncludeFilePath(String name, String extension) {
 | 
			
		||||
        return "include" + File.separator + toModuleName(name) + "." + extension;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected String toPrivFilePath(String name, String extension) {
 | 
			
		||||
        return "priv" + File.separator + name + "." + extension;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeQuotationMark(String input) {
 | 
			
		||||
        // remove ' to avoid code injection
 | 
			
		||||
        return input.replace("'", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        // ref: http://stackoverflow.com/a/30421295/677735
 | 
			
		||||
        return input.replace("-ifdef", "- if def").replace("-endif", "- end if");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -67,7 +67,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
 | 
			
		||||
 | 
			
		||||
        apiTemplateFiles.clear();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Template Location.  This is the location which templates will be read from.  The generator
 | 
			
		||||
         * will use the resource stream to attempt to read the templates.
 | 
			
		||||
         */
 | 
			
		||||
@ -81,14 +81,14 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
 | 
			
		||||
                        "print", "class", "exec", "in", "raise", "continue", "finally", "is",
 | 
			
		||||
                        "return", "def", "for", "lambda", "try"));
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Additional Properties.  These values can be passed to the templates and
 | 
			
		||||
         * are available in models, apis, and supporting files
 | 
			
		||||
         */
 | 
			
		||||
        additionalProperties.put("apiVersion", apiVersion);
 | 
			
		||||
        additionalProperties.put("serverPort", serverPort);
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Supporting Files.  You can write single files for the generator with the
 | 
			
		||||
         * entire object tree available.  If the input file has a suffix of `.mustache
 | 
			
		||||
         * it will be processed by the template engine.  Otherwise, it will be copied
 | 
			
		||||
 | 
			
		||||
@ -47,6 +47,11 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
        setReservedWordsLowerCase(
 | 
			
		||||
            Arrays.asList(
 | 
			
		||||
                // data type
 | 
			
		||||
                "string", "bool", "uint", "uint8", "uint16", "uint32", "uint64",
 | 
			
		||||
                "int", "int8", "int16", "int32", "int64", "float32", "float64",
 | 
			
		||||
                "complex64", "complex128", "rune", "byte", "uintptr",
 | 
			
		||||
 | 
			
		||||
                "break", "default", "func", "interface", "select",
 | 
			
		||||
                "case", "defer", "go", "map", "struct",
 | 
			
		||||
                "chan", "else", "goto", "package", "switch",
 | 
			
		||||
@ -91,6 +96,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        typeMapping.put("double", "float64");
 | 
			
		||||
        typeMapping.put("boolean", "bool");
 | 
			
		||||
        typeMapping.put("string", "string");
 | 
			
		||||
        typeMapping.put("UUID", "string");
 | 
			
		||||
        typeMapping.put("date", "time.Time");
 | 
			
		||||
        typeMapping.put("DateTime", "time.Time");
 | 
			
		||||
        typeMapping.put("password", "string");
 | 
			
		||||
@ -100,6 +106,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        // the correct solution is to use []byte
 | 
			
		||||
        typeMapping.put("binary", "string");
 | 
			
		||||
        typeMapping.put("ByteArray", "string");
 | 
			
		||||
        typeMapping.put("object", "interface{}");
 | 
			
		||||
 | 
			
		||||
        importMapping = new HashMap<String, String>();
 | 
			
		||||
        importMapping.put("time.Time", "time");
 | 
			
		||||
@ -111,11 +118,22 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
                .defaultValue("swagger"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
 | 
			
		||||
                .defaultValue("1.0.0"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
 | 
			
		||||
                .defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        //super.processOpts();
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                    Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
 | 
			
		||||
            setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
 | 
			
		||||
@ -147,7 +165,6 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        supportingFiles.add(new SupportingFile("api_client.mustache", "", "api_client.go"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("api_response.mustache", "", "api_response.go"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -193,9 +210,13 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        name = camelize(name);
 | 
			
		||||
 | 
			
		||||
        // for reserved word or word starting with number, append _
 | 
			
		||||
        if(isReservedWord(name) || name.matches("^\\d.*"))
 | 
			
		||||
        if (isReservedWord(name))
 | 
			
		||||
            name = escapeReservedWord(name);
 | 
			
		||||
 | 
			
		||||
        // for reserved word or word starting with number, append _
 | 
			
		||||
        if (name.matches("^\\d.*"))
 | 
			
		||||
            name = "Var" + name;
 | 
			
		||||
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -231,10 +252,16 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
        // model name cannot use reserved keyword, e.g. return
 | 
			
		||||
        if (isReservedWord(name)) {
 | 
			
		||||
            LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
 | 
			
		||||
            LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
 | 
			
		||||
            name = "model_" + name; // e.g. return => ModelReturn (after camelize)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // model name starts with number
 | 
			
		||||
        if (name.matches("^\\d.*")) {
 | 
			
		||||
            LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + ("model_" + name));
 | 
			
		||||
            name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return underscore(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -346,7 +373,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toOperationId(String operationId) {
 | 
			
		||||
        String sanitizedOperationId = new String(sanitizeName(operationId));
 | 
			
		||||
        String sanitizedOperationId = sanitizeName(operationId);
 | 
			
		||||
 | 
			
		||||
        // method name cannot use reserved keyword, e.g. return
 | 
			
		||||
        if (isReservedWord(sanitizedOperationId)) {
 | 
			
		||||
@ -382,14 +409,22 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        // if the return type is not primitive, import encoding/json
 | 
			
		||||
        for (CodegenOperation operation : operations) {
 | 
			
		||||
            if(operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
 | 
			
		||||
                Map<String, String> customImport = new HashMap<String, String>();
 | 
			
		||||
                customImport.put("import", "encoding/json");
 | 
			
		||||
                imports.add(customImport);
 | 
			
		||||
                imports.add(createMapping("import", "encoding/json"));
 | 
			
		||||
                break; //just need to import once
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // recursivly add import for mapping one type to multipe imports
 | 
			
		||||
        // this will only import "strings" "fmt" if there are items in pathParams
 | 
			
		||||
        for (CodegenOperation operation : operations) {
 | 
			
		||||
            if(operation.pathParams != null && operation.pathParams.size() > 0) {
 | 
			
		||||
                imports.add(createMapping("import", "fmt"));
 | 
			
		||||
                imports.add(createMapping("import", "strings"));
 | 
			
		||||
                break; //just need to import once
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // recursively add import for mapping one type to multiple imports
 | 
			
		||||
        List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
 | 
			
		||||
        if (recursiveImports == null)
 | 
			
		||||
            return objs;
 | 
			
		||||
@ -400,9 +435,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
            // if the import package happens to be found in the importMapping (key)
 | 
			
		||||
            // add the corresponding import package to the list
 | 
			
		||||
            if (importMapping.containsKey(_import)) {
 | 
			
		||||
                Map<String, String> newImportMap= new HashMap<String, String>();
 | 
			
		||||
                newImportMap.put("import", importMapping.get(_import));
 | 
			
		||||
                listIterator.add(newImportMap);
 | 
			
		||||
                listIterator.add(createMapping("import", importMapping.get(_import)));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -421,7 +454,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
                iterator.remove();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // recursivly add import for mapping one type to multipe imports
 | 
			
		||||
        // recursively add import for mapping one type to multiple imports
 | 
			
		||||
        List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
 | 
			
		||||
        if (recursiveImports == null)
 | 
			
		||||
            return objs;
 | 
			
		||||
@ -432,9 +465,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
            // if the import package happens to be found in the importMapping (key)
 | 
			
		||||
            // add the corresponding import package to the list
 | 
			
		||||
            if (importMapping.containsKey(_import)) {
 | 
			
		||||
                Map<String, String> newImportMap= new HashMap<String, String>();
 | 
			
		||||
                newImportMap.put("import", importMapping.get(_import));
 | 
			
		||||
                listIterator.add(newImportMap);
 | 
			
		||||
                listIterator.add(createMapping("import", importMapping.get(_import)));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -465,4 +496,11 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("*/", "*_/").replace("/*", "/_*");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Map<String, String> createMapping(String key, String value){
 | 
			
		||||
        Map<String, String> customImport = new HashMap<String, String>();
 | 
			
		||||
        customImport.put(key, value);
 | 
			
		||||
 | 
			
		||||
        return customImport;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -36,7 +36,7 @@ public class GoServerCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        // set the output folder here
 | 
			
		||||
        outputFolder = "generated-code/go";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Models.  You can write model files using the modelTemplateFiles map.
 | 
			
		||||
         * if you want to create one template for file, you can do so here.
 | 
			
		||||
         * for multiple files for model, just put another entry in the `modelTemplateFiles` with
 | 
			
		||||
@ -44,7 +44,7 @@ public class GoServerCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
         */
 | 
			
		||||
        modelTemplateFiles.clear();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Api classes.  You can write classes for each Api file with the apiTemplateFiles map.
 | 
			
		||||
         * as with models, add multiple entries with different extensions for multiple files per
 | 
			
		||||
         * class
 | 
			
		||||
@ -53,13 +53,13 @@ public class GoServerCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
                "controller.mustache",   // the template to use
 | 
			
		||||
                ".go");       // the extension for each file to write
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Template Location.  This is the location which templates will be read from.  The generator
 | 
			
		||||
         * will use the resource stream to attempt to read the templates.
 | 
			
		||||
         */
 | 
			
		||||
        embeddedTemplateDir = templateDir = "go-server";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Reserved words.  Override this with reserved words specific to your language
 | 
			
		||||
         */
 | 
			
		||||
        setReservedWordsLowerCase(
 | 
			
		||||
@ -126,14 +126,14 @@ public class GoServerCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        cliOptions.clear();
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).")
 | 
			
		||||
                .defaultValue("swagger"));
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Additional Properties.  These values can be passed to the templates and
 | 
			
		||||
         * are available in models, apis, and supporting files
 | 
			
		||||
         */
 | 
			
		||||
        additionalProperties.put("apiVersion", apiVersion);
 | 
			
		||||
        additionalProperties.put("serverPort", serverPort);
 | 
			
		||||
        additionalProperties.put("apiPath", apiPath);
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Supporting Files.  You can write single files for the generator with the
 | 
			
		||||
         * entire object tree available.  If the input file has a suffix of `.mustache
 | 
			
		||||
         * it will be processed by the template engine.  Otherwise, it will be copied
 | 
			
		||||
 | 
			
		||||
@ -12,6 +12,10 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
 | 
			
		||||
    public GroovyClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as groovy does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        sourceFolder = projectFolder + File.separator + "groovy";
 | 
			
		||||
        outputFolder = "generated-code/groovy";
 | 
			
		||||
        modelTemplateFiles.put("model.mustache", ".groovy");
 | 
			
		||||
 | 
			
		||||
@ -49,8 +49,10 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
 | 
			
		||||
    public HaskellServantCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // override the mapping for "-" (Minus) to keep the original mapping in Haskell
 | 
			
		||||
        specialCharReplacements.put('-', "Dash");
 | 
			
		||||
        // override the mapping to keep the original mapping in Haskell
 | 
			
		||||
        specialCharReplacements.put("-", "Dash");
 | 
			
		||||
        specialCharReplacements.put(">", "GreaterThan");
 | 
			
		||||
        specialCharReplacements.put("<", "LessThan");
 | 
			
		||||
 | 
			
		||||
        // set the output folder here
 | 
			
		||||
        outputFolder = "generated-code/haskell-servant";
 | 
			
		||||
@ -203,9 +205,9 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
 | 
			
		||||
        List<Map<String, Object>> replacements = new ArrayList<>();
 | 
			
		||||
        Object[] replacementChars = specialCharReplacements.keySet().toArray();
 | 
			
		||||
        for(int i = 0; i < replacementChars.length; i++) {
 | 
			
		||||
            Character c = (Character) replacementChars[i];
 | 
			
		||||
            String c = (String) replacementChars[i];
 | 
			
		||||
            Map<String, Object> o = new HashMap<>();
 | 
			
		||||
            o.put("char", Character.toString(c));
 | 
			
		||||
            o.put("char", c);
 | 
			
		||||
            o.put("replacement", "'" + specialCharReplacements.get(c));
 | 
			
		||||
            o.put("hasMore", i != replacementChars.length - 1);
 | 
			
		||||
            replacements.add(o);
 | 
			
		||||
@ -471,6 +473,11 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
 | 
			
		||||
 | 
			
		||||
        // Create newtypes for things with non-object types
 | 
			
		||||
        String dataOrNewtype = "data";
 | 
			
		||||
        // check if it's a ModelImpl before casting 
 | 
			
		||||
        if (!(mod instanceof ModelImpl)) {
 | 
			
		||||
            return model;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        String modelType = ((ModelImpl)  mod).getType();
 | 
			
		||||
        if(modelType != "object" && typeMapping.containsKey(modelType)) {
 | 
			
		||||
            String newtype = typeMapping.get(modelType);
 | 
			
		||||
 | 
			
		||||
@ -53,7 +53,7 @@ public class JMeterCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    // set the output folder here
 | 
			
		||||
    outputFolder = "generated-code/JMeterCodegen";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    /*
 | 
			
		||||
     * Api classes.  You can write classes for each Api file with the apiTemplateFiles map.
 | 
			
		||||
     * as with models, add multiple entries with different extensions for multiple files per
 | 
			
		||||
     * class
 | 
			
		||||
@ -64,23 +64,23 @@ public class JMeterCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    apiTemplateFiles.put("testdata-localhost.mustache", ".csv");
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    /*
 | 
			
		||||
     * Template Location.  This is the location which templates will be read from.  The generator
 | 
			
		||||
     * will use the resource stream to attempt to read the templates.
 | 
			
		||||
     */
 | 
			
		||||
    templateDir = "JMeter";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    /*
 | 
			
		||||
     * Api Package.  Optional, if needed, this can be used in templates
 | 
			
		||||
     */
 | 
			
		||||
    apiPackage = "";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    /*
 | 
			
		||||
     * Model Package.  Optional, if needed, this can be used in templates
 | 
			
		||||
     */
 | 
			
		||||
    modelPackage = "";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    /*
 | 
			
		||||
     * Reserved words.  Override this with reserved words specific to your language
 | 
			
		||||
     */
 | 
			
		||||
    reservedWords = new HashSet<String> (
 | 
			
		||||
@ -89,7 +89,7 @@ public class JMeterCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        "sample2")
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    /*
 | 
			
		||||
     * Additional Properties.  These values can be passed to the templates and
 | 
			
		||||
     * are available in models, apis, and supporting files
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,9 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
 | 
			
		||||
        outputFolder = "generated-code/JavaJaxRS-CXF";
 | 
			
		||||
        apiTestTemplateFiles.clear(); // TODO: add test template
 | 
			
		||||
 | 
			
		||||
        //TODO add auto-generated pom.xml for maven
 | 
			
		||||
        //apiTemplateFiles.put("pom.mustache", "pom.xml");
 | 
			
		||||
 | 
			
		||||
        // clear model and api doc template as this codegen
 | 
			
		||||
        // does not support auto-generated markdown doc at the moment
 | 
			
		||||
        //TODO: add doc templates
 | 
			
		||||
 | 
			
		||||
@ -183,6 +183,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen {
 | 
			
		||||
            if(additionalProperties.containsKey("gson")) {
 | 
			
		||||
                model.imports.add("SerializedName");
 | 
			
		||||
            }
 | 
			
		||||
        } else { // enum class
 | 
			
		||||
            //Needed imports for Jackson's JsonCreator
 | 
			
		||||
            if(additionalProperties.containsKey("jackson")) {
 | 
			
		||||
                model.imports.add("JsonCreator");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -39,6 +39,8 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
 | 
			
		||||
        modelPackage = System.getProperty("swagger.codegen.inflector.modelpackage", "io.swagger.model");
 | 
			
		||||
 | 
			
		||||
        additionalProperties.put("title", title);
 | 
			
		||||
        // java inflector uses the jackson lib
 | 
			
		||||
        additionalProperties.put("jackson", "true");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,6 @@ import io.swagger.models.Operation;
 | 
			
		||||
import io.swagger.models.Swagger;
 | 
			
		||||
import io.swagger.util.Json;
 | 
			
		||||
import org.apache.commons.io.FileUtils;
 | 
			
		||||
import com.fasterxml.jackson.core.JsonProcessingException;
 | 
			
		||||
 | 
			
		||||
public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen
 | 
			
		||||
{	
 | 
			
		||||
@ -69,8 +68,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen
 | 
			
		||||
        library.setEnum(supportedLibraries);
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(library);
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));	
 | 
			
		||||
        cliOptions.add(new CliOption("title", "a title describing the application"));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
@ -137,8 +134,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen
 | 
			
		||||
    	try {
 | 
			
		||||
			String swaggerJson = Json.pretty(swagger);
 | 
			
		||||
            FileUtils.writeStringToFile(new File(outputFolder + File.separator + "swagger.json"), swaggerJson);
 | 
			
		||||
		} catch (JsonProcessingException e) {
 | 
			
		||||
            throw new RuntimeException(e.getMessage(), e.getCause());
 | 
			
		||||
		} catch (IOException e) {
 | 
			
		||||
            throw new RuntimeException(e.getMessage(), e.getCause());
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -113,7 +113,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>(
 | 
			
		||||
                Arrays.asList("String", "Boolean", "Integer", "Number", "Array", "Object", "Date", "File")
 | 
			
		||||
                Arrays.asList("String", "Boolean", "Number", "Array", "Object", "Date", "File")
 | 
			
		||||
        );
 | 
			
		||||
        defaultIncludes = new HashSet<String>(languageSpecificPrimitives);
 | 
			
		||||
 | 
			
		||||
@ -126,17 +126,17 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
 | 
			
		||||
        typeMapping.put("List", "Array");
 | 
			
		||||
        typeMapping.put("boolean", "Boolean");
 | 
			
		||||
        typeMapping.put("string", "String");
 | 
			
		||||
        typeMapping.put("int", "Integer"); // Huh? What is JS Integer?
 | 
			
		||||
        typeMapping.put("int", "Number");
 | 
			
		||||
        typeMapping.put("float", "Number");
 | 
			
		||||
        typeMapping.put("number", "Number");
 | 
			
		||||
        typeMapping.put("DateTime", "Date"); // Should this be dateTime?
 | 
			
		||||
        typeMapping.put("date", "Date"); // Should this be date?
 | 
			
		||||
        typeMapping.put("long", "Integer");
 | 
			
		||||
        typeMapping.put("short", "Integer");
 | 
			
		||||
        typeMapping.put("DateTime", "Date");
 | 
			
		||||
        typeMapping.put("date", "Date");
 | 
			
		||||
        typeMapping.put("long", "Number");
 | 
			
		||||
        typeMapping.put("short", "Number");
 | 
			
		||||
        typeMapping.put("char", "String");
 | 
			
		||||
        typeMapping.put("double", "Number");
 | 
			
		||||
        typeMapping.put("object", "Object");
 | 
			
		||||
        typeMapping.put("integer", "Integer");
 | 
			
		||||
        typeMapping.put("integer", "Number");
 | 
			
		||||
        // binary not supported in JavaScript client right now, using String as a workaround
 | 
			
		||||
        typeMapping.put("ByteArray", "String"); // I don't see ByteArray defined in the Swagger docs.
 | 
			
		||||
        typeMapping.put("binary", "String");
 | 
			
		||||
@ -171,6 +171,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
 | 
			
		||||
        cliOptions.add(new CliOption(USE_INHERITANCE,
 | 
			
		||||
                "use JavaScript prototype chains & delegation for inheritance")
 | 
			
		||||
                .defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
 | 
			
		||||
                .defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@ -192,6 +194,15 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                    Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(PROJECT_NAME)) {
 | 
			
		||||
            setProjectName(((String) additionalProperties.get(PROJECT_NAME)));
 | 
			
		||||
        }
 | 
			
		||||
@ -1008,25 +1019,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toEnumVarName(String value, String datatype) {
 | 
			
		||||
        return value;
 | 
			
		||||
        /*
 | 
			
		||||
        // number
 | 
			
		||||
        if ("Integer".equals(datatype) || "Number".equals(datatype)) {
 | 
			
		||||
            String varName = "NUMBER_" + value;
 | 
			
		||||
            varName = varName.replaceAll("-", "MINUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\+", "PLUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\.", "_DOT_");
 | 
			
		||||
            return varName;
 | 
			
		||||
        // for symbol, e.g. $, #
 | 
			
		||||
        if (getSymbolName(value) != null) {
 | 
			
		||||
            return (getSymbolName(value)).toUpperCase();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // string
 | 
			
		||||
        String var = value.replaceAll("\\W+", "_").replaceAll("_+", "_").toUpperCase();
 | 
			
		||||
        if (var.matches("\\d.*")) {
 | 
			
		||||
            return "_" + var;
 | 
			
		||||
        } else {
 | 
			
		||||
            return var;
 | 
			
		||||
        }
 | 
			
		||||
        */
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 | 
			
		||||
@ -70,6 +70,19 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
 | 
			
		||||
        embeddedTemplateDir = templateDir = "Javascript-Closure-Angular";
 | 
			
		||||
        apiPackage = "API.Client";
 | 
			
		||||
        modelPackage = "API.Client";
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
 | 
			
		||||
                .defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 | 
			
		||||
@ -10,10 +10,9 @@ import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.TreeMap;
 | 
			
		||||
 | 
			
		||||
public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    // source folder where to write the files
 | 
			
		||||
    protected String sourceFolder = "";
 | 
			
		||||
public class LumenServerCodegen extends AbstractPhpCodegen 
 | 
			
		||||
{
 | 
			
		||||
     @SuppressWarnings("hiding")
 | 
			
		||||
    protected String apiVersion = "1.0.0";
 | 
			
		||||
        
 | 
			
		||||
    /**
 | 
			
		||||
@ -43,127 +42,59 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
     * @return A string value for the help message
 | 
			
		||||
     */
 | 
			
		||||
    public String getHelp() {
 | 
			
		||||
        return "Generates a LumenServerCodegen client library.";
 | 
			
		||||
        return "Generates a LumenServerCodegen server library.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public LumenServerCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // set the output folder here
 | 
			
		||||
        outputFolder = "lumen";
 | 
			
		||||
        String packagePath = "";
 | 
			
		||||
        embeddedTemplateDir = templateDir = "lumen";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Models.  You can write model files using the modelTemplateFiles map.
 | 
			
		||||
         * if you want to create one template for file, you can do so here.
 | 
			
		||||
         * for multiple files for model, just put another entry in the `modelTemplateFiles` with
 | 
			
		||||
         * a different extension
 | 
			
		||||
        /*
 | 
			
		||||
         * packPath
 | 
			
		||||
         */
 | 
			
		||||
        // modelTemplateFiles.put(
 | 
			
		||||
        //     "model.mustache", // the template to use
 | 
			
		||||
        //     ".sample");       // the extension for each file to write
 | 
			
		||||
        invokerPackage = "lumen";
 | 
			
		||||
        packagePath = "";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Api classes.  You can write classes for each Api file with the apiTemplateFiles map.
 | 
			
		||||
         * as with models, add multiple entries with different extensions for multiple files per
 | 
			
		||||
         * class
 | 
			
		||||
         */
 | 
			
		||||
        // apiTemplateFiles.put(
 | 
			
		||||
        //     "api.mustache",   // the template to use
 | 
			
		||||
        //     ".sample");       // the extension for each file to write
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // no api files
 | 
			
		||||
        // apiTemplateFiles.clear();
 | 
			
		||||
        apiTemplateFiles.put("api.mustache", ".php");
 | 
			
		||||
 | 
			
		||||
        // embeddedTemplateDir = templateDir = "slim";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Template Location.  This is the location which templates will be read from.  The generator
 | 
			
		||||
         * will use the resource stream to attempt to read the templates.
 | 
			
		||||
         */
 | 
			
		||||
        templateDir = "lumen";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Api Package.  Optional, if needed, this can be used in templates
 | 
			
		||||
         */
 | 
			
		||||
        apiPackage = "app.Http.Controllers";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Model Package.  Optional, if needed, this can be used in templates
 | 
			
		||||
         */
 | 
			
		||||
        modelPackage = "models";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Reserved words.  Override this with reserved words specific to your language
 | 
			
		||||
         */
 | 
			
		||||
        reservedWords = new HashSet<String> (
 | 
			
		||||
            Arrays.asList(
 | 
			
		||||
                "sample1",  // replace with static values
 | 
			
		||||
                "sample2")
 | 
			
		||||
        );
 | 
			
		||||
        // template files want to be ignored
 | 
			
		||||
        modelTemplateFiles.clear();
 | 
			
		||||
        apiTestTemplateFiles.clear();
 | 
			
		||||
        apiDocTemplateFiles.clear();
 | 
			
		||||
        modelDocTemplateFiles.clear();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Additional Properties.  These values can be passed to the templates and
 | 
			
		||||
         * are available in models, apis, and supporting files
 | 
			
		||||
         */
 | 
			
		||||
        additionalProperties.put("apiVersion", apiVersion);
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Supporting Files.  You can write single files for the generator with the
 | 
			
		||||
         * entire object tree available.  If the input file has a suffix of `.mustache
 | 
			
		||||
         * it will be processed by the template engine.  Otherwise, it will be copied
 | 
			
		||||
         */
 | 
			
		||||
        supportingFiles.add(new SupportingFile("composer.mustache", packagePath, "composer.json"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + "bootstrap", "app.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + "public", "index.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + "app", "User.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + "app"  + File.separator + "Console", "Kernel.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + "app"  + File.separator + "Exceptions", "Handler.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + "app"  + File.separator + "Http", "routes.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("composer.mustache", packagePath + File.separator + srcBasePath, "composer.json"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("readme.md", packagePath + File.separator + srcBasePath, "readme.md"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + srcBasePath + File.separator + "bootstrap", "app.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + srcBasePath + File.separator + "public", "index.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + srcBasePath + File.separator + "app", "User.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + srcBasePath + File.separator + "app"  + File.separator + "Console", "Kernel.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + srcBasePath + File.separator + "app"  + File.separator + "Exceptions", "Handler.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + srcBasePath + File.separator + "app"  + File.separator + "Http", "routes.php"));
 | 
			
		||||
        
 | 
			
		||||
        supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + "app"  + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + "app"  + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + srcBasePath + File.separator + "app"  + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + srcBasePath + File.separator + "app"  + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php"));
 | 
			
		||||
        
 | 
			
		||||
        /**
 | 
			
		||||
         * Language Specific Primitives.  These types will not trigger imports by
 | 
			
		||||
         * the client generator
 | 
			
		||||
         */
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>(
 | 
			
		||||
            Arrays.asList(
 | 
			
		||||
                "Type1",      // replace these with your types
 | 
			
		||||
                "Type2")
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
 | 
			
		||||
     * those terms here.  This logic is only called if a variable matches the reseved words
 | 
			
		||||
     * 
 | 
			
		||||
     * @return the escaped term
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeReservedWord(String name) {
 | 
			
		||||
        return "_" + name;  // add an underscore to the name
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Location to write model files.  You can use the modelPackage() as defined when the class is
 | 
			
		||||
     * instantiated
 | 
			
		||||
     */
 | 
			
		||||
    public String modelFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Location to write api files.  You can use the apiPackage() as defined when the class is
 | 
			
		||||
     * instantiated
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);//"/app/Http/controllers";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // override with any special post-processing
 | 
			
		||||
@ -185,57 +116,4 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Optional - type declaration.  This is a String which is used by the templates to instantiate your
 | 
			
		||||
     * types.  There is typically special handling for different property types
 | 
			
		||||
     *
 | 
			
		||||
     * @return a string value used as the `dataType` field for model templates, `returnType` for api templates
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if(p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
            return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Optional - swagger type conversion.  This is used to map swagger types in a `Property` into 
 | 
			
		||||
     * either language specific types via `typeMapping` or into complex models if there is not a mapping.
 | 
			
		||||
     *
 | 
			
		||||
     * @return a string value of the type or complex model for this property
 | 
			
		||||
     * @see io.swagger.models.properties.Property
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSwaggerType(Property p) {
 | 
			
		||||
        String swaggerType = super.getSwaggerType(p);
 | 
			
		||||
        String type = null;
 | 
			
		||||
        if(typeMapping.containsKey(swaggerType)) {
 | 
			
		||||
            type = typeMapping.get(swaggerType);
 | 
			
		||||
            if(languageSpecificPrimitives.contains(type))
 | 
			
		||||
                return toModelName(type);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
            type = swaggerType;
 | 
			
		||||
        return toModelName(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeQuotationMark(String input) {
 | 
			
		||||
        // remove ' to avoid code injection
 | 
			
		||||
        return input.replace("'", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("*/", "*_/").replace("/*", "/_*");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -222,7 +222,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void postProcessParentModels(final Map<String, Object> models) {
 | 
			
		||||
        log.info("Processing parents:  " + parentModels);
 | 
			
		||||
        log.debug("Processing parents:  " + parentModels);
 | 
			
		||||
        for (final String parent : parentModels) {
 | 
			
		||||
            final CodegenModel parentModel = modelByName(parent, models);
 | 
			
		||||
            parentModel.hasChildren = true;
 | 
			
		||||
@ -301,7 +301,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
 | 
			
		||||
        } else {
 | 
			
		||||
            result = enumName;
 | 
			
		||||
        }
 | 
			
		||||
        log.info(String.format("toEnumVarName('%s', %s) = '%s'", name, datatype, enumName));
 | 
			
		||||
        log.debug(String.format("toEnumVarName('%s', %s) = '%s'", name, datatype, enumName));
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -313,7 +313,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
 | 
			
		||||
        } else {
 | 
			
		||||
            apiName = capitalize(name);
 | 
			
		||||
        }
 | 
			
		||||
        log.info(String.format("toApiName('%s') = '%s'", name, apiName));
 | 
			
		||||
        log.debug(String.format("toApiName('%s') = '%s'", name, apiName));
 | 
			
		||||
        return apiName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -334,7 +334,7 @@ public class NancyFXServerCodegen extends AbstractCSharpCodegen {
 | 
			
		||||
        } else {
 | 
			
		||||
            result = null;
 | 
			
		||||
        }
 | 
			
		||||
        log.info(String.format("toModelImport('%s') = '%s'", name, result));
 | 
			
		||||
        log.debug(String.format("toModelImport('%s') = '%s'", name, result));
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
        // set the output folder here
 | 
			
		||||
        outputFolder = "generated-code/nodejs";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Models.  You can write model files using the modelTemplateFiles map.
 | 
			
		||||
         * if you want to create one template for file, you can do so here.
 | 
			
		||||
         * for multiple files for model, just put another entry in the `modelTemplateFiles` with
 | 
			
		||||
@ -42,7 +42,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
         */
 | 
			
		||||
        modelTemplateFiles.clear();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Api classes.  You can write classes for each Api file with the apiTemplateFiles map.
 | 
			
		||||
         * as with models, add multiple entries with different extensions for multiple files per
 | 
			
		||||
         * class
 | 
			
		||||
@ -51,13 +51,13 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
                "controller.mustache",   // the template to use
 | 
			
		||||
                ".js");       // the extension for each file to write
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Template Location.  This is the location which templates will be read from.  The generator
 | 
			
		||||
         * will use the resource stream to attempt to read the templates.
 | 
			
		||||
         */
 | 
			
		||||
        embeddedTemplateDir = templateDir = "nodejs";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Reserved words.  Override this with reserved words specific to your language
 | 
			
		||||
         */
 | 
			
		||||
        setReservedWordsLowerCase(
 | 
			
		||||
@ -69,14 +69,14 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
                        "void", "while", "with", "yield")
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Additional Properties.  These values can be passed to the templates and
 | 
			
		||||
         * are available in models, apis, and supporting files
 | 
			
		||||
         */
 | 
			
		||||
        additionalProperties.put("apiVersion", apiVersion);
 | 
			
		||||
        additionalProperties.put("serverPort", serverPort);
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Supporting Files.  You can write single files for the generator with the
 | 
			
		||||
         * entire object tree available.  If the input file has a suffix of `.mustache
 | 
			
		||||
         * it will be processed by the template engine.  Otherwise, it will be copied
 | 
			
		||||
@ -320,4 +320,14 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
        return removeNonNameElementToCamelCase(name, "[-:;#]");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("*/", "*_/").replace("/*", "/_*");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeQuotationMark(String input) {
 | 
			
		||||
        // remove " to avoid code injection
 | 
			
		||||
        return input.replace("\"", "");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -167,6 +167,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        cliOptions.add(new CliOption(AUTHOR_EMAIL, "Email to use in the podspec file.").defaultValue("apiteam@swagger.io"));
 | 
			
		||||
        cliOptions.add(new CliOption(GIT_REPO_URL, "URL for the git repo where this podspec should point to.")
 | 
			
		||||
                .defaultValue("https://github.com/swagger-api/swagger-codegen"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
 | 
			
		||||
                .defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@ -188,6 +190,14 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                    Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(POD_NAME)) {
 | 
			
		||||
            setPodName((String) additionalProperties.get(POD_NAME));
 | 
			
		||||
        }
 | 
			
		||||
@ -505,8 +515,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // if name starting with special word, escape with '_'
 | 
			
		||||
        for(int i =0; i < specialWords.length; i++) {
 | 
			
		||||
            if (name.matches("(?i:^" + specialWords[i] + ".*)"))
 | 
			
		||||
        for (String specialWord : specialWords) {
 | 
			
		||||
            if (name.matches("(?i:^" + specialWord + ".*)"))
 | 
			
		||||
                name = escapeSpecialWord(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -615,7 +625,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            StringProperty dp = (StringProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return "@\"" + dp.getDefault().toString() + "\"";
 | 
			
		||||
                return "@\"" + dp.getDefault() + "\"";
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            BooleanProperty dp = (BooleanProperty) p;
 | 
			
		||||
 | 
			
		||||
@ -42,6 +42,11 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    public PerlClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as perl does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        modelPackage = File.separatorChar + "Object";
 | 
			
		||||
        outputFolder = "generated-code" + File.separatorChar + "perl";
 | 
			
		||||
        modelTemplateFiles.put("object.mustache", ".pm");
 | 
			
		||||
@ -227,7 +232,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            StringProperty dp = (StringProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return "'" + dp.getDefault().toString() + "'";
 | 
			
		||||
                return "'" + dp.getDefault() + "'";
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            BooleanProperty dp = (BooleanProperty) p;
 | 
			
		||||
@ -396,9 +401,9 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
            p.example = "'" + p.example + "'";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isBoolean)) {
 | 
			
		||||
            if (Boolean.parseBoolean(p.example))
 | 
			
		||||
                p.example = new String("1");
 | 
			
		||||
                p.example = "1";
 | 
			
		||||
            else
 | 
			
		||||
                p.example = new String("0");
 | 
			
		||||
                p.example = "0";
 | 
			
		||||
        } else if (Boolean.TRUE.equals(p.isDateTime) || Boolean.TRUE.equals(p.isDate)) {
 | 
			
		||||
            p.example = "DateTime->from_epoch(epoch => str2time('" + p.example + "'))";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -13,6 +13,8 @@ import io.swagger.models.properties.*;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
@ -50,6 +52,11 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public PhpClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as php does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        supportsInheritance = true;
 | 
			
		||||
        outputFolder = "generated-code" + File.separator + "php";
 | 
			
		||||
        modelTemplateFiles.put("model.mustache", ".php");
 | 
			
		||||
@ -96,7 +103,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // provide primitives to mustache template
 | 
			
		||||
        String primitives = "'" + StringUtils.join(languageSpecificPrimitives, "', '") + "'";
 | 
			
		||||
        List sortedLanguageSpecificPrimitives= new ArrayList(languageSpecificPrimitives);
 | 
			
		||||
        Collections.sort(sortedLanguageSpecificPrimitives);
 | 
			
		||||
        String primitives = "'" + StringUtils.join(sortedLanguageSpecificPrimitives, "', '") + "'";
 | 
			
		||||
        additionalProperties.put("primitives", primitives);
 | 
			
		||||
 | 
			
		||||
        // ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
 | 
			
		||||
@ -132,6 +141,8 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next swagger-codegen release"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
 | 
			
		||||
                .defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPackagePath() {
 | 
			
		||||
@ -195,6 +206,14 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                    Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(PACKAGE_PATH)) {
 | 
			
		||||
            this.setPackagePath((String) additionalProperties.get(PACKAGE_PATH));
 | 
			
		||||
        } else {
 | 
			
		||||
@ -498,7 +517,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            StringProperty dp = (StringProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return "'" + dp.getDefault().toString() + "'";
 | 
			
		||||
                return "'" + dp.getDefault() + "'";
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            BooleanProperty dp = (BooleanProperty) p;
 | 
			
		||||
@ -617,7 +636,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public String toEnumVarName(String name, String datatype) {
 | 
			
		||||
        // number
 | 
			
		||||
        if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
 | 
			
		||||
            String varName = new String(name);
 | 
			
		||||
            String varName = name;
 | 
			
		||||
            varName = varName.replaceAll("-", "MINUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\+", "PLUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\.", "_DOT_");
 | 
			
		||||
@ -640,6 +659,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public String toEnumName(CodegenProperty property) {
 | 
			
		||||
        String enumName = underscore(toModelName(property.name)).toUpperCase();
 | 
			
		||||
 | 
			
		||||
        // remove [] for array or map of enum
 | 
			
		||||
        enumName = enumName.replace("[]", "");
 | 
			
		||||
 | 
			
		||||
        if (enumName.matches("\\d.*")) { // starts with number
 | 
			
		||||
            return "_" + enumName;
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
@ -33,6 +33,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
    public PythonClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as python does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        modelPackage = "models";
 | 
			
		||||
        apiPackage = "api";
 | 
			
		||||
        outputFolder = "generated-code" + File.separatorChar + "python";
 | 
			
		||||
@ -110,6 +114,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
                .defaultValue("1.0.0"));
 | 
			
		||||
        cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
 | 
			
		||||
                CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
 | 
			
		||||
                .defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@ -135,6 +141,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
            setPackageVersion("1.0.0");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                    Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
 | 
			
		||||
        additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
 | 
			
		||||
 | 
			
		||||
@ -199,7 +213,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
                        + "/pattern/modifiers convention. "+pattern+" is not valid.");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            String regex = pattern.substring(1, i).replace("'", "\'");
 | 
			
		||||
            String regex = pattern.substring(1, i).replace("'", "\\'");
 | 
			
		||||
            List<String> modifiers = new ArrayList<String>();
 | 
			
		||||
 | 
			
		||||
            for(char c : pattern.substring(i).toCharArray()) {
 | 
			
		||||
@ -486,7 +500,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            StringProperty dp = (StringProperty) p;
 | 
			
		||||
            if (dp.getDefault() != null) {
 | 
			
		||||
                return "'" + dp.getDefault().toString() + "'";
 | 
			
		||||
                return "'" + dp.getDefault() + "'";
 | 
			
		||||
            }
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            BooleanProperty dp = (BooleanProperty) p;
 | 
			
		||||
 | 
			
		||||
@ -11,6 +11,7 @@ import io.swagger.models.properties.DateTimeProperty;
 | 
			
		||||
import io.swagger.models.properties.DecimalProperty;
 | 
			
		||||
import io.swagger.models.properties.DoubleProperty;
 | 
			
		||||
import io.swagger.models.properties.FloatProperty;
 | 
			
		||||
import io.swagger.models.properties.BaseIntegerProperty;
 | 
			
		||||
import io.swagger.models.properties.IntegerProperty;
 | 
			
		||||
import io.swagger.models.properties.LongProperty;
 | 
			
		||||
import io.swagger.models.properties.MapProperty;
 | 
			
		||||
@ -40,7 +41,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        // set the output folder here
 | 
			
		||||
        outputFolder = "generated-code/qt5cpp";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Models.  You can write model files using the modelTemplateFiles map.
 | 
			
		||||
         * if you want to create one template for file, you can do so here.
 | 
			
		||||
         * for multiple files for model, just put another entry in the `modelTemplateFiles` with
 | 
			
		||||
@ -54,7 +55,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
                "model-body.mustache",
 | 
			
		||||
                ".cpp");
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Api classes.  You can write classes for each Api file with the apiTemplateFiles map.
 | 
			
		||||
         * as with models, add multiple entries with different extensions for multiple files per
 | 
			
		||||
         * class
 | 
			
		||||
@ -67,13 +68,13 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
                "api-body.mustache",   // the template to use
 | 
			
		||||
                ".cpp");       // the extension for each file to write
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Template Location.  This is the location which templates will be read from.  The generator
 | 
			
		||||
         * will use the resource stream to attempt to read the templates.
 | 
			
		||||
         */
 | 
			
		||||
        embeddedTemplateDir = templateDir = "qt5cpp";
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Reserved words.  Override this with reserved words specific to your language
 | 
			
		||||
         */
 | 
			
		||||
        setReservedWordsLowerCase(
 | 
			
		||||
@ -82,14 +83,14 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
                        "sample2")
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Additional Properties.  These values can be passed to the templates and
 | 
			
		||||
         * are available in models, apis, and supporting files
 | 
			
		||||
         */
 | 
			
		||||
        additionalProperties.put("apiVersion", apiVersion);
 | 
			
		||||
        additionalProperties().put("prefix", PREFIX);
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        /*
 | 
			
		||||
         * Language Specific Primitives.  These types will not trigger imports by
 | 
			
		||||
         * the client generator
 | 
			
		||||
         */
 | 
			
		||||
@ -124,6 +125,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        //TODO binary should be mapped to byte array
 | 
			
		||||
        // mapped to String as a workaround
 | 
			
		||||
        typeMapping.put("binary", "QString");
 | 
			
		||||
        typeMapping.put("ByteArray", "QByteArray");
 | 
			
		||||
 | 
			
		||||
        importMapping = new HashMap<String, String>();
 | 
			
		||||
 | 
			
		||||
@ -138,6 +140,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        systemIncludes.add("QMap");
 | 
			
		||||
        systemIncludes.add("QDate");
 | 
			
		||||
        systemIncludes.add("QDateTime");
 | 
			
		||||
        systemIncludes.add("QByteArray");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -268,6 +271,10 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
            return "0";
 | 
			
		||||
        } else if (p instanceof LongProperty) {
 | 
			
		||||
            return "0L";
 | 
			
		||||
        } else if (p instanceof BaseIntegerProperty) {
 | 
			
		||||
            // catchall for any other format of the swagger specifiction
 | 
			
		||||
            // integer type not explicitly handled above
 | 
			
		||||
            return "0";
 | 
			
		||||
        } else if (p instanceof DecimalProperty) {
 | 
			
		||||
            return "0.0";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
 | 
			
		||||
@ -30,6 +30,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public static final String MODULE_NAME = "moduleName";
 | 
			
		||||
    public static final String GEM_VERSION = "gemVersion";
 | 
			
		||||
    public static final String GEM_LICENSE = "gemLicense";
 | 
			
		||||
    public static final String GEM_REQUIRED_RUBY_VERSION = "gemRequiredRubyVersion";
 | 
			
		||||
    public static final String GEM_HOMEPAGE = "gemHomepage";
 | 
			
		||||
    public static final String GEM_SUMMARY = "gemSummary";
 | 
			
		||||
    public static final String GEM_DESCRIPTION = "gemDescription";
 | 
			
		||||
@ -42,6 +43,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    protected String specFolder = "spec";
 | 
			
		||||
    protected String libFolder = "lib";
 | 
			
		||||
    protected String gemLicense = "Apache-2.0";
 | 
			
		||||
    protected String gemRequiredRubyVersion = ">= 1.9";
 | 
			
		||||
    protected String gemHomepage = "http://swagger.io";
 | 
			
		||||
    protected String gemSummary = "A ruby wrapper for the swagger APIs";
 | 
			
		||||
    protected String gemDescription = "This gem maps to a swagger API";
 | 
			
		||||
@ -54,6 +56,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    public RubyClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as ruby does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        modelPackage = "models";
 | 
			
		||||
        apiPackage = "api";
 | 
			
		||||
        outputFolder = "generated-code" + File.separator + "ruby";
 | 
			
		||||
@ -138,6 +145,9 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        cliOptions.add(new CliOption(GEM_LICENSE, "gem license. ").
 | 
			
		||||
                defaultValue("Apache-2.0"));
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(GEM_REQUIRED_RUBY_VERSION, "gem required Ruby version. ").
 | 
			
		||||
                defaultValue(">= 1.9"));
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(GEM_HOMEPAGE, "gem homepage. ").
 | 
			
		||||
                defaultValue("http://swagger.io"));
 | 
			
		||||
 | 
			
		||||
@ -151,12 +161,23 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(GEM_AUTHOR_EMAIL, "gem author email (only one is supported)."));
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated").
 | 
			
		||||
                defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                    Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(GEM_NAME)) {
 | 
			
		||||
            setGemName((String) additionalProperties.get(GEM_NAME));
 | 
			
		||||
        }
 | 
			
		||||
@ -187,6 +208,10 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
            setGemLicense((String) additionalProperties.get(GEM_LICENSE));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(GEM_REQUIRED_RUBY_VERSION)) {
 | 
			
		||||
            setGemRequiredRubyVersion((String) additionalProperties.get(GEM_REQUIRED_RUBY_VERSION));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (additionalProperties.containsKey(GEM_HOMEPAGE)) {
 | 
			
		||||
            setGemHomepage((String) additionalProperties.get(GEM_HOMEPAGE));
 | 
			
		||||
        }
 | 
			
		||||
@ -225,7 +250,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
 | 
			
		||||
 | 
			
		||||
        // test files should not be overwritten
 | 
			
		||||
        writeOptional(outputFolder, new SupportingFile("rspec.mustache", "", ".rspec"));
 | 
			
		||||
@ -544,7 +568,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public String toEnumVarName(String name, String datatype) {
 | 
			
		||||
        // number
 | 
			
		||||
        if ("Integer".equals(datatype) || "Float".equals(datatype)) {
 | 
			
		||||
            String varName = new String(name);
 | 
			
		||||
            String varName = name;
 | 
			
		||||
            varName = varName.replaceAll("-", "MINUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\+", "PLUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\.", "_DOT_");
 | 
			
		||||
@ -693,6 +717,10 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        this.gemLicense = gemLicense;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setGemRequiredRubyVersion(String gemRequiredRubyVersion) {
 | 
			
		||||
        this.gemRequiredRubyVersion = gemRequiredRubyVersion;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setGemHomepage(String gemHomepage) {
 | 
			
		||||
        this.gemHomepage = gemHomepage;
 | 
			
		||||
    }
 | 
			
		||||
@ -723,4 +751,5 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("=end", "=_end").replace("=begin", "=_begin");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,40 +4,22 @@ import io.swagger.codegen.CliOption;
 | 
			
		||||
import io.swagger.codegen.CodegenConfig;
 | 
			
		||||
import io.swagger.codegen.CodegenConstants;
 | 
			
		||||
import io.swagger.codegen.CodegenType;
 | 
			
		||||
import io.swagger.codegen.DefaultCodegen;
 | 
			
		||||
import io.swagger.codegen.SupportingFile;
 | 
			
		||||
import io.swagger.models.properties.ArrayProperty;
 | 
			
		||||
import io.swagger.models.properties.BooleanProperty;
 | 
			
		||||
import io.swagger.models.properties.DateProperty;
 | 
			
		||||
import io.swagger.models.properties.DateTimeProperty;
 | 
			
		||||
import io.swagger.models.properties.DoubleProperty;
 | 
			
		||||
import io.swagger.models.properties.FloatProperty;
 | 
			
		||||
import io.swagger.models.properties.IntegerProperty;
 | 
			
		||||
import io.swagger.models.properties.LongProperty;
 | 
			
		||||
import io.swagger.models.properties.MapProperty;
 | 
			
		||||
import io.swagger.models.properties.Property;
 | 
			
		||||
import io.swagger.models.properties.StringProperty;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
 | 
			
		||||
public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    protected String invokerPackage = "io.swagger.client";
 | 
			
		||||
    protected String groupId = "io.swagger";
 | 
			
		||||
    protected String artifactId = "swagger-scala-client";
 | 
			
		||||
    protected String artifactVersion = "1.0.0";
 | 
			
		||||
    protected String sourceFolder = "src/main/scala";
 | 
			
		||||
public class ScalaClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
 | 
			
		||||
    protected String authScheme = "";
 | 
			
		||||
    protected String gradleWrapperPackage = "gradle.wrapper";
 | 
			
		||||
    protected boolean authPreemptive;
 | 
			
		||||
    protected boolean asyncHttpClient = !authScheme.isEmpty();
 | 
			
		||||
    protected String groupId = "io.swagger";
 | 
			
		||||
    protected String artifactId = "swagger-scala-client";
 | 
			
		||||
    protected String artifactVersion = "1.0.0";
 | 
			
		||||
 | 
			
		||||
    public ScalaClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
@ -117,25 +99,76 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
        typeMapping.put("binary", "String");
 | 
			
		||||
        typeMapping.put("ByteArray", "String");
 | 
			
		||||
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>(
 | 
			
		||||
                Arrays.asList(
 | 
			
		||||
                        "String",
 | 
			
		||||
                        "boolean",
 | 
			
		||||
                        "Boolean",
 | 
			
		||||
                        "Double",
 | 
			
		||||
                        "Int",
 | 
			
		||||
                        "Long",
 | 
			
		||||
                        "Float",
 | 
			
		||||
                        "Object",
 | 
			
		||||
                        "Any",
 | 
			
		||||
                        "List",
 | 
			
		||||
                        "Map")
 | 
			
		||||
        );
 | 
			
		||||
        instantiationTypes.put("array", "ListBuffer");
 | 
			
		||||
        instantiationTypes.put("map", "HashMap");
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
    
 | 
			
		||||
        if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) {
 | 
			
		||||
            setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setModelPropertyNaming(String naming) {
 | 
			
		||||
        if ("original".equals(naming) || "camelCase".equals(naming) ||
 | 
			
		||||
                "PascalCase".equals(naming) || "snake_case".equals(naming)) {
 | 
			
		||||
            this.modelPropertyNaming = naming;
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new IllegalArgumentException("Invalid model property naming '" +
 | 
			
		||||
                    naming + "'. Must be 'original', 'camelCase', " +
 | 
			
		||||
                    "'PascalCase' or 'snake_case'");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getModelPropertyNaming() {
 | 
			
		||||
        return this.modelPropertyNaming;
 | 
			
		||||
    }
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toVarName(String name) {
 | 
			
		||||
        // sanitize name
 | 
			
		||||
        name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
 | 
			
		||||
    
 | 
			
		||||
        if("_".equals(name)) {
 | 
			
		||||
          name = "_u";
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        // if it's all uppper case, do nothing
 | 
			
		||||
        if (name.matches("^[A-Z_]*$")) {
 | 
			
		||||
            return name;
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        name = getNameUsingModelPropertyNaming(name);
 | 
			
		||||
    
 | 
			
		||||
        // for reserved word or word starting with number, append _
 | 
			
		||||
        if (isReservedWord(name) || name.matches("^\\d.*")) {
 | 
			
		||||
            name = escapeReservedWord(name);
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toParamName(String name) {
 | 
			
		||||
        // should be the same as variable name
 | 
			
		||||
        return toVarName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getNameUsingModelPropertyNaming(String name) {
 | 
			
		||||
        switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) {
 | 
			
		||||
            case original:    return name;
 | 
			
		||||
            case camelCase:   return camelize(name, true);
 | 
			
		||||
            case PascalCase:  return camelize(name);
 | 
			
		||||
            case snake_case:  return underscore(name);
 | 
			
		||||
            default:          throw new IllegalArgumentException("Invalid model property naming '" +
 | 
			
		||||
                    name + "'. Must be 'original', 'camelCase', " +
 | 
			
		||||
                    "'PascalCase' or 'snake_case'");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@ -153,98 +186,6 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
        return "Generates a Scala client library.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeReservedWord(String name) {
 | 
			
		||||
        return "_" + name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String modelFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
 | 
			
		||||
            return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSwaggerType(Property p) {
 | 
			
		||||
        String swaggerType = super.getSwaggerType(p);
 | 
			
		||||
        String type = null;
 | 
			
		||||
        if (typeMapping.containsKey(swaggerType)) {
 | 
			
		||||
            type = typeMapping.get(swaggerType);
 | 
			
		||||
            if (languageSpecificPrimitives.contains(type)) {
 | 
			
		||||
                return toModelName(type);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            type = swaggerType;
 | 
			
		||||
        }
 | 
			
		||||
        return toModelName(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toInstantiationType(Property p) {
 | 
			
		||||
        if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty ap = (MapProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getAdditionalProperties());
 | 
			
		||||
            return instantiationTypes.get("map") + "[String, " + inner + "]";
 | 
			
		||||
        } else if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getItems());
 | 
			
		||||
            return instantiationTypes.get("array") + "[" + inner + "]";
 | 
			
		||||
        } else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toDefaultValue(Property p) {
 | 
			
		||||
        if (p instanceof StringProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof BooleanProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DateProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DateTimeProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof DoubleProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof FloatProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof IntegerProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof LongProperty) {
 | 
			
		||||
            return "null";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty ap = (MapProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getAdditionalProperties());
 | 
			
		||||
            return "new HashMap[String, " + inner + "]() ";
 | 
			
		||||
        } else if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            String inner = getSwaggerType(ap.getItems());
 | 
			
		||||
            return "new ListBuffer[" + inner + "]() ";
 | 
			
		||||
        } else {
 | 
			
		||||
            return "null";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toOperationId(String operationId) {
 | 
			
		||||
        // throw exception if method name is empty
 | 
			
		||||
@ -260,51 +201,6 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
        return camelize(operationId, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessModels(Map<String, Object> objs) {
 | 
			
		||||
        // remove model imports to avoid warnings for importing class in the same package in Scala
 | 
			
		||||
        List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
 | 
			
		||||
        final String prefix = modelPackage() + ".";
 | 
			
		||||
        Iterator<Map<String, String>> iterator = imports.iterator();
 | 
			
		||||
        while (iterator.hasNext()) {
 | 
			
		||||
            String _import = iterator.next().get("import");
 | 
			
		||||
            if (_import.startsWith(prefix)) iterator.remove();
 | 
			
		||||
        }
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toVarName(String name) {
 | 
			
		||||
        // sanitize name
 | 
			
		||||
        name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
 | 
			
		||||
 | 
			
		||||
        if("_".equals(name)) {
 | 
			
		||||
          name = "_u";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // if it's all uppper case, do nothing
 | 
			
		||||
        if (name.matches("^[A-Z_]*$")) {
 | 
			
		||||
            return name;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // camelize (lower first character) the variable name
 | 
			
		||||
        // pet_id => petId
 | 
			
		||||
        name = camelize(name, true);
 | 
			
		||||
 | 
			
		||||
        // for reserved word or word starting with number, append _
 | 
			
		||||
        if (isReservedWord(name) || name.matches("^\\d.*")) {
 | 
			
		||||
            name = escapeReservedWord(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toParamName(String name) {
 | 
			
		||||
        // should be the same as variable name
 | 
			
		||||
        return toVarName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toModelName(final String name) {
 | 
			
		||||
        final String sanitizedName = sanitizeName(modelNamePrefix + name + modelNameSuffix);
 | 
			
		||||
@ -330,21 +226,10 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
 | 
			
		||||
        return camelizedName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toModelFilename(String name) {
 | 
			
		||||
        // should be the same as the model name
 | 
			
		||||
        return toModelName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeQuotationMark(String input) {
 | 
			
		||||
        // remove " to avoid code injection
 | 
			
		||||
        return input.replace("\"", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("*/", "*_/").replace("/*", "/_*");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -5,25 +5,19 @@ import io.swagger.codegen.CodegenConfig;
 | 
			
		||||
import io.swagger.codegen.CodegenConstants;
 | 
			
		||||
import io.swagger.codegen.CodegenOperation;
 | 
			
		||||
import io.swagger.codegen.CodegenType;
 | 
			
		||||
import io.swagger.codegen.DefaultCodegen;
 | 
			
		||||
import io.swagger.codegen.SupportingFile;
 | 
			
		||||
import io.swagger.models.properties.ArrayProperty;
 | 
			
		||||
import io.swagger.models.properties.MapProperty;
 | 
			
		||||
import io.swagger.models.properties.Property;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    protected String invokerPackage = "io.swagger.client";
 | 
			
		||||
public class ScalatraServerCodegen extends AbstractScalaCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    protected String groupId = "io.swagger";
 | 
			
		||||
    protected String artifactId = "swagger-client";
 | 
			
		||||
    protected String artifactVersion = "1.0.0";
 | 
			
		||||
    protected String sourceFolder = "src/main/scala";
 | 
			
		||||
 | 
			
		||||
    public ScalatraServerCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
@ -93,17 +87,6 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf
 | 
			
		||||
        supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("sbt", "", "sbt"));
 | 
			
		||||
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>(
 | 
			
		||||
                Arrays.asList(
 | 
			
		||||
                        "String",
 | 
			
		||||
                        "boolean",
 | 
			
		||||
                        "Boolean",
 | 
			
		||||
                        "Double",
 | 
			
		||||
                        "Integer",
 | 
			
		||||
                        "Long",
 | 
			
		||||
                        "Float",
 | 
			
		||||
                        "Object")
 | 
			
		||||
        );
 | 
			
		||||
        instantiationTypes.put("array", "ArrayList");
 | 
			
		||||
        instantiationTypes.put("map", "HashMap");
 | 
			
		||||
 | 
			
		||||
@ -121,9 +104,6 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf
 | 
			
		||||
        importMapping.put("LocalDateTime", "org.joda.time.LocalDateTime");
 | 
			
		||||
        importMapping.put("LocalDate", "org.joda.time.LocalDate");
 | 
			
		||||
        importMapping.put("LocalTime", "org.joda.time.LocalTime");
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@ -141,71 +121,42 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf
 | 
			
		||||
        return "Generates a Scala server application with Scalatra.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeReservedWord(String name) {
 | 
			
		||||
        return "_" + name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String apiFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String modelFileFolder() {
 | 
			
		||||
        return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
 | 
			
		||||
        Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
 | 
			
		||||
        List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
 | 
			
		||||
        for (CodegenOperation op : operationList) {
 | 
			
		||||
            // force http method to lower case
 | 
			
		||||
            op.httpMethod = op.httpMethod.toLowerCase();
 | 
			
		||||
 
 | 
			
		||||
            String[] items = op.path.split("/", -1);
 | 
			
		||||
            String scalaPath = "";
 | 
			
		||||
            int pathParamIndex = 0;
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < items.length; ++i) {
 | 
			
		||||
                if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
 | 
			
		||||
                    scalaPath = scalaPath + ":" + items[i].replace("{", "").replace("}", "");
 | 
			
		||||
                    pathParamIndex++;
 | 
			
		||||
                } else {
 | 
			
		||||
                    scalaPath = scalaPath + items[i];
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (i != items.length -1) {
 | 
			
		||||
                    scalaPath = scalaPath + "/";
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            op.vendorExtensions.put("x-scalatra-path", scalaPath);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
 | 
			
		||||
            return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSwaggerType(Property p) {
 | 
			
		||||
        String swaggerType = super.getSwaggerType(p);
 | 
			
		||||
        String type = null;
 | 
			
		||||
        if (typeMapping.containsKey(swaggerType)) {
 | 
			
		||||
            type = typeMapping.get(swaggerType);
 | 
			
		||||
            if (languageSpecificPrimitives.contains(type)) {
 | 
			
		||||
                return toModelName(type);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            type = swaggerType;
 | 
			
		||||
        }
 | 
			
		||||
        return toModelName(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeQuotationMark(String input) {
 | 
			
		||||
        // remove " to avoid code injection
 | 
			
		||||
        return input.replace("\"", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String escapeUnsafeCharacters(String input) {
 | 
			
		||||
        return input.replace("*/", "*_/").replace("/*", "/_*");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -30,6 +30,10 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
 | 
			
		||||
    public SlimFrameworkServerCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as slim does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        invokerPackage = camelize("SwaggerServer");
 | 
			
		||||
 | 
			
		||||
        //String packagePath = "SwaggerServer";
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,6 @@ import io.swagger.codegen.*;
 | 
			
		||||
import io.swagger.models.Operation;
 | 
			
		||||
import io.swagger.models.Path;
 | 
			
		||||
import io.swagger.models.Swagger;
 | 
			
		||||
import org.apache.commons.lang3.BooleanUtils;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
@ -42,6 +41,9 @@ public class SpringCodegen extends AbstractJavaCodegen {
 | 
			
		||||
        additionalProperties.put(CONFIG_PACKAGE, configPackage);
 | 
			
		||||
        additionalProperties.put(BASE_PACKAGE, basePackage);
 | 
			
		||||
 | 
			
		||||
        // spring uses the jackson lib
 | 
			
		||||
        additionalProperties.put("jackson", "true");
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(TITLE, "server title name or client service name"));
 | 
			
		||||
        cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
 | 
			
		||||
        cliOptions.add(new CliOption(BASE_PACKAGE, "base package for generated code"));
 | 
			
		||||
@ -231,7 +233,7 @@ public class SpringCodegen extends AbstractJavaCodegen {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.additionalProperties.put("serverPort", port);
 | 
			
		||||
        if (swagger != null && swagger.getPaths() != null) {
 | 
			
		||||
        if (swagger.getPaths() != null) {
 | 
			
		||||
            for (String pathname : swagger.getPaths().keySet()) {
 | 
			
		||||
                Path path = swagger.getPath(pathname);
 | 
			
		||||
                if (path.getOperations() != null) {
 | 
			
		||||
@ -352,17 +354,22 @@ public class SpringCodegen extends AbstractJavaCodegen {
 | 
			
		||||
    public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
 | 
			
		||||
        super.postProcessModelProperty(model, property);
 | 
			
		||||
 | 
			
		||||
        if("null".equals(property.example)) {
 | 
			
		||||
        if ("null".equals(property.example)) {
 | 
			
		||||
            property.example = null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Add imports for Jackson
 | 
			
		||||
        if(!BooleanUtils.toBoolean(model.isEnum)) {
 | 
			
		||||
        if (!Boolean.TRUE.equals(model.isEnum)) {
 | 
			
		||||
            model.imports.add("JsonProperty");
 | 
			
		||||
 | 
			
		||||
            if(BooleanUtils.toBoolean(model.hasEnums)) {
 | 
			
		||||
            if (Boolean.TRUE.equals(model.hasEnums)) {
 | 
			
		||||
                model.imports.add("JsonValue");
 | 
			
		||||
            }
 | 
			
		||||
        } else { // enum class
 | 
			
		||||
            //Needed imports for Jackson's JsonCreator
 | 
			
		||||
            if (additionalProperties.containsKey("jackson")) {
 | 
			
		||||
                model.imports.add("JsonCreator");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,11 @@ public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
 | 
			
		||||
    public StaticDocCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as this generator does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        outputFolder = "docs";
 | 
			
		||||
        modelTemplateFiles.put("model.mustache", ".html");
 | 
			
		||||
        apiTemplateFiles.put("operation.mustache", ".html");
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,152 @@
 | 
			
		||||
package io.swagger.codegen.languages;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.*;
 | 
			
		||||
import io.swagger.models.Model;
 | 
			
		||||
import io.swagger.models.Operation;
 | 
			
		||||
import io.swagger.models.Swagger;
 | 
			
		||||
import io.swagger.models.properties.ArrayProperty;
 | 
			
		||||
import io.swagger.models.properties.MapProperty;
 | 
			
		||||
import io.swagger.models.properties.Property;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    protected String invokerPackage = "io.swagger.client";
 | 
			
		||||
    protected String groupId = "io.swagger";
 | 
			
		||||
    protected String artifactId = "swagger-client";
 | 
			
		||||
    protected String artifactVersion = "1.0.0";
 | 
			
		||||
 | 
			
		||||
    public StaticHtml2Generator() {
 | 
			
		||||
        super();
 | 
			
		||||
        outputFolder = "docs";
 | 
			
		||||
        embeddedTemplateDir = templateDir = "htmlDocs2";
 | 
			
		||||
 | 
			
		||||
        defaultIncludes = new HashSet<String>();
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption("appName", "short name of the application"));
 | 
			
		||||
        cliOptions.add(new CliOption("appDescription", "description of the application"));
 | 
			
		||||
        cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application"));
 | 
			
		||||
        cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application"));
 | 
			
		||||
        cliOptions.add(new CliOption("licenseInfo", "a short description of the license"));
 | 
			
		||||
        cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
 | 
			
		||||
        
 | 
			
		||||
        additionalProperties.put("appName", "Swagger Sample");
 | 
			
		||||
        additionalProperties.put("appDescription", "A sample swagger server");
 | 
			
		||||
        additionalProperties.put("infoUrl", "https://helloreverb.com");
 | 
			
		||||
        additionalProperties.put("infoEmail", "hello@helloreverb.com");
 | 
			
		||||
        additionalProperties.put("licenseInfo", "All rights reserved");
 | 
			
		||||
        additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
 | 
			
		||||
        additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
 | 
			
		||||
        additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
 | 
			
		||||
        additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
 | 
			
		||||
        additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
 | 
			
		||||
 | 
			
		||||
        supportingFiles.add(new SupportingFile("index.mustache", "", "index.html"));
 | 
			
		||||
        reservedWords = new HashSet<String>();
 | 
			
		||||
 | 
			
		||||
        languageSpecificPrimitives = new HashSet<String>();
 | 
			
		||||
        importMapping = new HashMap<String, String>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public CodegenType getTag() {
 | 
			
		||||
        return CodegenType.DOCUMENTATION;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return "html2";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getHelp() {
 | 
			
		||||
        return "Generates a static HTML file.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getTypeDeclaration(Property p) {
 | 
			
		||||
        if (p instanceof ArrayProperty) {
 | 
			
		||||
            ArrayProperty ap = (ArrayProperty) p;
 | 
			
		||||
            Property inner = ap.getItems();
 | 
			
		||||
            return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        } else if (p instanceof MapProperty) {
 | 
			
		||||
            MapProperty mp = (MapProperty) p;
 | 
			
		||||
            Property inner = mp.getAdditionalProperties();
 | 
			
		||||
 | 
			
		||||
            return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]";
 | 
			
		||||
        }
 | 
			
		||||
        return super.getTypeDeclaration(p);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
 | 
			
		||||
        Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
 | 
			
		||||
        List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
 | 
			
		||||
        for (CodegenOperation op : operationList) {
 | 
			
		||||
            op.httpMethod = op.httpMethod.toLowerCase();
 | 
			
		||||
        }
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
 | 
			
		||||
        CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, swagger);
 | 
			
		||||
        if (op.returnType != null) {
 | 
			
		||||
            op.returnType = normalizeType(op.returnType);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //path is an unescaped variable in the mustache template api.mustache line 82 '<&path>'
 | 
			
		||||
        op.path = sanitizePath(op.path);
 | 
			
		||||
 | 
			
		||||
        // Set vendor-extension to be used in template:
 | 
			
		||||
        //     x-codegen-hasMoreRequired
 | 
			
		||||
        //     x-codegen-hasMoreOptional
 | 
			
		||||
        //     x-codegen-hasRequiredParams
 | 
			
		||||
        CodegenParameter lastRequired = null;
 | 
			
		||||
        CodegenParameter lastOptional = null;
 | 
			
		||||
        for (CodegenParameter p : op.allParams) {
 | 
			
		||||
            if (p.required != null && p.required) {
 | 
			
		||||
                lastRequired = p;
 | 
			
		||||
            } else {
 | 
			
		||||
                lastOptional = p;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        for (CodegenParameter p : op.allParams) {
 | 
			
		||||
            if (p == lastRequired) {
 | 
			
		||||
                p.vendorExtensions.put("x-codegen-hasMoreRequired", false);
 | 
			
		||||
            } else if (p == lastOptional) {
 | 
			
		||||
                p.vendorExtensions.put("x-codegen-hasMoreOptional", false);
 | 
			
		||||
            } else {
 | 
			
		||||
                p.vendorExtensions.put("x-codegen-hasMoreRequired", true);
 | 
			
		||||
                p.vendorExtensions.put("x-codegen-hasMoreOptional", true);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        op.vendorExtensions.put("x-codegen-hasRequiredParams", lastRequired != null);
 | 
			
		||||
 | 
			
		||||
        return op;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private String sanitizePath(String p) {
 | 
			
		||||
        //prefer replace a ', instead of a fuLL URL encode for readability
 | 
			
		||||
        return p.replaceAll("'", "%27");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Normalize type by wrapping primitive types with single quotes.
 | 
			
		||||
     *
 | 
			
		||||
     * @param type Primitive type
 | 
			
		||||
     * @return Normalized type
 | 
			
		||||
     */
 | 
			
		||||
    public String normalizeType(String type) {
 | 
			
		||||
        return type.replaceAll("\\b(Boolean|Integer|Number|String|Date)\\b", "'$1'");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -19,12 +19,10 @@ import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    private static final String ALL_OPERATIONS = "";
 | 
			
		||||
    protected String invokerPackage = "io.swagger.client";
 | 
			
		||||
    protected String groupId = "io.swagger";
 | 
			
		||||
    protected String artifactId = "swagger-client";
 | 
			
		||||
    protected String artifactVersion = "1.0.0";
 | 
			
		||||
    protected String sourceFolder = "src/main/scala";
 | 
			
		||||
 | 
			
		||||
    public StaticHtmlGenerator() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
@ -1,27 +1,28 @@
 | 
			
		||||
package io.swagger.codegen.languages;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.*;
 | 
			
		||||
import io.swagger.models.Swagger;
 | 
			
		||||
import io.swagger.util.Yaml;
 | 
			
		||||
import org.apache.commons.io.FileUtils;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.CodegenConfig;
 | 
			
		||||
import io.swagger.codegen.CodegenType;
 | 
			
		||||
import io.swagger.codegen.DefaultCodegen;
 | 
			
		||||
import io.swagger.codegen.SupportingFile;
 | 
			
		||||
import io.swagger.models.Swagger;
 | 
			
		||||
import io.swagger.util.Yaml;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
 | 
			
		||||
public class SwaggerYamlGenerator extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public static final String OUTPUT_NAME = "outputFile";
 | 
			
		||||
 | 
			
		||||
    private static final Logger LOGGER = LoggerFactory.getLogger(SwaggerYamlGenerator.class);
 | 
			
		||||
 | 
			
		||||
    protected String outputFile = "swagger.yaml";
 | 
			
		||||
 | 
			
		||||
    public SwaggerYamlGenerator() {
 | 
			
		||||
        super();
 | 
			
		||||
        embeddedTemplateDir = templateDir = "swagger";
 | 
			
		||||
        outputFolder = "generated-code/swagger";
 | 
			
		||||
 | 
			
		||||
        cliOptions.add(new CliOption(OUTPUT_NAME, "output filename"));
 | 
			
		||||
 | 
			
		||||
        supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -40,11 +41,20 @@ public class SwaggerYamlGenerator extends DefaultCodegen implements CodegenConfi
 | 
			
		||||
        return "Creates a static swagger.yaml file.";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
        if(additionalProperties.containsKey(OUTPUT_NAME)) {
 | 
			
		||||
            this.outputFile = additionalProperties.get(OUTPUT_NAME).toString();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processSwagger(Swagger swagger) {
 | 
			
		||||
        try {
 | 
			
		||||
            String swaggerString = Yaml.mapper().writeValueAsString(swagger);
 | 
			
		||||
            String outputFile = outputFolder + File.separator + "swagger.yaml";
 | 
			
		||||
            String outputFile = outputFolder + File.separator + this.outputFile;
 | 
			
		||||
            FileUtils.writeStringToFile(new File(outputFile), swaggerString);
 | 
			
		||||
            LOGGER.debug("wrote file to " + outputFile);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
    public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace";
 | 
			
		||||
    public static final String DEFAULT_POD_AUTHORS = "Swagger Codegen";
 | 
			
		||||
    protected static final String LIBRARY_PROMISE_KIT = "PromiseKit";
 | 
			
		||||
    protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT };
 | 
			
		||||
    protected static final String LIBRARY_RX_SWIFT = "RxSwift";
 | 
			
		||||
    protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT, LIBRARY_RX_SWIFT };
 | 
			
		||||
    protected String projectName = "SwaggerClient";
 | 
			
		||||
    protected boolean unwrapRequired;
 | 
			
		||||
    protected boolean swiftUseApiNamespace;
 | 
			
		||||
@ -153,11 +154,21 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        cliOptions.add(new CliOption(POD_SCREENSHOTS, "Screenshots used for Podspec"));
 | 
			
		||||
        cliOptions.add(new CliOption(POD_DOCUMENTATION_URL, "Documentation URL used for Podspec"));
 | 
			
		||||
        cliOptions.add(new CliOption(SWIFT_USE_API_NAMESPACE, "Flag to make all the API classes inner-class of {{projectName}}API"));
 | 
			
		||||
        cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
 | 
			
		||||
                .defaultValue(Boolean.TRUE.toString()));
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void processOpts() {
 | 
			
		||||
        super.processOpts();
 | 
			
		||||
        // default HIDE_GENERATION_TIMESTAMP to true
 | 
			
		||||
        if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
 | 
			
		||||
                    Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Setup project name
 | 
			
		||||
        if (additionalProperties.containsKey(PROJECT_NAME)) {
 | 
			
		||||
@ -186,6 +197,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        if (ArrayUtils.contains(responseAs, LIBRARY_PROMISE_KIT)) {
 | 
			
		||||
            additionalProperties.put("usePromiseKit", true);
 | 
			
		||||
        }
 | 
			
		||||
        if (ArrayUtils.contains(responseAs, LIBRARY_RX_SWIFT)) {
 | 
			
		||||
            additionalProperties.put("useRxSwift", true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Setup swiftUseApiNamespace option, which makes all the API classes inner-class of {{projectName}}API
 | 
			
		||||
        if (additionalProperties.containsKey(SWIFT_USE_API_NAMESPACE)) {
 | 
			
		||||
@ -347,10 +361,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
            List<Map<String, String>> swiftEnums = new ArrayList<Map<String, String>>();
 | 
			
		||||
            List<String> values = (List<String>) codegenProperty.allowableValues.get("values");
 | 
			
		||||
            
 | 
			
		||||
            for (String value : values) {
 | 
			
		||||
            for (Object value : values) {
 | 
			
		||||
                Map<String, String> map = new HashMap<String, String>();
 | 
			
		||||
                map.put("enum", toSwiftyEnumName(value));
 | 
			
		||||
                map.put("raw", value);
 | 
			
		||||
                map.put("enum", toSwiftyEnumName(String.valueOf(value)));
 | 
			
		||||
                map.put("raw", String.valueOf(value));
 | 
			
		||||
                swiftEnums.add(map);
 | 
			
		||||
            }
 | 
			
		||||
            codegenProperty.allowableValues.put("values", swiftEnums);
 | 
			
		||||
@ -524,7 +538,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
 | 
			
		||||
        // TODO: this code is probably useless, because the var name is computed from the value in map.put("enum", toSwiftyEnumName(value));
 | 
			
		||||
        // number
 | 
			
		||||
        if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
 | 
			
		||||
            String varName = new String(name);
 | 
			
		||||
            String varName = name;
 | 
			
		||||
            varName = varName.replaceAll("-", "MINUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\+", "PLUS_");
 | 
			
		||||
            varName = varName.replaceAll("\\.", "_DOT_");
 | 
			
		||||
 | 
			
		||||
@ -3,10 +3,13 @@ package io.swagger.codegen.languages;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.text.SimpleDateFormat;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.CliOption;
 | 
			
		||||
import io.swagger.codegen.CodegenModel;
 | 
			
		||||
import io.swagger.codegen.CodegenParameter;
 | 
			
		||||
import io.swagger.codegen.CodegenOperation;
 | 
			
		||||
import io.swagger.codegen.SupportingFile;
 | 
			
		||||
import io.swagger.models.ModelImpl;
 | 
			
		||||
import io.swagger.models.properties.ArrayProperty;
 | 
			
		||||
@ -68,6 +71,7 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
 | 
			
		||||
        supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
 | 
			
		||||
        supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
 | 
			
		||||
 | 
			
		||||
@ -162,6 +166,46 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
 | 
			
		||||
        parameter.dataType = addModelPrefix(parameter.dataType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessOperations(Map<String, Object> operations) {
 | 
			
		||||
        Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
 | 
			
		||||
        List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
 | 
			
		||||
        for (CodegenOperation op : ops) {
 | 
			
		||||
            // Convert httpMethod to Angular's RequestMethod enum
 | 
			
		||||
            // https://angular.io/docs/ts/latest/api/http/index/RequestMethod-enum.html
 | 
			
		||||
            switch (op.httpMethod) {
 | 
			
		||||
                case "GET":
 | 
			
		||||
                    op.httpMethod = "RequestMethod.Get";
 | 
			
		||||
                    break;
 | 
			
		||||
                case "POST":
 | 
			
		||||
                    op.httpMethod = "RequestMethod.Post";
 | 
			
		||||
                    break;
 | 
			
		||||
                case "PUT":
 | 
			
		||||
                    op.httpMethod = "RequestMethod.Put";
 | 
			
		||||
                    break;
 | 
			
		||||
                case "DELETE":
 | 
			
		||||
                    op.httpMethod = "RequestMethod.Delete";
 | 
			
		||||
                    break;
 | 
			
		||||
                case "OPTIONS":
 | 
			
		||||
                    op.httpMethod = "RequestMethod.Options";
 | 
			
		||||
                    break;
 | 
			
		||||
                case "HEAD":
 | 
			
		||||
                    op.httpMethod = "RequestMethod.Head";
 | 
			
		||||
                    break;
 | 
			
		||||
                case "PATCH":
 | 
			
		||||
                    op.httpMethod = "RequestMethod.Patch";
 | 
			
		||||
                    break;
 | 
			
		||||
                default:
 | 
			
		||||
                    throw new RuntimeException("Unknown HTTP Method " + op.httpMethod + " not allowed");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Convert path to TypeScript template string
 | 
			
		||||
            op.path = op.path.replaceAll("\\{(.*?)\\}", "\\$\\{$1\\}");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return operations;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getNpmName() {
 | 
			
		||||
        return npmName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,14 @@
 | 
			
		||||
package io.swagger.codegen.languages;
 | 
			
		||||
 | 
			
		||||
import io.swagger.codegen.CliOption;
 | 
			
		||||
import io.swagger.codegen.CodegenModel;
 | 
			
		||||
import io.swagger.codegen.CodegenProperty;
 | 
			
		||||
import io.swagger.codegen.SupportingFile;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.TreeSet;
 | 
			
		||||
 | 
			
		||||
public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodegen {
 | 
			
		||||
 | 
			
		||||
@ -15,6 +20,11 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
 | 
			
		||||
 | 
			
		||||
    public TypeScriptFetchClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as TS does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        outputFolder = "generated-code/typescript-fetch";
 | 
			
		||||
        embeddedTemplateDir = templateDir = "TypeScript-Fetch";
 | 
			
		||||
        this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
 | 
			
		||||
@ -67,4 +77,24 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
 | 
			
		||||
        this.npmVersion = npmVersion;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Map<String, Object> postProcessModels(Map<String, Object> objs) {
 | 
			
		||||
        // process enum in models
 | 
			
		||||
        List<Object> models = (List<Object>) postProcessModelsEnum(objs).get("models");
 | 
			
		||||
        for (Object _mo : models) {
 | 
			
		||||
            Map<String, Object> mo = (Map<String, Object>) _mo;
 | 
			
		||||
            CodegenModel cm = (CodegenModel) mo.get("model");
 | 
			
		||||
            cm.imports = new TreeSet(cm.imports);
 | 
			
		||||
            for (CodegenProperty var : cm.vars) {
 | 
			
		||||
                // name enum with model name, e.g. StatuEnum => PetStatusEnum
 | 
			
		||||
                if (Boolean.TRUE.equals(var.isEnum)) {
 | 
			
		||||
                    var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + var.enumName);
 | 
			
		||||
                    var.enumName = cm.classname + var.enumName;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return objs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,11 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
 | 
			
		||||
 | 
			
		||||
    public TypeScriptNodeClientCodegen() {
 | 
			
		||||
        super();
 | 
			
		||||
 | 
			
		||||
        // clear import mapping (from default generator) as TS does not use it
 | 
			
		||||
        // at the moment
 | 
			
		||||
        importMapping.clear();
 | 
			
		||||
 | 
			
		||||
        outputFolder = "generated-code/typescript-node";
 | 
			
		||||
        embeddedTemplateDir = templateDir = "typescript-node";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -497,9 +497,16 @@ public class ApiClient {
 | 
			
		||||
    if (contentType.startsWith("multipart/form-data")) {
 | 
			
		||||
      FormDataMultiPart mp = new FormDataMultiPart();
 | 
			
		||||
      for (Entry<String, Object> param: formParams.entrySet()) {
 | 
			
		||||
        if (param.getValue() instanceof File) {
 | 
			
		||||
        if( param.getValue() instanceof List && !( ( List ) param.getValue() ).isEmpty()
 | 
			
		||||
                  && ( ( List ) param.getValue() ).get( 0 ) instanceof File ) {
 | 
			
		||||
            @SuppressWarnings( "unchecked" )
 | 
			
		||||
            List<File> files = ( List<File> ) param.getValue();
 | 
			
		||||
            for( File file : files ) {
 | 
			
		||||
              mp.bodyPart( new FileDataBodyPart( param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE ) );
 | 
			
		||||
            }
 | 
			
		||||
        } else if (param.getValue() instanceof File) {
 | 
			
		||||
          File file = (File) param.getValue();
 | 
			
		||||
          mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
 | 
			
		||||
          mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
 | 
			
		||||
        } else {
 | 
			
		||||
          mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -60,7 +60,7 @@ Please follow the [installation](#installation) instruction and execute the foll
 | 
			
		||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
 | 
			
		||||
import {{{invokerPackage}}}.*;
 | 
			
		||||
import {{{invokerPackage}}}.auth.*;
 | 
			
		||||
import {{{invokerPackage}}}.model.*;
 | 
			
		||||
import {{{modelPackage}}}.*;
 | 
			
		||||
import {{{package}}}.{{{classname}}};
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
@ -140,7 +140,7 @@ Class | Method | HTTP request | Description
 | 
			
		||||
 | 
			
		||||
## Recommendation
 | 
			
		||||
 | 
			
		||||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue.
 | 
			
		||||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
 | 
			
		||||
 | 
			
		||||
## Author
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,7 @@ After the client library is installed/deployed, you can use it in your Maven pro
 | 
			
		||||
 | 
			
		||||
## Recommendation
 | 
			
		||||
 | 
			
		||||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue.
 | 
			
		||||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
 | 
			
		||||
 | 
			
		||||
## Author
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@ public interface {{classname}} extends ApiClient.Api {
 | 
			
		||||
  @Headers({
 | 
			
		||||
    "Content-type: {{vendorExtensions.x-contentType}}",
 | 
			
		||||
    "Accept: {{vendorExtensions.x-accepts}}",{{#headerParams}}
 | 
			
		||||
    "{{paramName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
 | 
			
		||||
    "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
 | 
			
		||||
    {{/hasMore}}{{/headerParams}}
 | 
			
		||||
  })
 | 
			
		||||
  {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^isBodyParam}}@Param("{{paramName}}") {{/isBodyParam}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
 | 
			
		||||
 | 
			
		||||
@ -95,6 +95,11 @@
 | 
			
		||||
          </execution>
 | 
			
		||||
        </executions>
 | 
			
		||||
      </plugin>
 | 
			
		||||
      <plugin>
 | 
			
		||||
        <groupId>org.apache.maven.plugins</groupId>
 | 
			
		||||
        <artifactId>maven-javadoc-plugin</artifactId>
 | 
			
		||||
        <version>2.10.4</version>
 | 
			
		||||
      </plugin>
 | 
			
		||||
    </plugins>
 | 
			
		||||
  </build>
 | 
			
		||||
  <dependencies>
 | 
			
		||||
 | 
			
		||||
@ -498,8 +498,15 @@ public class ApiClient {
 | 
			
		||||
   * Deserialize response body to Java object according to the Content-Type.
 | 
			
		||||
   */
 | 
			
		||||
  public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
 | 
			
		||||
    if (response == null || returnType == null) {
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ("byte[]".equals(returnType.toString())) {
 | 
			
		||||
      // Handle binary response (byte array).
 | 
			
		||||
      return (T) response.readEntity(byte[].class);
 | 
			
		||||
    } else if (returnType.equals(File.class)) {
 | 
			
		||||
      // Handle file downloading.
 | 
			
		||||
    if (returnType.equals(File.class)) {
 | 
			
		||||
      @SuppressWarnings("unchecked")
 | 
			
		||||
      T file = (T) downloadFileFromResponse(response);
 | 
			
		||||
      return file;
 | 
			
		||||
 | 
			
		||||
@ -110,6 +110,11 @@
 | 
			
		||||
          {{/java8}}
 | 
			
		||||
        </configuration>
 | 
			
		||||
      </plugin>
 | 
			
		||||
      <plugin>
 | 
			
		||||
        <groupId>org.apache.maven.plugins</groupId>
 | 
			
		||||
        <artifactId>maven-javadoc-plugin</artifactId>
 | 
			
		||||
        <version>2.10.4</version>
 | 
			
		||||
      </plugin>
 | 
			
		||||
    </plugins>
 | 
			
		||||
  </build>
 | 
			
		||||
  <dependencies>
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,7 @@ import java.util.Map;
 | 
			
		||||
/**
 | 
			
		||||
 * API response returned by API call.
 | 
			
		||||
 *
 | 
			
		||||
 * @param T The type of data that is deserialized from response body
 | 
			
		||||
 * @param <T> The type of data that is deserialized from response body
 | 
			
		||||
 */
 | 
			
		||||
public class ApiResponse<T> {
 | 
			
		||||
    final private int statusCode;
 | 
			
		||||
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user