Compare commits

..

1023 Commits

Author SHA1 Message Date
Tony Tam
12531943d0 Merge pull request #438 from swagger-api/develop_2.0
merged to master for patch release
2015-02-17 21:48:20 -08:00
Tony Tam
3061cd8277 put parser back to 1.0.0 2015-02-17 21:41:36 -08:00
Tony Tam
686f3656c5 updated to new patch 2015-02-17 21:38:02 -08:00
Tony Tam
9ae106affd rebuilt clients 2015-02-17 21:37:51 -08:00
Tony Tam
2550539495 added shade plugin to properly include service descriptions 2015-02-17 18:54:57 -08:00
Tony Tam
06164cdc51 updated file separator replacement 2015-02-17 15:04:06 -08:00
Tony Tam
583a932fba Merge pull request #436 from kreymerman/patch-python-codegen
Fix StringIndexOutOfBoundsException on Windows
2015-02-17 15:02:58 -08:00
Mikhail Kreymerman
fdd485608f fixed StringIndexOutOfBoundsException on Windows 2015-02-17 23:00:23 +01:00
Tony Tam
0307d3818a added friendly download links 2015-02-17 12:59:31 -08:00
Tony Tam
9a473ceae6 enabled url-only reading of specs 2015-02-17 12:43:10 -08:00
Tony Tam
12365b9591 removed cruft 2015-02-17 12:43:01 -08:00
Tony Tam
c832889db8 added slf4j, updated server gen logic 2015-02-17 11:15:08 -08:00
Tony Tam
39487d9917 disabled outdated routes, made languages GET method dynamic 2015-02-17 10:29:35 -08:00
Tony Tam
aa37542411 added version to make swagger valid 2015-02-17 10:29:06 -08:00
Tony Tam
279f43d697 Update README.md 2015-02-17 08:57:39 -08:00
Tony Tam
fee6de5974 Merge branch 'geoand-jackson_array' into develop_2.0 2015-02-17 07:08:55 -08:00
gandrianakis
5fa98b12b8 Fixed bug that did not allow json arrays to be deserialized by Jackson 2015-02-17 15:17:32 +02:00
Tony Tam
ff94196295 updated to snapshot version 2015-02-16 22:16:40 -08:00
Tony Tam
0195749f3b merged 2015-02-16 22:08:52 -08:00
Tony Tam
97fca910a1 removed cruft 2015-02-16 22:06:10 -08:00
Tony Tam
577aad3364 added file 2015-02-16 22:02:27 -08:00
Tony Tam
05c6cc756c remove cruft 2015-02-16 22:01:33 -08:00
Tony Tam
66c6662f42 cleaned up poms 2015-02-16 21:53:51 -08:00
Tony Tam
6319167464 added placeholder for javadocs 2015-02-16 21:53:43 -08:00
Tony Tam
aea2909490 Merge pull request #434 from swagger-api/develop_2.0
Merged from develop_2.0
2015-02-16 21:16:09 -08:00
Tony Tam
842421bb44 Merge pull request #433 from tfoxcroft/develop_2.0
Minor fix to cater for empty array in php
2015-02-16 21:14:56 -08:00
Terence Foxcroft
c6f10ef1ea Minor fix to cater for empty array 2015-02-17 07:10:08 +02:00
Tony Tam
3df04839a6 Update README.md 2015-02-16 21:03:36 -08:00
Tony Tam
618b4698c2 Merge branch 'develop_2.0'
Conflicts:
	README.md
	bin/Version.scala
	build.sbt
	modules/swagger-codegen/src/main/resources/Java/api.mustache
	modules/swagger-codegen/src/main/resources/android-java/api.mustache
	modules/swagger-codegen/src/main/resources/nodejs/api.mustache
	modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h
	modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m
	modules/swagger-codegen/src/main/resources/objc/SWGDate.h
	modules/swagger-codegen/src/main/resources/objc/SWGDate.m
	modules/swagger-codegen/src/main/resources/objc/SWGFile.m
	modules/swagger-codegen/src/main/resources/objc/SWGObject.h
	modules/swagger-codegen/src/main/resources/objc/SWGObject.m
	modules/swagger-codegen/src/main/resources/objc/api-header.mustache
	modules/swagger-codegen/src/main/resources/php/api.mustache
	modules/swagger-codegen/src/main/resources/python/api.mustache
	modules/swagger-codegen/src/main/resources/scala/apiInvoker.mustache
	modules/swagger-codegen/src/main/resources/scala/pom.mustache
	project/build.properties
	samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java
	samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java
	samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java
	samples/client/petstore/scala/pom.xml
	samples/client/petstore/scala/src/test/scala/PetApiTest.scala
	samples/client/petstore/scala/src/test/scala/StoreApiTest.scala
	samples/client/petstore/scala/src/test/scala/UserApiTest.scala
	samples/client/wordnik-apiobjc/client/SWGAccountApi.h
	samples/client/wordnik-apiobjc/client/SWGAccountApi.m
	samples/client/wordnik-apiobjc/client/SWGApiClient.h
	samples/client/wordnik-apiobjc/client/SWGApiClient.m
	samples/client/wordnik-apiobjc/client/SWGApiTokenStatus.h
	samples/client/wordnik-apiobjc/client/SWGAudioFile.h
	samples/client/wordnik-apiobjc/client/SWGAuthenticationToken.h
	samples/client/wordnik-apiobjc/client/SWGBigram.h
	samples/client/wordnik-apiobjc/client/SWGCitation.h
	samples/client/wordnik-apiobjc/client/SWGCitation.m
	samples/client/wordnik-apiobjc/client/SWGContentProvider.h
	samples/client/wordnik-apiobjc/client/SWGContentProvider.m
	samples/client/wordnik-apiobjc/client/SWGDate.h
	samples/client/wordnik-apiobjc/client/SWGDate.m
	samples/client/wordnik-apiobjc/client/SWGDefinition.h
	samples/client/wordnik-apiobjc/client/SWGDefinition.m
	samples/client/wordnik-apiobjc/client/SWGDefinitionSearchResults.h
	samples/client/wordnik-apiobjc/client/SWGDefinitionSearchResults.m
	samples/client/wordnik-apiobjc/client/SWGExample.h
	samples/client/wordnik-apiobjc/client/SWGExample.m
	samples/client/wordnik-apiobjc/client/SWGExampleSearchResults.h
	samples/client/wordnik-apiobjc/client/SWGExampleSearchResults.m
	samples/client/wordnik-apiobjc/client/SWGExampleUsage.h
	samples/client/wordnik-apiobjc/client/SWGExampleUsage.m
	samples/client/wordnik-apiobjc/client/SWGFacet.h
	samples/client/wordnik-apiobjc/client/SWGFacet.m
	samples/client/wordnik-apiobjc/client/SWGFacetValue.h
	samples/client/wordnik-apiobjc/client/SWGFacetValue.m
	samples/client/wordnik-apiobjc/client/SWGFile.h
	samples/client/wordnik-apiobjc/client/SWGFile.m
	samples/client/wordnik-apiobjc/client/SWGFrequency.h
	samples/client/wordnik-apiobjc/client/SWGFrequency.m
	samples/client/wordnik-apiobjc/client/SWGFrequencySummary.h
	samples/client/wordnik-apiobjc/client/SWGFrequencySummary.m
	samples/client/wordnik-apiobjc/client/SWGLabel.h
	samples/client/wordnik-apiobjc/client/SWGLabel.m
	samples/client/wordnik-apiobjc/client/SWGNote.h
	samples/client/wordnik-apiobjc/client/SWGObject.h
	samples/client/wordnik-apiobjc/client/SWGObject.m
	samples/client/wordnik-apiobjc/client/SWGRelated.h
	samples/client/wordnik-apiobjc/client/SWGScoredWord.h
	samples/client/wordnik-apiobjc/client/SWGSentence.h
	samples/client/wordnik-apiobjc/client/SWGSentence.m
	samples/client/wordnik-apiobjc/client/SWGSimpleDefinition.h
	samples/client/wordnik-apiobjc/client/SWGSimpleExample.h
	samples/client/wordnik-apiobjc/client/SWGStringValue.h
	samples/client/wordnik-apiobjc/client/SWGStringValue.m
	samples/client/wordnik-apiobjc/client/SWGSyllable.h
	samples/client/wordnik-apiobjc/client/SWGTextPron.h
	samples/client/wordnik-apiobjc/client/SWGUser.h
	samples/client/wordnik-apiobjc/client/SWGWordApi.h
	samples/client/wordnik-apiobjc/client/SWGWordList.h
	samples/client/wordnik-apiobjc/client/SWGWordList.m
	samples/client/wordnik-apiobjc/client/SWGWordListApi.h
	samples/client/wordnik-apiobjc/client/SWGWordListApi.m
	samples/client/wordnik-apiobjc/client/SWGWordListWord.h
	samples/client/wordnik-apiobjc/client/SWGWordListsApi.h
	samples/client/wordnik-apiobjc/client/SWGWordListsApi.m
	samples/client/wordnik-apiobjc/client/SWGWordObject.h
	samples/client/wordnik-apiobjc/client/SWGWordOfTheDay.h
	samples/client/wordnik-apiobjc/client/SWGWordOfTheDay.m
	samples/client/wordnik-apiobjc/client/SWGWordSearchResult.h
	samples/client/wordnik-apiobjc/client/SWGWordSearchResults.h
	samples/client/wordnik-apiobjc/client/SWGWordSearchResults.m
	samples/client/wordnik-apiobjc/client/SWGWordsApi.h
	samples/client/wordnik-apiobjc/client/SWGWordsApi.m
	samples/client/wordnik-api-objc/Podfile
	samples/client/wordnik-api-objc/client/SWGAccountApi.h
	samples/client/wordnik-api-objc/client/SWGAccountApi.m
	samples/client/wordnik-api-objc/client/SWGApiClient.h
	samples/client/wordnik-api-objc/client/SWGApiClient.m
	samples/client/wordnik-api-objc/client/SWGApiTokenStatus.h
	samples/client/wordnik-api-objc/client/SWGApiTokenStatus.m
	samples/client/wordnik-api-objc/client/SWGAudioFile.h
	samples/client/wordnik-api-objc/client/SWGAudioFile.m
	samples/client/wordnik-api-objc/client/SWGAuthenticationToken.h
	samples/client/wordnik-api-objc/client/SWGAuthenticationToken.m
	samples/client/wordnik-api-objc/client/SWGBigram.h
	samples/client/wordnik-api-objc/client/SWGBigram.m
	samples/client/wordnik-api-objc/client/SWGCitation.h
	samples/client/wordnik-api-objc/client/SWGCitation.m
	samples/client/wordnik-api-objc/client/SWGContentProvider.h
	samples/client/wordnik-api-objc/client/SWGContentProvider.m
	samples/client/wordnik-api-objc/client/SWGDate.h
	samples/client/wordnik-api-objc/client/SWGDate.m
	samples/client/wordnik-api-objc/client/SWGDefinition.h
	samples/client/wordnik-api-objc/client/SWGDefinition.m
	samples/client/wordnik-api-objc/client/SWGDefinitionSearchResults.h
	samples/client/wordnik-api-objc/client/SWGDefinitionSearchResults.m
	samples/client/wordnik-api-objc/client/SWGExample.h
	samples/client/wordnik-api-objc/client/SWGExample.m
	samples/client/wordnik-api-objc/client/SWGExampleSearchResults.h
	samples/client/wordnik-api-objc/client/SWGExampleSearchResults.m
	samples/client/wordnik-api-objc/client/SWGExampleUsage.h
	samples/client/wordnik-api-objc/client/SWGExampleUsage.m
	samples/client/wordnik-api-objc/client/SWGFacet.h
	samples/client/wordnik-api-objc/client/SWGFacet.m
	samples/client/wordnik-api-objc/client/SWGFacetValue.h
	samples/client/wordnik-api-objc/client/SWGFacetValue.m
	samples/client/wordnik-api-objc/client/SWGFile.h
	samples/client/wordnik-api-objc/client/SWGFile.m
	samples/client/wordnik-api-objc/client/SWGFrequency.h
	samples/client/wordnik-api-objc/client/SWGFrequency.m
	samples/client/wordnik-api-objc/client/SWGFrequencySummary.h
	samples/client/wordnik-api-objc/client/SWGFrequencySummary.m
	samples/client/wordnik-api-objc/client/SWGLabel.h
	samples/client/wordnik-api-objc/client/SWGLabel.m
	samples/client/wordnik-api-objc/client/SWGNote.h
	samples/client/wordnik-api-objc/client/SWGNote.m
	samples/client/wordnik-api-objc/client/SWGObject.h
	samples/client/wordnik-api-objc/client/SWGObject.m
	samples/client/wordnik-api-objc/client/SWGRelated.h
	samples/client/wordnik-api-objc/client/SWGRelated.m
	samples/client/wordnik-api-objc/client/SWGScoredWord.h
	samples/client/wordnik-api-objc/client/SWGScoredWord.m
	samples/client/wordnik-api-objc/client/SWGScrabbleScoreResult.h
	samples/client/wordnik-api-objc/client/SWGScrabbleScoreResult.m
	samples/client/wordnik-api-objc/client/SWGSentence.h
	samples/client/wordnik-api-objc/client/SWGSentence.m
	samples/client/wordnik-api-objc/client/SWGSimpleDefinition.h
	samples/client/wordnik-api-objc/client/SWGSimpleDefinition.m
	samples/client/wordnik-api-objc/client/SWGSimpleExample.h
	samples/client/wordnik-api-objc/client/SWGSimpleExample.m
	samples/client/wordnik-api-objc/client/SWGStringValue.h
	samples/client/wordnik-api-objc/client/SWGStringValue.m
	samples/client/wordnik-api-objc/client/SWGSyllable.h
	samples/client/wordnik-api-objc/client/SWGSyllable.m
	samples/client/wordnik-api-objc/client/SWGTextPron.h
	samples/client/wordnik-api-objc/client/SWGTextPron.m
	samples/client/wordnik-api-objc/client/SWGUser.h
	samples/client/wordnik-api-objc/client/SWGUser.m
	samples/client/wordnik-api-objc/client/SWGWordApi.h
	samples/client/wordnik-api-objc/client/SWGWordApi.m
	samples/client/wordnik-api-objc/client/SWGWordList.h
	samples/client/wordnik-api-objc/client/SWGWordList.m
	samples/client/wordnik-api-objc/client/SWGWordListApi.h
	samples/client/wordnik-api-objc/client/SWGWordListApi.m
	samples/client/wordnik-api-objc/client/SWGWordListWord.h
	samples/client/wordnik-api-objc/client/SWGWordListWord.m
	samples/client/wordnik-api-objc/client/SWGWordListsApi.h
	samples/client/wordnik-api-objc/client/SWGWordListsApi.m
	samples/client/wordnik-api-objc/client/SWGWordObject.h
	samples/client/wordnik-api-objc/client/SWGWordObject.m
	samples/client/wordnik-api-objc/client/SWGWordOfTheDay.h
	samples/client/wordnik-api-objc/client/SWGWordOfTheDay.m
	samples/client/wordnik-api-objc/client/SWGWordSearchResult.h
	samples/client/wordnik-api-objc/client/SWGWordSearchResult.m
	samples/client/wordnik-api-objc/client/SWGWordSearchResults.h
	samples/client/wordnik-api-objc/client/SWGWordSearchResults.m
	samples/client/wordnik-api-objc/client/SWGWordsApi.h
	samples/client/wordnik-api-objc/client/SWGWordsApi.m
	samples/client/wordnik-api-php/wordnik/AccountApi.php
	samples/client/wordnik-api/scala/src/test/scala/AccountApiTest.scala
	samples/client/wordnik-api/scala/src/test/scala/WordApiTest.scala
	samples/client/wordnik-api/scala/src/test/scala/WordListApiTest.scala
	samples/client/wordnik-api/scala/src/test/scala/WordsApiTest.scala
	samples/client/wordnik/objc/client/SWGAccountApi.h
	samples/client/wordnik/objc/client/SWGAccountApi.m
	samples/client/wordnik/objc/client/SWGApiTokenStatus.h
	samples/client/wordnik/objc/client/SWGAudioFile.h
	samples/client/wordnik/objc/client/SWGAuthenticationToken.h
	samples/client/wordnik/objc/client/SWGBigram.h
	samples/client/wordnik/objc/client/SWGCitation.h
	samples/client/wordnik/objc/client/SWGCitation.m
	samples/client/wordnik/objc/client/SWGContentProvider.h
	samples/client/wordnik/objc/client/SWGContentProvider.m
	samples/client/wordnik/objc/client/SWGDefinition.h
	samples/client/wordnik/objc/client/SWGDefinition.m
	samples/client/wordnik/objc/client/SWGDefinitionSearchResults.h
	samples/client/wordnik/objc/client/SWGDefinitionSearchResults.m
	samples/client/wordnik/objc/client/SWGExample.h
	samples/client/wordnik/objc/client/SWGExample.m
	samples/client/wordnik/objc/client/SWGExampleSearchResults.h
	samples/client/wordnik/objc/client/SWGExampleSearchResults.m
	samples/client/wordnik/objc/client/SWGExampleUsage.h
	samples/client/wordnik/objc/client/SWGExampleUsage.m
	samples/client/wordnik/objc/client/SWGFacet.h
	samples/client/wordnik/objc/client/SWGFacet.m
	samples/client/wordnik/objc/client/SWGFacetValue.h
	samples/client/wordnik/objc/client/SWGFacetValue.m
	samples/client/wordnik/objc/client/SWGFile.h
	samples/client/wordnik/objc/client/SWGFrequency.h
	samples/client/wordnik/objc/client/SWGFrequency.m
	samples/client/wordnik/objc/client/SWGFrequencySummary.h
	samples/client/wordnik/objc/client/SWGFrequencySummary.m
	samples/client/wordnik/objc/client/SWGLabel.h
	samples/client/wordnik/objc/client/SWGLabel.m
	samples/client/wordnik/objc/client/SWGNote.h
	samples/client/wordnik/objc/client/SWGRelated.h
	samples/client/wordnik/objc/client/SWGScoredWord.h
	samples/client/wordnik/objc/client/SWGSentence.h
	samples/client/wordnik/objc/client/SWGSentence.m
	samples/client/wordnik/objc/client/SWGSimpleDefinition.h
	samples/client/wordnik/objc/client/SWGSimpleExample.h
	samples/client/wordnik/objc/client/SWGStringValue.h
	samples/client/wordnik/objc/client/SWGStringValue.m
	samples/client/wordnik/objc/client/SWGSyllable.h
	samples/client/wordnik/objc/client/SWGTextPron.h
	samples/client/wordnik/objc/client/SWGUser.h
	samples/client/wordnik/objc/client/SWGWordApi.h
	samples/client/wordnik/objc/client/SWGWordList.h
	samples/client/wordnik/objc/client/SWGWordList.m
	samples/client/wordnik/objc/client/SWGWordListApi.h
	samples/client/wordnik/objc/client/SWGWordListApi.m
	samples/client/wordnik/objc/client/SWGWordListWord.h
	samples/client/wordnik/objc/client/SWGWordListsApi.h
	samples/client/wordnik/objc/client/SWGWordListsApi.m
	samples/client/wordnik/objc/client/SWGWordObject.h
	samples/client/wordnik/objc/client/SWGWordOfTheDay.h
	samples/client/wordnik/objc/client/SWGWordOfTheDay.m
	samples/client/wordnik/objc/client/SWGWordSearchResult.h
	samples/client/wordnik/objc/client/SWGWordSearchResults.h
	samples/client/wordnik/objc/client/SWGWordSearchResults.m
	samples/client/wordnik/objc/client/SWGWordsApi.h
	samples/client/wordnik/objc/client/SWGWordsApi.m
	samples/server-generator/node/README.md
	samples/server/petstore/jaxrs/src/main/java/io/swagger/model/Pet.java
	samples/server/petstore/nodejs/app/apis/PetApi.js
	samples/server/petstore/nodejs/app/apis/StoreApi.js
	samples/server/petstore/nodejs/app/apis/UserApi.js
	sbt
	src/main/resources/objc/api-body.mustache
	src/main/resources/php/Swagger.mustache
	src/main/resources/python/swagger.mustache
	src/main/scala/com/wordnik/swagger/codegen/BasicAndroidJavaClient.scala
	src/main/scala/com/wordnik/swagger/codegen/BasicGenerator.scala
	src/main/scala/com/wordnik/swagger/codegen/BasicPythonGenerator.scala
	src/main/scala/com/wordnik/swagger/codegen/BasicScalaGenerator.scala
	src/main/scala/com/wordnik/swagger/codegen/Codegen.scala
	src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala
	src/main/scala/com/wordnik/swagger/codegen/model/AuthorizationModels.scala
	src/main/scala/com/wordnik/swagger/codegen/spec/SwaggerSpecValidator.scala
	src/main/scala/com/wordnik/swagger/codegen/util/RemoteUrl.scala
	src/test/scala/CodegenTest.scala
2015-02-16 21:01:17 -08:00
Tony Tam
72feda8346 updated readme 2015-02-16 20:53:26 -08:00
Tony Tam
2e88dea3ac updated versions 2015-02-16 20:44:22 -08:00
Tony Tam
678bbd6676 made dynamic swagger config example 2015-02-16 20:17:00 -08:00
Tony Tam
5853326f6a removed file 2015-02-16 20:15:24 -08:00
Tony Tam
8befb95986 added type tag 2015-02-16 18:19:06 -08:00
Tony Tam
026c93a104 fixed models 2015-02-16 18:03:15 -08:00
Tony Tam
15fde46ca5 removed debug 2015-02-16 17:56:28 -08:00
Tony Tam
f3455397ec rebuilt clients 2015-02-16 17:56:13 -08:00
Tony Tam
4f0823bffa rebuilt client 2015-02-16 17:55:59 -08:00
Tony Tam
31eb392d40 rebuild client 2015-02-16 17:55:15 -08:00
Tony Tam
fde5014bf9 fix for #224, added safe php comparison 2015-02-16 17:49:22 -08:00
Tony Tam
39b2bf4204 fixed test errors from updating sample json 2015-02-16 17:38:04 -08:00
Tony Tam
a1cf365288 rebuilt 2015-02-16 17:37:45 -08:00
Tony Tam
166a18bfc8 pulled from live server 2015-02-16 17:37:25 -08:00
Tony Tam
a0ea195ffc rebuilt client 2015-02-16 17:37:05 -08:00
Tony Tam
0563be891c made scripts call local file to avoid transient server issues 2015-02-16 17:36:48 -08:00
Tony Tam
5790c7d289 fix for #191, not detecting correct file name 2015-02-16 17:18:19 -08:00
Tony Tam
c7c3c969db moved output 2015-02-15 22:22:42 -08:00
Tony Tam
04074bd853 updated client 2015-02-15 22:20:56 -08:00
Tony Tam
76a367072c updated client 2015-02-15 22:20:26 -08:00
Tony Tam
e4cf9c5d55 updated scripts 2015-02-15 22:20:08 -08:00
Tony Tam
a4bde0368e updated for separation with enums 2015-02-15 22:19:43 -08:00
Tony Tam
da8176e170 updated templates 2015-02-15 22:19:26 -08:00
Tony Tam
bd276f5680 rebuilt client 2015-02-15 22:18:13 -08:00
Tony Tam
f10da06188 updated client 2015-02-15 22:17:32 -08:00
Tony Tam
13ef879703 rebuilt client 2015-02-15 22:14:38 -08:00
Tony Tam
8cbba12282 rebuilt client 2015-02-15 22:14:25 -08:00
Tony Tam
d98e894b41 rebuilt client 2015-02-15 22:12:48 -08:00
Tony Tam
73a6c0c42d rebuilt client 2015-02-15 22:09:07 -08:00
Tony Tam
7363365447 rebuilt client 2015-02-15 22:06:22 -08:00
Tony Tam
3b501f4134 added better enum support 2015-02-15 22:05:45 -08:00
Tony Tam
ffe5353987 rebuilt client 2015-02-15 22:04:50 -08:00
Tony Tam
1556bf16a9 rebuilt client 2015-02-15 21:26:35 -08:00
Tony Tam
88351ed844 rebuilt client 2015-02-15 21:25:41 -08:00
Tony Tam
9707f0a1ab updated client 2015-02-15 21:18:54 -08:00
Tony Tam
4daac48c6b added readme, rebuilt client 2015-02-15 19:50:41 -08:00
Tony Tam
e943f5c864 added readme, rebuilt client 2015-02-15 19:50:23 -08:00
Tony Tam
719820c089 added help response if args not set 2015-02-15 19:11:15 -08:00
Tony Tam
fe06652931 removed scala compile step #205 2015-02-15 19:04:53 -08:00
Tony Tam
098f7930eb added script 2015-02-15 18:07:05 -08:00
Tony Tam
f942e82691 updated templates 2015-02-15 18:06:50 -08:00
Tony Tam
db5259b913 updated script, addressed #189 with type mapping 2015-02-15 18:06:40 -08:00
Tony Tam
dfc7750dda rebuilt client 2015-02-15 18:05:56 -08:00
Tony Tam
dd971f19e7 added support for headers when generating per #102 2015-02-15 17:15:40 -08:00
Tony Tam
785cc4e29a fixed file suffix 2015-02-14 17:49:33 -08:00
Tony Tam
0c3e82e375 updated templates 2015-02-14 17:49:19 -08:00
Tony Tam
a6744507ef updated version 2015-02-14 17:49:10 -08:00
Tony Tam
9614dd8b95 added sample 2015-02-14 17:48:55 -08:00
Tony Tam
5208b36939 updated client 2015-02-14 17:36:52 -08:00
Tony Tam
779bdb23eb rebuilt client 2015-02-14 17:36:39 -08:00
Tony Tam
4bd1b99213 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-02-14 17:34:27 -08:00
Tony Tam
4841485456 Merge pull request #427 from lucamilanesio/scala-mustache-backward-compatibility
Scala api.mustache: make new constructor backward compatible
2015-02-14 17:34:23 -08:00
Tony Tam
d5ddf0c404 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-02-14 17:33:46 -08:00
Tony Tam
7d4cc6bdde Merge pull request #425 from lucamilanesio/develop_2.0
SPNEGO auth fix: Authentication scheme should be set as String
2015-02-14 17:33:30 -08:00
Tony Tam
a0d74531f7 added petstore script 2015-02-14 17:09:07 -08:00
Tony Tam
feb6119572 added supporting data post processing 2015-02-14 17:08:51 -08:00
Tony Tam
dbc4ab51b1 removed deprecated call 2015-02-14 17:08:37 -08:00
Tony Tam
8daebf78f4 updated sample 2015-02-14 17:06:32 -08:00
Tony Tam
391806570c updated script 2015-02-14 16:30:38 -08:00
Tony Tam
ed1e082896 updated versions 2015-02-13 22:16:54 -08:00
Tony Tam
0640c63573 updated readme 2015-02-12 22:32:00 -08:00
Tony Tam
9985d9e2d9 removed template path 2015-02-12 22:26:42 -08:00
Tony Tam
cd3dfe164b rebuilt 2015-02-12 22:25:29 -08:00
Tony Tam
85b396ce88 rebuilt sample 2015-02-12 22:24:17 -08:00
Tony Tam
241c69fef7 updated templates 2015-02-12 22:24:04 -08:00
Tony Tam
20deb15c8c updated client 2015-02-12 21:54:34 -08:00
Tony Tam
2bc5e71f91 updated year in comments 2015-02-12 21:53:37 -08:00
Tony Tam
dd9da67f51 made match case insensitive 2015-02-12 21:51:44 -08:00
Tony Tam
10e9e8a51d rebuilt 2015-02-12 21:40:42 -08:00
Tony Tam
c3978d2ea3 updated dependencies for compat 2015-02-12 21:38:52 -08:00
Tony Tam
54db9f8f24 updated scripts 2015-02-12 21:38:31 -08:00
Tony Tam
8785759fdf Merge pull request #431 from devnulled/develop_2.0
Fixed The html.sh Sample Generation Script
2015-02-12 16:26:30 -08:00
Brandon Harper
59b0a062a0 Fixed/updated the swagger.json URL in the html.sh script so that it would generate a sample again. 2015-02-12 14:46:02 -07:00
Tony Tam
95155f07d8 added snapshots back 2015-02-11 08:27:52 -08:00
Luca Milanesio
14795df85d Scala api.mustache: make new constructor backward compatible
When default values have been provided with the api.mustache
constructor, backward compatibility was broken because of the public
instance variables becoming immutable vals whilst they were vars before.

We can now use the constructor arguments as default values for the internal
vars and establish backward compatibility with existing code.
2015-02-11 11:00:41 +00:00
Tony Tam
d821a897b3 Merge pull request #426 from lucamilanesio/scala-mustache-easy-override
Scala api.mustache: allow easy basePath and ApiInvoker override
2015-02-10 08:22:39 -08:00
Luca Milanesio
fd560f4dc1 Scala api.mustache: allow easy basePath and ApiInvoker override
Gets rid of the smelly vars inside Scala api.mustache allowing the
override of default basePath and ApiInvoker on the constructor.

Previously the code for overriding was:

  val myApi = new MyApi()
  myApi.basePath = "http://myapi.endpoint.com"
  myApi.apiInvoker = new ApiInvoker(authScheme = "SPNEGO")

after the change everything can be simply declared in the constructor:

  val myApi = new MyApi("http://myapi.endpoint.com",
                         new ApiInvoker(authScheme = "SPNEGO"))
2015-02-10 14:07:13 +00:00
Luca Milanesio
6ecc569abd SPNEGO auth fix: Authentication scheme should be set as String
Default authentication scheme is a String and must be later
on decoded as Realm enum
2015-02-10 12:17:27 +00:00
Tony Tam
ece072aee3 Merge pull request #418 from lucamilanesio/scala-async-http-support
Support for HTTP Async client transport for Jersey on Scala (legacy master)
2015-02-09 13:43:07 -08:00
Tony Tam
759c0aea80 Merge pull request #421 from lucamilanesio/scala-spnego-preemptive-auth-2.0
Support Secure SPNEGO kerberos negotiation for Scala
2015-02-09 12:33:59 -08:00
Luca Milanesio
8e327aa24b Support for Secure SPNEGO kerberos negotiation
Ability to integrate with a SPNEGO-protected REST API
with KerberosV5 ticket preemptive authentication.
2015-02-09 20:14:13 +00:00
Luca Milanesio
592d59ceb2 Support for HTTP Async client transport for Jersey on Scala
When generating Scala client, the ApiInvoker is a class with
overridable options, avoiding the need of public vars to be
manually modified.

Additionally it is possible to plug the AsyncHttp protocol
for Jersey in order to achieve Netty support and maximum scalability.

NOTE: Support for Scala 2.10.0-3 removed as largely obsolete
2015-02-09 19:59:26 +00:00
Luca Milanesio
2386e394ae Support for HTTP Async client transport for Jersey on Scala
When generating Scala client, the ApiInvoker is a class with
overridable options, avoiding the need of public vars to be
manually modified.

Additionally it is possible to plug the AsyncHttp protocol
for Jersey in order to achieve Netty support and maximum scalability.

NOTE: Support for Scala 2.10.0-3 removed as largely obsolete
2015-02-09 19:36:28 +00:00
Tony Tam
781c9f7d83 Merge pull request #416 from FindTheBest/develop_2.0
PHP/Python Enhancements
2015-02-08 22:15:34 -08:00
Tony Tam
70803a1d09 Update README.md 2015-02-07 15:32:06 -08:00
Tony Tam
ffe5fc7fd2 changed signature for usage in generator 2015-02-07 14:59:35 -08:00
Tony Tam
cbc9fdbe34 updated annotations 2015-02-07 11:08:21 -08:00
Tony Tam
416c087be0 removed old files 2015-02-06 11:36:58 -08:00
James Ebentier
09bfecf76e Python: adding in support for formParams as well as multipart-form requests 2015-02-06 11:32:15 -08:00
James Ebentier
8b4180ca4a PHP: moving over the addition of a setTimeout function for the APIClient 2015-02-06 11:16:16 -08:00
James Ebentier
73a702f91e PHP: adding the ability to use multipart-form submissions as well as adding formParams to the api 2015-02-06 11:15:22 -08:00
Tony Tam
f55d9eaa68 Merge pull request #412 from FindTheBest/master
Python/PHP Multipart-Form request support
2015-02-06 10:47:10 -08:00
Tony Tam
7315b0ce2c changed scope per #414 2015-02-06 05:55:30 -08:00
Tony Tam
de4534475c removed old samples 2015-02-06 05:52:57 -08:00
Tony Tam
0bf660ebe8 added podfile 2015-02-06 05:52:15 -08:00
Tony Tam
8b32db73c2 formatting 2015-02-06 05:52:05 -08:00
Tony Tam
bffd43c8fc fixed container type 2015-02-06 05:51:56 -08:00
Tony Tam
6f7a1bb7e3 added reserved words 2015-02-06 05:51:23 -08:00
Tony Tam
eb1dce3d11 fixed paths 2015-02-06 05:50:43 -08:00
Tony Tam
a841f94273 updated response types 2015-02-06 05:50:12 -08:00
Tony Tam
a7f12c04e6 updated samples 2015-02-06 05:49:38 -08:00
Tony Tam
422cd88b51 rebuilt samples 2015-02-06 05:49:08 -08:00
Tony Tam
eb9e95952d updated templates 2015-02-06 05:48:47 -08:00
Tony Tam
1e717addf4 removed old samples 2015-02-06 05:48:27 -08:00
Tony Tam
3885991439 rebuilt samples 2015-02-05 21:45:48 -08:00
Tony Tam
3815dfa6a2 updated packages 2015-02-05 21:06:35 -08:00
Tony Tam
5f65c5aa49 added client 2015-02-05 21:06:22 -08:00
Tony Tam
e86837dd9a added samples 2015-02-05 21:02:12 -08:00
Tony Tam
585311c06a added files 2015-02-05 21:00:24 -08:00
Tony Tam
69dceb7f69 updated samples 2015-02-05 20:58:32 -08:00
Tony Tam
f1ac82f8a0 updated dependencies 2015-02-05 20:58:21 -08:00
Tony Tam
2c55649797 renamed package 2015-02-05 20:57:21 -08:00
Tony Tam
5c519f6429 revert last commit 2015-02-05 16:17:53 -08:00
Tony Tam
20e600c80e updated multi-module pom 2015-02-05 16:16:19 -08:00
Tony Tam
2ed8e10fe4 added null check for simple definitions with no models 2015-02-05 16:16:04 -08:00
Tony Tam
caaa753f58 Merge pull request #413 from swagger-api/assembly
Created assembly and submodules
2015-02-05 11:51:00 -08:00
Tony Tam
f7c6810757 updated samples 2015-02-05 11:35:13 -08:00
Tony Tam
2f16ee3b29 renamed package 2015-02-05 11:34:23 -08:00
Tony Tam
d97c7c7668 updated bin scripts 2015-02-05 10:22:28 -08:00
Tony Tam
11df3530f3 added wordnik sample 2015-02-05 10:22:19 -08:00
Tony Tam
6bb2e4ccb4 moved to modules per #411 2015-02-05 07:17:38 -08:00
Tony Tam
450894c52e moved to modules 2015-02-05 07:16:56 -08:00
James Ebentier
0f041dae90 MultipartForm: adding support for php 2015-02-04 12:48:00 -08:00
James Ebentier
6c97a9c6c7 MultipartForm: some more fixing of formating 2015-02-04 10:54:55 -08:00
James Ebentier
257d67346c MultipartForm: fixing some spacing issues 2015-02-04 10:41:25 -08:00
James Ebentier
e955c9dcfd MultipartForm: getting the file uploading working 2015-02-04 09:56:10 -08:00
Tony Tam
8414046fc5 added test for form params 2015-02-04 07:21:26 -08:00
Tony Tam
fd270d7733 added copy function 2015-02-04 07:21:17 -08:00
Tony Tam
67a3fffad7 added copy function 2015-02-04 07:21:08 -08:00
Tony Tam
7d0e003bf2 added form params template 2015-02-04 06:51:16 -08:00
Tony Tam
bad6798433 added consumes, produces 2015-02-03 23:54:37 -08:00
Tony Tam
949b321e13 updated path 2015-02-03 21:52:03 -08:00
Tony Tam
c84fd54215 updated to m1 version 2015-02-03 21:51:38 -08:00
Tony Tam
5acb01eb6b moved to 2_0 folder 2015-02-03 21:51:20 -08:00
Tony Tam
568504ffb4 move to 2_0 folder 2015-02-03 21:51:05 -08:00
Tony Tam
eec525a40f shortened line breaks 2015-02-03 21:50:28 -08:00
Tony Tam
f8624dbcaa update to m1 release 2015-02-03 21:50:02 -08:00
Tony Tam
5fdb609767 changed package to io.swagger 2015-02-03 21:49:45 -08:00
Tony Tam
4c53d7b8c4 added formParam values 2015-02-03 21:49:21 -08:00
Tony Tam
3b96894e75 added file & forms 2015-02-03 21:49:05 -08:00
James Ebentier
63bb20238b MultipartForm: fixing syntax error 2015-02-03 19:01:31 -08:00
James Ebentier
55575541d8 MultipartForm: better formatting 2015-02-03 18:28:56 -08:00
James Ebentier
33e6105822 MultipartForm: adding in basic support for multipart form submissions on python bindings 2015-02-03 18:03:20 -08:00
Tony Tam
87be442ad9 Merge pull request #409 from ethanjcohen/master
Fix "properties" name in node server example template
2015-02-02 22:42:56 -08:00
Tony Tam
33834d6cce Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-02-02 06:28:24 -08:00
Tony Tam
212b7cee72 added void to default includes 2015-02-02 06:28:17 -08:00
Tony Tam
d9ca26c40d updated to m1 2015-02-02 06:27:58 -08:00
Ethan Cohen
65b3b594e3 Renamed the "params" operation property to "parameters" to conform to the swagger spec 2015-02-01 16:02:27 -06:00
Ethan Cohen
94ceb504b8 Changed the "params" operation property to "parameters" to conform to the swagger spec 2015-02-01 15:54:47 -06:00
Tony Tam
fcb21da7f9 Merge pull request #392 from ikuo/develop_2.0-support-upper-case-property-name
Support upper case-proprty names
2015-01-30 12:26:56 -08:00
Tony Tam
124e17fb8a Merge pull request #401 from fleque/fleque-fix-response-selection
Fix for the selection of the methodResponse during code-generation
2015-01-28 22:07:06 -08:00
Tony Tam
f914f26f3b Merge pull request #400 from FindTheBest/master
Fixing curl $postData for php bindings
2015-01-28 22:06:23 -08:00
Tony Tam
1bc5fcc29e Merge pull request #397 from fleque/fleque-python-codegen
[WIP] Support Python code generation
2015-01-28 21:53:14 -08:00
James Ebentier
4a6e719d6a APIClient: making the cURL timeout able to be variably set for better dynamic api calls 2015-01-28 16:04:11 -08:00
Fleque
35dc8d4e5d Fix for the selection of the methodResponse from an operation during code generation. Now all the smallest 2xx code is used 2015-01-27 23:01:21 +01:00
James Ebentier
61ea9564f8 building a fix for postData that will pass TravisCI build 2015-01-27 13:48:59 -08:00
James Ebentier
bfc14938d0 Fixing curl $postData for php bindings 2015-01-27 13:16:20 -08:00
Tony Tam
c98a78062f Merge pull request #398 from FindTheBest/master
Fixing issue with deserialization in PHP
2015-01-27 12:50:24 -08:00
James Ebentier
fd128cbab0 Update Swagger.mustache 2015-01-27 12:28:28 -08:00
James Ebentier
59568915de Fixing minor typo 2015-01-27 12:08:41 -08:00
James Ebentier
bff2515bf2 Fixing issue with deserialization in PHP
No longer will deserialize throw errors when converting a json response to a string
2015-01-27 11:48:20 -08:00
Tony Tam
d196c6656e added test for #393 2015-01-25 20:21:40 -08:00
Tony Tam
a2b01e9599 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2015-01-25 20:20:36 -08:00
Tony Tam
34a61e1256 added scala client support for #393 2015-01-25 20:20:27 -08:00
Ikuo Matsumura
b49572005b Fix typo name{ -> s} 2015-01-24 16:32:38 +09:00
Ikuo Matsumura
ea11b4fc35 Added spec on upper-case property name 2015-01-24 16:17:40 +09:00
Ikuo Matsumura
556485538f Added @JsonProperty to Java/model.mustache 2015-01-24 16:17:18 +09:00
Tony Tam
53e8683a5d Merge pull request #388 from fleque/template-resolving-fix
Fix for template resolving from classpath on windows
2015-01-23 16:55:09 -08:00
Fleque
6491223ed9 First attempt to port pythong code generation 2015-01-22 23:01:44 +01:00
Fleque
29a7375082 Applied import style of swagger-codegen project 2015-01-22 11:50:05 +01:00
Fleque
8f9947a20a Fix for the template resovling from classpath on Windows 2015-01-22 11:38:42 +01:00
Tony Tam
dcaf639bec Merge branch 'STRML-fixPHPFormParams' 2015-01-21 23:19:19 -08:00
Tony Tam
2f6bf95fa2 merged 2015-01-21 23:19:13 -08:00
Tony Tam
154c28b062 Merge pull request #385 from STRML/fixPHPComments
Rework generated PHP function comments.
2015-01-21 22:10:20 -08:00
Samuel Reed
8106de95dc Rework PHP function comments to match PHPDoc style.
Also eliminated bad newline.
2015-01-21 10:58:57 +01:00
Samuel Reed
7c342a060a Add missing formParams to PHP api.mustache. Fixes #383.
Also fixed mixed tabs and spaces in template.
2015-01-21 10:01:41 +01:00
Tony Tam
a15eb6f905 updated java version 2015-01-20 11:23:31 -08:00
Tony Tam
89c776a3b9 Update README.md 2015-01-14 11:16:06 -08:00
Tony Tam
6a5b4e2fb4 Merge pull request #364 from Helmsdown/jaxrs-path-annotation-fix
JAXRS Codegen should omit @PATH variable when it is not necessary
2015-01-11 22:55:36 -08:00
Tony Tam
fd39402116 Merge pull request #371 from cantecim/develop_2.0
Fixed apiFileFolder and modelFileFolder function results for android-java Fixes #369
2015-01-10 12:37:55 -08:00
Can Tecim
f6055dde30 Fixed apiFileFolder and modelFileFolder function results for android-java Fixes #369 2015-01-10 22:31:38 +02:00
Tony Tam
3abc42eee9 Merge pull request #368 from amandaducrou/master
Adding first and hasRequiredParams parameters to Codegen
2015-01-09 10:26:50 -08:00
Amanda Ducrou
2d81c71b52 Adding first and hasRequiredParams parameters to Codegen 2015-01-09 10:59:21 +10:00
Tony Tam
52db5b0925 Update README.md 2015-01-07 10:40:16 -08:00
russellb337
9aa9f4e842 fix JaxRS code gen to only generated @PATH annotation on a given resource function when that function is a "sub resource" (e.g. @PATH("/{id}") or @PATH("/{id}/operation") 2015-01-02 13:52:36 -08:00
Tony Tam
21396d0797 added map support for #360 2014-12-25 08:17:41 -08:00
Tony Tam
93eca2a6b6 php fixes 2014-12-24 19:29:25 -08:00
Tony Tam
74b9257de4 variable type fixes 2014-12-24 15:00:10 -08:00
Tony Tam
a921278650 added php generator 2014-12-24 10:19:42 -08:00
Tony Tam
2d193a0e92 Merge pull request #218 from JDiPierro/output_resource_path_for_no_models_found
Output the resourcePath when no models are found rather than the basePath
2014-12-23 22:23:14 -08:00
Tony Tam
09e7bd9c43 Merge pull request #286 from jebentier/master
Java binding comment creation issue fixed
2014-12-23 22:17:35 -08:00
Tony Tam
0ece4a084f Merge pull request #303 from butlermh/master
Can't run ./bin/scala-petstore.sh as instructed at README
2014-12-23 22:16:35 -08:00
Tony Tam
0821d1859b Merge pull request #321 from Laurent-Sarrazin/patch-doc
Fix a typo
2014-12-23 22:14:39 -08:00
Tony Tam
25aef5fd6e Merge pull request #240 from GerardSoleCa/master
Edit line 76 to place pom.xml correctly and dependency-jar generation
2014-12-23 20:31:26 -08:00
Tony Tam
20c21cb2f7 added debug info per #330 2014-12-23 19:56:32 -08:00
webron
3a77287f8b Update README.md 2014-12-23 17:29:49 +02:00
webron
d2111a8e68 Merge pull request #352 from FMJaguar/patch-2
Update README.md
2014-12-23 17:28:59 +02:00
Tony Tam
8fa4b196b4 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2014-12-19 14:49:51 -08:00
Tony Tam
3bf45de1f7 added null check 2014-12-19 14:49:32 -08:00
Rich DeLauder
3c0d639d0e Update README.md 2014-12-19 13:10:02 -08:00
Tony Tam
ed1d0948a3 Merge pull request #351 from earldouglas/exec-maven-plugin
Add the Exec Maven Plugin
2014-12-18 11:01:52 -08:00
James Earl Douglas
83699e5324 Add the Exec Maven Plugin
This allows execution of the Codegen class via `mvn exec:java`,
with optional args passed via `-Dexec.args="..."`:

mvn exec:java -Dexec.args="-i .../swagger.json -l html -o samples/..."
2014-12-18 10:58:25 -08:00
Tony Tam
1f30c65464 Update README.md 2014-12-12 12:47:30 -08:00
Tony Tam
45d5e480c0 configured scala version #344 2014-12-11 09:42:39 -08:00
Tony Tam
5ecada11ef moved java-specific reserved words out of default 2014-12-08 13:13:29 -08:00
Tony Tam
4f6878a278 fallbacks for unmatched inner types 2014-12-08 11:49:47 -08:00
Tony Tam
50e0445ab4 Merge pull request #342 from martoe/codegenfactory
Introduced a factory for codegen data containers
2014-12-08 07:22:22 -08:00
Martin Ehrnhoefer
78b36e0ba9 Introduced a factory for codegen data containers
Moved parameter/response generation code to
dedicated methods so that subclasses may extend it
2014-12-08 11:21:17 +01:00
Martin Ehrnhoefer
7a5068d632 Introduced a factory for codegen data containers
Missing model elements added
2014-12-08 10:27:29 +01:00
Tony Tam
c010b4c9c6 Merge pull request #341 from martoe/responseheaders
Make response headers available to the code generator
2014-12-07 21:30:57 -08:00
Tony Tam
cc9029236b Merge pull request #340 from martoe/codegenfactory
Introduced a factory for codegen data containers
2014-12-07 21:29:18 -08:00
Martin Ehrnhoefer
3f0b71b3e0 Make response headers available to the code generator 2014-12-07 10:08:42 +01:00
Martin Ehrnhoefer
0eb467e46e Introduced a factory for codegen data containers
implementation completed
2014-12-07 09:52:52 +01:00
Tony Tam
f2c64a0fbb removed comments 2014-12-06 15:55:42 -08:00
Martin Ehrnhoefer
f4424a5eae Introduced a factory for codegen data containers
This enables users to extend the Codegen* classes
and add their own methods there (which then can
be accessed from the mustache templates)
2014-12-06 16:07:45 +01:00
webron
1b68671e98 Update README.md 2014-12-04 16:27:44 +02:00
Tony Tam
f3ac9a579f Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2014-12-03 00:55:55 -08:00
Tony Tam
6e858ee645 updated samples 2014-12-03 00:55:38 -08:00
Tony Tam
96ea15a4d0 updated readme 2014-12-03 00:55:25 -08:00
Tony Tam
586420b919 Merge pull request #335 from wing328/master
update deserialize to handle both array(primitive) and Array(model)
2014-12-02 22:07:24 -08:00
Tony Tam
c05e07c8aa Merge pull request #331 from yutenglei/develop_2.0
Assigned Accept and Content-Type request-header for python's api.mustach...
2014-12-02 21:44:51 -08:00
Tony Tam
43a5ece5b3 Merge pull request #312 from idosh/master
add support to multipart form data and urlencoded for android client
2014-12-02 20:40:02 -08:00
William Cheng
9f6d883e68 update deserialize to handle both array(primitive) and Array(model) 2014-11-29 18:23:44 +08:00
Tony Tam
23d2d09136 added help, dynamic loading 2014-11-26 16:37:44 -10:00
Tony Tam
f35c748fb2 added help, dynamic loading 2014-11-26 15:20:50 -10:00
Tony Tam
a24556f0be added static, updated reference to swagger parser 2014-11-26 14:06:00 -10:00
Tony Tam
a1d604feb3 updated to use swagger parser 2014-11-25 12:01:13 -10:00
webron
524497a606 Merge pull request #332 from mhurne/patch-1
Fix spelling errors and improve sentence in Compatibility section
2014-11-24 22:13:29 +02:00
Matt Hurne
665ba22c7a Fix spelling errors and improve sentence in Compatibility section 2014-11-24 15:11:38 -05:00
Yu Teng Lei
9085a0d148 Assigned Accept and Content-Type request-header for python's api.mustache
This was done in PHP but not in python
2014-11-23 16:39:35 -05:00
Tony Tam
74d4ff0fc9 added swagger output for conversion 2014-11-21 08:30:21 -10:00
Tony Tam
29d956d424 added static html generator 2014-11-21 08:14:33 -10:00
Tony Tam
06031a0a34 added 1.2 conversion 2014-11-21 08:14:14 -10:00
Tony Tam
9ffece910d added basePath 2014-11-19 13:36:59 -08:00
Tony Tam
d12a565032 added debug mode 2014-11-19 13:36:52 -08:00
Tony Tam
9d6e6b56c6 added tizen c++ support 2014-11-13 09:29:13 -08:00
Tony Tam
acc0bad668 changed permissions 2014-11-13 09:28:32 -08:00
Tony Tam
697457415d updated spec with auth 2014-11-10 21:18:19 -08:00
Tony Tam
bcfd2e8ab6 println 2014-11-10 21:17:29 -08:00
Tony Tam
5adb82f6f6 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0 2014-11-10 13:15:36 -08:00
Tony Tam
4415cfe30d added escape 2014-11-10 13:15:27 -08:00
Ido Shamun
0614d1b221 update pom.xml with dependencies
fix Codegen.scala to support file as a param type
2014-11-08 01:19:53 +02:00
Ido Shamun
fb3f331e3c Merge remote-tracking branch 'upstream/master'
merge fork with master
2014-11-07 18:27:58 +02:00
Tony Tam
4e9378965b Merge pull request #324 from FindTheBest/pull_request
Adding the casting of integer -> int for python generated code
2014-11-05 15:47:44 -08:00
James Ebentier
d1fe146522 Adding the casting of integer -> int for python generated code 2014-11-05 15:37:22 -08:00
Tony Tam
718e6ba7b4 Merge pull request #302 from martoe/externalDocs
"External Documentation Object" implemented (according to spec)
2014-11-04 20:25:41 -08:00
Tony Tam
b9758107c3 Merge pull request #322 from Laurent-Sarrazin/patch-php-server-generator
Add a basic PHP server-generator example
2014-10-31 09:32:08 -07:00
Laurent Sarrazin
06332e5dce Add a basic PHP server-generator example 2014-10-31 17:00:34 +01:00
Laurent Sarrazin
aa262f6021 Fix a typo 2014-10-30 14:30:55 +01:00
Martin Ehrnhoefer
436d2530e4 "External Documentation Object" implemented (according to spec)
Depends on https://github.com/wordnik/swagger-core/pull/716
2014-10-30 10:22:00 +01:00
Tony Tam
77053fa855 added test case, update for #316 2014-10-28 13:21:50 -07:00
Tony Tam
810c7f9ed2 added test case, update for #316 2014-10-28 13:21:32 -07:00
Tony Tam
59b477d2da added test case, update for src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java 2014-10-28 13:08:41 -07:00
Tony Tam
4c674ca94b rebuilt samples 2014-10-26 21:46:26 -07:00
Tony Tam
63c428d048 updated templates 2014-10-26 21:46:14 -07:00
Tony Tam
2454bfa225 updated templates per #316 2014-10-26 21:40:13 -07:00
Tony Tam
d6bdd09273 removed unimplemented scripts 2014-10-24 14:50:40 -07:00
Tony Tam
73425fe582 rebuilt client 2014-10-23 21:22:19 -07:00
Tony Tam
bc974e6514 added bodyParam 2014-10-23 21:21:58 -07:00
Tony Tam
237f00e2e3 updated references 2014-10-22 15:46:47 -07:00
Tony Tam
88692ec42d updated references 2014-10-22 15:45:21 -07:00
Tony Tam
ee833da0ca fixed notes 2014-10-22 14:06:59 -07:00
Tony Tam
36aad8bc0a updated examples 2014-10-22 13:54:28 -07:00
Ivan Porto Carrero
a656ea301e updates the codegen to also include the project name for sbt 2014-10-21 10:59:35 -07:00
Tony Tam
e2ae99acac fixed import types 2014-10-21 00:02:28 -07:00
Tony Tam
461cb51f6a fixed summary/description mapping 2014-10-20 17:34:48 -07:00
Tony Tam
681628dba2 added model pacakge 2014-10-20 17:11:28 -07:00
Tony Tam
7167bf28c7 changed to Boolean to allow null values 2014-10-20 17:11:19 -07:00
Ido Shamun
5e4e838a48 add support to multipart form data and urlencoded for android client 2014-10-21 01:58:31 +03:00
Ivan Porto Carrero
f3dc69a7e7 update dependencies in async scala project 2014-10-20 15:42:10 -07:00
Tony Tam
86f9a0a58a fixed build error 2014-10-20 08:42:35 -07:00
Tony Tam
df1a987e2d Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-10-20 08:24:46 -07:00
Tony Tam
40b4d34870 added required flag for parameter 2014-10-20 08:24:34 -07:00
Tony Tam
c6e3608ffa Merge pull request #310 from martoe/param_required
Parameter.required flag implemented
2014-10-20 07:07:50 -07:00
Martin Ehrnhoefer
0aa87cfbeb Parameter.required flag implemented
Made the "required" flag for Parameter objects available to the code generator templates
2014-10-20 15:56:25 +02:00
Tony Tam
053419234a renamed field to avoid nested naming collisions 2014-10-19 11:18:38 -07:00
Tony Tam
12eba440ae Update README.md 2014-10-18 17:14:00 -07:00
Tony Tam
5d43282f51 fixed typo 2014-10-17 14:46:47 -07:00
Tony Tam
2826b69487 removed profile 2014-10-17 14:31:26 -07:00
Tony Tam
63c6bc28c3 Merge branch 'berngp-feature/develop_2.0/scala_2.11' into develop_2.0 2014-10-17 14:29:37 -07:00
Tony Tam
bf3eb94c51 Merge branch 'feature/develop_2.0/scala_2.11' of github.com:berngp/swagger-codegen into berngp-feature/develop_2.0/scala_2.11 2014-10-17 14:28:58 -07:00
Tony Tam
350d736706 fixed case on scheme 2014-10-16 17:43:15 -07:00
Tony Tam
e0aed88e98 added default value 2014-10-16 17:42:39 -07:00
Tony Tam
52a4370c35 added default value 2014-10-16 17:42:27 -07:00
Bernardo Gomez Palacio
5c0577aa8e Adding Echo YAML Sample 2014-10-14 15:09:55 -07:00
Bernardo Gomez Palacio
1e1abde846 Updating the Scalatra Template for Scala 2.11
* Moved to Scala 2.11.2
* Updated the dependencies to use latest Jetty as well as Akka
* Added the SBT Dependency Graph plugin
* Build Properties now use SBT 0.13.5
* Updated the sbt executable.
2014-10-14 14:39:12 -07:00
Bernardo Gomez Palacio
b2f34a152b Enabling Maven Profile gen-scalatra 2014-10-14 14:24:59 -07:00
webron
4676c4cdf7 Merge pull request #307 from catherinedodge/master
Fixed broken link in README.md
2014-10-13 16:58:22 +03:00
catherinedodge
d5674c9a7b Fixed broken link in README.md 2014-10-13 09:48:29 -04:00
Tony Tam
7c998a2d67 addressed import mappings 2014-10-10 22:07:08 -07:00
Tony Tam
5a70550a37 added scalatra support 2014-10-10 21:41:21 -07:00
Tony Tam
4d214dbcef updated client 2014-10-10 21:39:45 -07:00
Tony Tam
97623af8df added apiInfo 2014-10-10 21:26:07 -07:00
Tony Tam
b87bc2a908 added scalatra 2014-10-10 21:25:19 -07:00
Mark H. Butler
c8dac4a3cf Reverting these files, they don't need to change 2014-10-08 08:25:23 -07:00
Mark H. Butler
6f30a6d65a Modifying the pom.xml template because it defaults to building with Scala 2.9.1, but that is broken because BeanProperty moved, so instead use 2.10 as the default but add the option of using Scala 2.11 2014-10-08 08:20:02 -07:00
Mark H. Butler
9d1f0bf568 Adding ignore for gedit files (Linux) 2014-10-08 08:19:08 -07:00
Tony Tam
643c211d72 Merge pull request #296 from lloydmeta/update/fix_deprecations
Update deprecated method calls
2014-10-07 21:42:13 -07:00
Tony Tam
fb84985e9b Merge pull request #298 from dreamfactorysoftware/master
adding a space in call to completionHandler to kill latest Xcode parse errors
2014-10-02 16:45:38 -07:00
Jason Sykes
afb34b4f2f adding a space in call to completionHandler to kill latest Xcode parse errors 2014-10-02 12:20:17 -04:00
Tony Tam
5024e0bbda added root checking per #279 2014-10-02 00:32:15 -07:00
Tony Tam
e771ed3332 added scheme, host, basePath per #295 2014-10-02 00:18:36 -07:00
Tony Tam
2e81b38838 Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-10-02 00:10:42 -07:00
Tony Tam
67d28e8b3c added test 2014-10-02 00:10:39 -07:00
Tony Tam
b834ba436f added nodejs server 2014-10-02 00:10:15 -07:00
Tony Tam
6da7cbf095 Merge pull request #297 from martoe/#268
Windows path problem fixed
2014-10-02 00:00:54 -07:00
Martin Ehrnhoefer
d5d1eb2833 Windows path problem fixed
see #268, #269, #288
2014-10-02 08:56:30 +02:00
Tony Tam
e66f3c48ac Merge pull request #288 from martoe/268
Windows path problem fixed (again)
2014-10-01 23:29:46 -07:00
Tony Tam
c10cf7bf7f Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-10-01 23:22:43 -07:00
Tony Tam
178d7d19c4 added files 2014-10-01 23:22:39 -07:00
Tony Tam
3c2845aaa6 updated file locations 2014-10-01 23:21:59 -07:00
Tony Tam
a215e93505 Merge pull request #294 from martoe/287
[2.0 Spec] Java generator: Implement Enums #287
2014-10-01 23:13:58 -07:00
Tony Tam
bc99361100 Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-10-01 22:13:50 -07:00
Tony Tam
48f8e16fb0 added models support per #291 2014-10-01 22:12:50 -07:00
Tony Tam
ffda821f68 updated imports 2014-10-01 22:12:18 -07:00
Tony Tam
1bce51de7a updated imports 2014-10-01 22:11:51 -07:00
Lloyd
1734ac2e18 Update deprecated method calls
1. Update specs to inherit via `with Matchers`
2. Update `URLEncoder.encode` to pass "UTF-8" as charset
2014-10-02 10:49:20 +09:00
Tony Tam
ddb7aad530 Merge pull request #289 from maneeshsahu/develop_2.0
Added support for Map<String, Object>
2014-10-01 08:50:06 -07:00
Martin Ehrnhoefer
31ca832bdf [2.0 Spec] Java generator: Implement Enums #287
Unittest
2014-10-01 17:42:03 +02:00
Martin Ehrnhoefer
a80af33260 [2.0 Spec] Java generator: Implement Enums #287
Very basic implementation
2014-10-01 17:10:51 +02:00
Martin Ehrnhoefer
3971bbf334 [2.0 Spec] Java generator: Implement Enums #287
Very basic implementation
2014-10-01 16:58:38 +02:00
Maneesh Sahu-SSI
8cf9cb95f5 Added support for Map<String, Object> 2014-09-30 21:57:21 -07:00
Tony Tam
2787fa82c6 added docs 2014-09-30 06:11:51 -07:00
Tony Tam
05e1d02341 added custom class loading for configurations 2014-09-30 06:06:01 -07:00
Tony Tam
277f26a5bb Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-09-30 05:10:30 -07:00
Tony Tam
c05a3c3a99 updated client 2014-09-30 05:10:24 -07:00
Tony Tam
ca06241307 updated scripts 2014-09-30 05:09:47 -07:00
Martin Ehrnhoefer
cb25eb6bc0 Windows path problem fixed (again) - #268 #269 2014-09-30 09:32:52 +02:00
James Ebentier
72bef1fb68 fixing the java comments above the api calls to allow for multiline comments in the swagger docs 2014-09-29 17:53:53 -07:00
Tony Tam
b7452fa8ee Merge pull request #284 from martoe/699
[2.0 Spec] Implement Schema Object.example field
2014-09-29 10:48:57 -07:00
Martin Ehrnhoefer
89a009c411 [2.0 Spec] Implement Schema Object.example field
see issue https://github.com/wordnik/swagger-core/issues/699,
 pull-request https://github.com/wordnik/swagger-core/pull/700
2014-09-29 16:26:06 +02:00
Tony Tam
c75a951668 updated sample 2014-09-28 00:52:32 -07:00
Tony Tam
d714f097eb updated static template 2014-09-28 00:50:47 -07:00
Tony Tam
48f05b41e4 updated android sample 2014-09-27 17:00:30 -07:00
Tony Tam
f04827c6d3 updated android sample 2014-09-27 17:00:03 -07:00
Tony Tam
2729070d7f updated android sample 2014-09-27 16:59:08 -07:00
Tony Tam
9e5576d3fe added empty var check 2014-09-27 16:50:36 -07:00
Tony Tam
530ebe1f7d added map, list model types with tests 2014-09-27 09:13:26 -07:00
Tony Tam
ba45641801 updated for objc tests 2014-09-26 22:52:27 -07:00
Tony Tam
f2b03d2930 added test files 2014-09-26 14:21:43 -07:00
Tony Tam
7006c2f6e9 updated README 2014-09-26 13:59:07 -07:00
Tony Tam
108880cbe9 updated README 2014-09-26 13:56:12 -07:00
Tony Tam
64aa948445 added android client 2014-09-26 10:25:44 -07:00
Tony Tam
eb6c09bfce merged from #271 2014-09-26 09:39:39 -07:00
Tony Tam
2dd73872a4 updated with tests 2014-09-26 09:38:07 -07:00
Tony Tam
ba94dc3d68 added subclass for ArrayModel support #273, removed path param brackets for auto-generated operationId #274 2014-09-23 21:44:09 -07:00
Tony Tam
5bc907f1d4 added template variable 2014-09-23 09:14:25 -07:00
Tony Tam
1406c36ced Merge branch 'develop_2.0' of github.com:wordnik/swagger-codegen into develop_2.0 2014-09-22 16:44:23 -07:00
Tony Tam
394a064cc3 added scripts 2014-09-22 16:44:19 -07:00
Tony Tam
db29ecc8d0 added file from master 2014-09-22 16:44:01 -07:00
Tony Tam
ec99bef893 Merge pull request #266 from FindTheBest/pull_request
Python binding generation pull request
2014-09-20 13:39:07 -07:00
Tony Tam
64f7aece12 Merge pull request #269 from martoe/develop_2.0
#268 Windows path problem fixed
2014-09-20 10:42:43 -07:00
Martin Ehrnhoefer
46f5fe0611 #268 Windows path problem fixed 2014-09-20 19:39:54 +02:00
Tony Tam
923ed596ac Merge pull request #267 from martoe/develop_2.0
Issue 244 - checkout on windows fails due to special chars
2014-09-20 08:47:44 -07:00
Tony Tam
2fd29d74f2 Merge pull request #263 from wordnik/basic-auth
Adds Basic auth as an authentication mechanism
2014-09-20 08:43:30 -07:00
Tony Tam
033a9a4b97 Merge pull request #262 from xhh/patch-1
Fixes #260 convert form parameters to string for Java client
2014-09-20 08:41:33 -07:00
isf
8762f38470 Issue 244 - checkout on windows fails due to special chars 2014-09-20 11:48:50 +00:00
Tony Tam
e5392dc21a added script 2014-09-19 16:41:09 -07:00
Tony Tam
7630fd4f85 added scripts 2014-09-19 16:36:28 -07:00
Tony Tam
134c900aa1 reorded for cleanliness 2014-09-19 16:28:56 -07:00
Tony Tam
a0876f24a3 added travis file 2014-09-19 14:38:00 -07:00
Tony Tam
504e1b28c5 added model package to templates 2014-09-19 14:05:31 -07:00
Tony Tam
885e463bcb added compatibility table 2014-09-19 11:50:20 -07:00
James Ebentier
b8f3201dba fixing a minor generation issue in api.mustashe to make sure that python scripts are as clean as possible for apis 2014-09-19 10:53:03 -07:00
James Ebentier
983edbd85b Adding in the ability to post forms using swagger codegen generate bindings for python 2014-09-19 10:52:57 -07:00
Tony Tam
24268661af Merge pull request #265 from fehguy/develop_2.0
added 2.0 support
2014-09-19 07:30:13 -07:00
Tony Tam
b90742e995 updated template location, added snapshot 2014-09-18 08:28:19 -07:00
Ivan Porto Carrero
86d56b978a also work on java 7 2014-09-16 20:52:07 -07:00
Ivan Porto Carrero
ed86bfb79b adds basic auth support 2014-09-16 20:41:32 -07:00
Ivan Porto Carrero
44a73c32fa more lenient Version.scala 2014-09-16 20:15:09 -07:00
Xu Hui Hui
39662e45b1 Fixes #260 convert form parameters to string for Java client 2014-09-16 18:58:17 +08:00
Tony Tam
9ab12eeda3 added mapping 2014-09-14 22:44:29 -07:00
Tony Tam
2128741218 removed println 2014-09-14 22:44:18 -07:00
Tony Tam
4442dcf203 added operationId generator 2014-09-14 22:44:05 -07:00
Tony Tam
fff1f30dba updated the query params 2014-09-14 21:44:07 -07:00
Tony Tam
c123bb9130 template cleanup 2014-09-14 17:52:25 -07:00
Tony Tam
5112b655bd added auth and response models 2014-09-14 17:47:59 -07:00
Tony Tam
d4122d197f updated to support jaxrs 2014-09-14 17:47:36 -07:00
webron
998bf633d8 Merge pull request #261 from czenker/patch-1
Fix typo in README.md
2014-09-12 15:48:22 +03:00
Christian Zenker
b927ffbd53 Fix typo in README.md 2014-09-12 14:26:15 +02:00
Tony Tam
cab4ffa286 property renames 2014-09-10 06:13:49 -07:00
Tony Tam
1ff47393ed Merge pull request #255 from martoe/master
Issue 244 - checkout on windows fails due to special chars
2014-09-07 23:59:01 -07:00
isf
a6ecc7a65b Issue 244 - checkout on windows fails due to special chars 2014-09-08 08:50:35 +02:00
Tony Tam
d5e62086c8 added cli parser, input opts 2014-09-04 12:42:35 -07:00
Tony Tam
370c22cddb made templates same as 2.0 2014-09-03 22:17:26 -07:00
Tony Tam
fbf8398324 fixes for return types, arrays 2014-09-03 22:10:34 -07:00
Tony Tam
79c456ecfc updates for reserved words 2014-09-03 11:18:19 -07:00
Tony Tam
bc0cc567d9 updated output filenames 2014-09-03 11:07:48 -07:00
Tony Tam
ad3006d49c added support for supporting files 2014-09-03 10:20:13 -07:00
Tony Tam
73ad502251 updated 2.0 support for objc 2014-09-03 01:10:02 -07:00
Tony Tam
7901d8a7c6 fixed api filenames 2014-09-03 00:41:06 -07:00
Tony Tam
6f63ba43ad added return types, media types 2014-09-03 00:38:24 -07:00
Tony Tam
812520e29f added support for models, partial for ops 2014-09-01 13:31:01 -07:00
Tony Tam
d1daf3a0e6 added 2.0 support files 2014-08-29 09:47:46 -07:00
Tony Tam
c5ccc0a908 update to swagger 2.0 2014-08-29 09:47:17 -07:00
Tony Tam
dbf04a9563 updated scripts 2014-08-27 01:09:28 -07:00
Tony Tam
d1603ba25e updated scalatest 2014-08-27 01:04:02 -07:00
Tony Tam
d4ce57bd15 added bigdecimal support 2014-08-27 01:03:49 -07:00
Tony Tam
5e56346dc9 updated scripts to use only assembly 2014-08-27 01:03:32 -07:00
Tony Tam
05db83a067 set to petstore 2014-08-27 00:17:45 -07:00
Tony Tam
707ee1c85b set version to 2.10.4 2014-08-27 00:17:33 -07:00
Tony Tam
a54adb925f added big decimal support 2014-08-27 00:16:12 -07:00
Tony Tam
8c53837802 updated scripts for assembly 2014-08-27 00:15:26 -07:00
Tony Tam
3625b89a15 updated to snapshot build 2014-08-26 16:53:52 -07:00
Tony Tam
2ed68c2df8 version 2.0.17 2014-08-26 16:52:26 -07:00
Tony Tam
db1915ec89 Merge pull request #252 from earldouglas/path-not-optional
Drop the 'optional' param for path params
2014-08-26 14:40:14 -07:00
James Earl Douglas
77e9ce5ede Drop the 'optional' param for path params 2014-08-26 14:38:27 -07:00
Tony Tam
013c19eb36 Merge pull request #251 from earldouglas/not-so-required
Set param as 'required' iff required, else set as 'optional'
2014-08-26 14:33:00 -07:00
James Earl Douglas
61c04ddaf1 Set param as 'required' iff required, else set as 'optional' 2014-08-26 14:31:45 -07:00
Tony Tam
b4d361130c Merge pull request #247 from xoom/issues/java_pom
Issues/java pom - remove scala dependencies from Java pom files
2014-08-25 23:05:04 -07:00
Tony Tam
8e7571c34f Merge pull request #248 from xhh/patch-1
Fixes #242 - Ruby model syntax error
2014-08-25 23:03:45 -07:00
xhh
1ba42ef6cc Fixes #242 - Ruby model syntax error 2014-08-26 09:18:54 +08:00
Rob Blair
fc77521d49 Simplify java sample poms.
* remove scala references from the java client pom template files.
* regenerate the petstore sample pom.xml, verify they can build properly.
2014-08-25 17:37:36 -07:00
Rob Blair
1522069281 Regenerate the java code before modifying templates 2014-08-25 17:35:44 -07:00
Tony Tam
a13f46e781 Merge pull request #245 from ganeshs/master
Added import mappings for java.util.Set and java.sql.Timestamp
2014-08-20 23:43:05 -07:00
Ganesh Subramanian
3ad1ecf153 Added import mapping for Timestamp 2014-08-21 12:11:19 +05:30
Ganesh Subramanian
6087181634 Added import mapping for Timestamp 2014-08-21 12:10:14 +05:30
Ganesh Subramanian
c09adc4539 Fix for issue #226 2014-08-21 12:01:44 +05:30
Tony Tam
a626dea181 Update api.mustache 2014-08-11 08:58:45 -07:00
Tony Tam
454ec4b438 fix for #235 2014-08-08 16:38:38 -04:00
Gerard Solé
4a64d602a0 Add plugin to build a jar with dependencies 2014-08-07 12:17:05 -07:00
Gerard Solé
f294656073 Edit line 76 to place pom.xml correctly 2014-08-07 11:28:08 -07:00
Ivan Porto Carrero
c7da910e68 remove sample files again 2014-08-05 10:56:20 -07:00
Ivan Porto Carrero
40d33693cf add typesafe releases resolver, fixes #232 2014-08-05 10:43:28 -07:00
Tony Tam
13eaf2bf63 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-08-03 09:19:01 -07:00
Tony Tam
d4508ed112 updated resolvers 2014-08-03 09:16:30 -07:00
Tony Tam
c252e9f7c6 added sonatype as resolver 2014-08-03 09:12:16 -07:00
Tony Tam
6690b80b29 Update .travis.yml 2014-08-02 16:32:10 -07:00
Tony Tam
19bb97a725 updated travis to 2.10.4 2014-08-02 16:09:00 -07:00
Tony Tam
62ee62ebd3 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-08-02 16:04:55 -07:00
Tony Tam
87083034ee Merge pull request #215 from JDiPierro/fix_java_generator_lists
Use config.processResponseClass to determine type of returnContainer
2014-07-24 11:48:19 -07:00
Tony Tam
d9de57da6f Merge pull request #223 from darkcube/master
CSharp: Multipart form submission
2014-07-23 08:43:37 -04:00
Timothy Lusk
d0b0323925 CSharp: Implement multipart form submission 2014-07-22 17:17:54 -04:00
Tony Tam
f592414409 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-07-18 09:52:57 -06:00
Tony Tam
e1c8f58d28 added 2.10.4 2014-07-18 09:52:53 -06:00
Tony Tam
4870ed7e51 Merge pull request #220 from darkcube/master
CSharp Changes
2014-07-16 16:30:15 -06:00
Timothy Lusk
bbe48814b4 CSharp: Add optional api constructor argument to set the basePath 2014-07-15 15:41:57 -04:00
Timothy Lusk
3b6ffa4a1f CSharp: Close the WebResponse if we throw an ApiException 2014-07-15 15:41:56 -04:00
Tony Tam
527c40b996 Merge pull request #211 from wcandillon/patch-1
Link back to the swagger-js-codegen project
2014-07-13 07:21:22 -07:00
Justin DiPierro
3aa2c86991 Output the resourcePath when no models are found rather than the basePath 2014-07-10 10:14:22 -04:00
Justin DiPierro
e2a20447df Fixed comment in test 2014-07-10 10:02:18 -04:00
Tony Tam
5d42c8cc5f moved to petstore 2014-07-04 10:19:48 -07:00
Tony Tam
256485ec5b updated template 2014-07-04 10:19:28 -07:00
Tony Tam
7ab0394e76 added node.js instead of jetty 2014-07-04 10:19:09 -07:00
Tony Tam
89b04b2e10 formatting 2014-07-04 10:18:44 -07:00
Tony Tam
a019a438e0 changed to petstore sample 2014-07-04 10:08:54 -07:00
Justin DiPierro
9834059786 Fixed BasicScalaGeneratorTest to expect Some(List) 2014-07-03 11:32:37 -04:00
Justin DiPierro
550fade9e0 Codegen.apiToMap should use config.processResponseClass when setting the returnContainer property. Test passes now 2014-07-03 11:24:05 -04:00
Justin DiPierro
aa1b4fc0fb Wrote failing test for Codegen 2014-07-03 11:23:07 -04:00
Tony Tam
5a659803a8 Merge pull request #212 from darkcube/master
Various csharp codegen fixes
2014-06-29 13:59:21 -07:00
Timothy Lusk
7bc7789e81 CSharp: Invoker should handle WebException and rethrow ApiException 2014-06-27 17:55:10 -04:00
Timothy Lusk
cf0721da73 CSharp: Use nullable primitive types to allow optional parameters 2014-06-27 16:10:45 -04:00
Timothy Lusk
dcbf4d1bfd CSharp: Use the correct model package name 2014-06-27 16:01:24 -04:00
William Candillon
017b578502 Link back to the swagger-js-codegen project 2014-06-26 15:05:33 +02:00
Tony Tam
58bade3b01 Update README.md 2014-06-19 09:33:41 -07:00
Tony Tam
02631e674a Merge pull request #207 from emmekappa/master
Fixing extensions and namespaces for csharp common files.
2014-06-17 10:53:17 -07:00
Michele Cantelli
5f5e534d05 CSharp: renaming the "packages" to follow the .NET style. 2014-06-17 16:22:04 +02:00
Michele Cantelli
51deeb478d Fixing extensions for csharp common files. 2014-06-17 15:18:58 +02:00
Tony Tam
acff8229b3 Merge pull request #206 from xoom/issue/modelsFromStatus
Issue/models from status - utilize the responseModel, if present
2014-06-16 17:03:17 -07:00
Rob Blair
233555790a Regenerate sample java files with example response status codes
* none of existing examples use the responseMessage.responseModel feature, but I have tested it.
* Didn't want to muck with sample json
* update the scripts used to generate both java versions.
* see https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#525-response-message-object
2014-06-16 12:59:53 -07:00
Rob Blair
d5ddac8e7e Update java mustache to show error status codes and models in generated API, in comments.
* I wonder if there is some clever way to make exceptions based on the model thrown, and automatically fill them in with the parsed error models?
* Until then, it's comments, and roll your own.
2014-06-16 12:51:35 -07:00
Rob Blair
e8210cd5e3 allow list of models to be returned in errors
* for example, a list of validation errors with an exceptional status
2014-06-16 12:40:44 -07:00
Rob Blair
2dc6b485e0 Generate classes from the models declared in 'responseModel'
* ResponseMessage has new constructor parameter, an optional string for responseModel
* Make sure we add it to list of models
* make sure the responseModel is part of the error list available to mustache
2014-06-16 12:34:44 -07:00
Tony Tam
11bede2b7d improved validation messages 2014-06-12 00:45:27 -07:00
Tony Tam
ed51dd9dea added files 2014-06-11 06:41:59 -07:00
Tony Tam
218f514005 updated node sample 2014-06-11 06:41:31 -07:00
Tony Tam
209e8e066c Merge pull request #201 from xoom/issue/JavaSafeApiName
coerce API names for classesand files to valid Java names
2014-06-11 06:12:55 -07:00
Tony Tam
7d05b01a56 Merge pull request #202 from gonimar/patch-1
Unused local variable 'json_data'.
2014-06-11 06:12:36 -07:00
Tony Tam
64f6bedc37 Merge branch 'repackage' 2014-06-11 06:12:15 -07:00
Tony Tam
4ae4aa98bb formatting 2014-06-11 06:11:45 -07:00
Tony Tam
db8bda087b made nickname optional 2014-06-11 06:11:31 -07:00
Tony Tam
06eb52118e updated to 2.3.0 release 2014-06-11 06:03:44 -07:00
Tony Tam
63be7d0069 removed println 2014-06-11 05:50:44 -07:00
Tony Tam
c7468125fa added clientName 2014-06-10 20:37:36 -07:00
Tony Tam
7b3d8bf799 added file upload support 2014-06-10 20:37:24 -07:00
Tony Tam
c4913fe583 wrapped in apiInfo 2014-06-10 20:37:08 -07:00
Tony Tam
d3339cb087 fixed string default 2014-06-10 20:36:58 -07:00
Tony Tam
ba4fda12dc added additional params 2014-06-10 20:36:29 -07:00
Tony Tam
7a6d6d27ff enabled logging 2014-06-10 20:36:10 -07:00
Tony Tam
bcabb03225 added support for nickname generation 2014-06-10 20:05:19 -07:00
Tony Tam
a404823c54 updated copyright 2014-06-10 17:23:35 -07:00
Tony Tam
96ea70e3c9 added className key 2014-06-10 17:23:20 -07:00
Tony Tam
9a01331ddd updated copyright 2014-06-10 16:58:43 -07:00
Tony Tam
3bfa468ed1 fixed filemap 2014-06-10 16:57:39 -07:00
Tony Tam
fdf8572535 updated copyright 2014-06-10 16:57:12 -07:00
Tony Tam
cff8b1552d updated copyright 2014-06-10 16:57:01 -07:00
Tony Tam
e73dd0a7c4 updated copyrights 2014-06-10 16:56:06 -07:00
Tony Tam
9c4c2dfd37 updated copyrights 2014-06-10 16:55:57 -07:00
Tony Tam
2f8355c953 regenerated client 2014-06-10 16:55:34 -07:00
Tony Tam
3f480482b6 regenerated client 2014-06-10 16:55:17 -07:00
Tony Tam
8274196999 regenerated client 2014-06-10 16:55:13 -07:00
Tony Tam
4e8c71f754 regenerated client 2014-06-10 16:54:48 -07:00
Tony Tam
57e7b41e9c regenerated client 2014-06-10 16:52:16 -07:00
Tony Tam
58d9894f1f regenerated client 2014-06-10 16:51:41 -07:00
Tony Tam
4b4d4d32cd regenerated client 2014-06-10 16:51:36 -07:00
Tony Tam
6a2ea9f614 regenerated client 2014-06-10 16:51:10 -07:00
Tony Tam
0d6754e167 regenerated client 2014-06-10 16:50:17 -07:00
Tony Tam
cb5c2a9708 regenerated client 2014-06-10 16:48:27 -07:00
Tony Tam
dc8ad7edf5 updated client 2014-06-10 16:48:05 -07:00
Tony Tam
52bc82149f file rename 2014-06-10 16:34:40 -07:00
Tony Tam
f53b5e27e0 updated scalatra version, templates for files, forms 2014-06-10 15:51:15 -07:00
Tony Tam
ce5be3452c added patch class 2014-06-10 15:50:49 -07:00
Tony Tam
ce14c225e5 added patch 2014-06-10 10:36:46 -07:00
Tony Tam
b78721826e regenerated client 2014-06-10 10:36:13 -07:00
Tony Tam
85113df113 regenerated client 2014-06-10 08:41:44 -07:00
Tony Tam
607b56cb87 removed println 2014-06-10 08:40:19 -07:00
Tony Tam
2dbf8b7d41 regenerated 2014-06-10 08:40:03 -07:00
Tony Tam
7d4c10043d updated client 2014-06-10 08:22:40 -07:00
Tony Tam
64604124c9 added array support 2014-06-10 08:22:08 -07:00
Tony Tam
50f20ad836 updated templates 2014-06-10 08:21:51 -07:00
Tony Tam
ac40283501 updated samples 2014-06-10 08:01:53 -07:00
Sergey Gonimar
e03d4fc1a5 Unused local variable 'json_data'.
The value of the variable is not used anywhere.
2014-06-10 19:25:00 +06:00
Rob Blair
05e9443db5 coerce API names of class and file valid Java names
* Swagger allows names of apis to include characters like '-' Java does not like that
* use same replace strings as used in toVarName
2014-06-09 17:04:57 -07:00
Tony Tam
1250cc758f updated version 2014-06-09 16:34:42 -07:00
Tony Tam
a18784da6c updated file maps 2014-06-09 15:05:23 -07:00
Tony Tam
c87d637edd regenerated 2014-06-06 00:27:40 -07:00
Tony Tam
bf4a4e5296 fixed imports, nesting 2014-06-06 00:27:15 -07:00
Tony Tam
4f7b80dad2 added debug, fixed headers 2014-06-05 22:49:09 -07:00
Tony Tam
8a2f9bc7bb compatibility 2014-06-05 20:08:59 -07:00
Tony Tam
b9806c183b fixed case 2014-06-05 20:08:37 -07:00
Tony Tam
5aa4c4c999 made snapshot 2014-05-31 16:04:19 -07:00
Tony Tam
424cfac80f updated config 2014-05-30 16:27:54 -07:00
Ivan Porto Carrero
715913f3b4 Update slightly add some test files 2014-05-30 15:17:53 -07:00
Tony Tam
1c2c4fdcd3 removed function override 2014-05-30 15:03:10 -07:00
Ivan Porto Carrero
2ea6c2a3a7 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-05-30 14:25:57 -07:00
Tony Tam
d91da857a0 removed unused code 2014-05-30 09:59:27 -07:00
Tony Tam
31e65969b3 removed printlns, cruft 2014-05-30 07:53:27 -07:00
Tony Tam
df250bc056 fixed model mapping, refactoring the processing of apiMap and modelMap so it's executed just once 2014-05-30 07:29:19 -07:00
Tony Tam
1569274684 fixed package 2014-05-20 00:14:01 -07:00
Tony Tam
6d8f751da4 added model package 2014-05-19 23:23:23 -07:00
Tony Tam
c2dd00a4ab fixed return type 2014-05-19 15:08:44 -07:00
Tony Tam
9e6ae6eef8 added opts for input 2014-05-15 08:51:41 -04:00
Tony Tam
58b985ba02 moved packages to address collisions with swagger-core per #145 2014-05-14 18:23:32 -04:00
Tony Tam
b4f3143c8c Merge pull request #159 from yanoosh/php-fix-sanitize
PHP - Improved/fixed serialization and deserialize.
2014-05-01 20:31:13 -07:00
Tony Tam
84ad6b5d50 rebuilt docs 2014-05-01 20:19:40 -07:00
Tony Tam
32c14af5ce added resize 2014-05-01 20:18:23 -07:00
Tony Tam
46023c47f5 Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-05-01 20:17:53 -07:00
Tony Tam
71212e5f68 reverted to artifactVersion 2014-05-01 20:16:46 -07:00
Tony Tam
6d1c34048c fix for #176 2014-05-01 20:16:27 -07:00
Tony Tam
f67006057e updated version 2014-05-01 20:14:41 -07:00
Tony Tam
e1e397a7b5 Merge pull request #179 from j-unior/scala-2.10
Added scala 2.10 support in generated maven profile.
2014-05-01 18:03:22 -07:00
Tony Tam
0f35799a77 fixed start script #188 2014-04-29 09:46:49 -07:00
Tony Tam
be44221d98 Merge pull request #187 from earldouglas/return-generated-files
Return files generated from BasicGenerator#generateClientWithoutExit
2014-04-24 16:06:12 -07:00
James Earl Douglas
94ad254a58 Return files generated from BasicGenerator#generateClientWithoutExit 2014-04-24 15:14:41 -07:00
James Earl Douglas
666a4be1f2 Return files generated from Codegen#writeSupportingClasses 2014-04-24 15:12:11 -07:00
James Earl Douglas
e542fbd0a2 De-duplicate code from Codegen#writeSupportingClasses 2014-04-24 15:07:45 -07:00
Pat
f4b2d13aa4 Update README.md 2014-04-09 10:15:08 -07:00
j-unior
abcae6da96 Added scala 2.10 support in generated maven profile. You can enable it with mvn install -P scala_2.10 on generated client 2014-04-01 16:56:08 +03:00
Tony Tam
1b9b3eaa8e Merge pull request #175 from STEAMULO/master
Filename misprint for Android generation
2014-03-25 11:33:03 -07:00
aansel
0babc4f192 Filename misprint for Android generation 2014-03-25 18:44:05 +01:00
webron
e51ffb37b4 Update README.md 2014-03-23 13:16:02 +02:00
Tony Tam
2fba96713c Merge pull request #172 from giovannibotta/master
Minor change to map used when generating supporting files
2014-03-19 08:27:49 -07:00
giodude
dccf8edc25 Minor change to map used when generating supporting files. 2014-03-19 11:18:23 -04:00
webron
d98aeac818 Create LICENSE 2014-03-19 16:08:55 +02:00
webron
62bfc4ea19 Update README.md
Updated license year.
2014-03-19 16:08:38 +02:00
Tony Tam
8d74029fba Merge pull request #170 from hsanjuan/master
Issue #168: Let runscala.sh run from everywhere without breaking
2014-03-18 18:54:28 -07:00
Hector Sanjuan
809cb5cf1f Issue #168: Let runscala.sh run from everywhere without breaking and correctly
setting the classpath
2014-03-17 16:21:36 +01:00
Tony Tam
a4196609c9 added friendly error message when SSL validation fails 2014-03-06 08:29:02 -08:00
Tony Tam
e7eedcf48d removed printlns 2014-03-05 07:54:12 -08:00
Tony Tam
8bf042b153 updated sample with form param support 2014-03-05 07:54:03 -08:00
Tony Tam
8325a12faf fixed hasMore 2014-03-04 20:05:16 -08:00
Tony Tam
03abccd8e8 fix for #154 2014-03-04 19:48:13 -08:00
Janusz Jablonski
19e79fedb2 Added backslash before DateTime object. 2014-03-03 00:40:45 +01:00
Tony Tam
71eacaa3b1 Merge pull request #160 from yanoosh/php-removed-escape
PHP - Removed escapeReservedWord method.
2014-03-02 13:30:08 -08:00
Janusz Jablonski
7cfa46d838 Removed escapeReservedWord method. 2014-03-02 18:31:35 +01:00
Janusz Jablonski
7989e78460 Improved/fixed serialization and deserialize. 2014-03-02 14:44:46 +01:00
Tony Tam
08466f615f Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-25 12:54:12 -08:00
Tony Tam
880d14990f added patch support 2014-02-25 12:53:11 -08:00
Tony Tam
39ac8f6d46 added patch support 2014-02-25 12:52:49 -08:00
Tony Tam
685fc7066f Update README.md 2014-02-22 07:21:13 -08:00
Tony Tam
127600e728 Update README.md 2014-02-21 17:29:22 -08:00
Tony Tam
d764328026 updated readme 2014-02-21 17:22:48 -08:00
Tony Tam
cae8296999 updated readme 2014-02-21 17:21:56 -08:00
Tony Tam
86efb71124 updated readme 2014-02-21 17:21:50 -08:00
Tony Tam
0899b08b8c Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-21 17:20:16 -08:00
Tony Tam
a770db9d3e added readme 2014-02-21 17:20:06 -08:00
Tony Tam
87b5c43166 Merge pull request #158 from mkantor/objc-safe-var-names
Prevent ObjC generator from producing invalid var names.
2014-02-21 13:41:26 -08:00
Matt Kantor
d14ab2aeff Prevent ObjC generator from producing invalid var names. 2014-02-21 13:35:13 -08:00
Tony Tam
5e95362542 added files 2014-02-20 21:09:48 -08:00
Tony Tam
e92d4e6258 updated sample 2014-02-19 16:46:11 -08:00
Tony Tam
641aada8a8 updated templates 2014-02-19 15:08:06 -08:00
Tony Tam
c8c59fe93a manual merge of https://github.com/wordnik/swagger-codegen/pull/135 2014-02-19 14:30:49 -08:00
Tony Tam
450746f94d updated jodatime version, added groupId and artifactId params 2014-02-19 14:30:20 -08:00
Tony Tam
827f03f272 Merge pull request #157 from df-jsykes/master
fix for broken links when using file system to browse
2014-02-19 12:40:03 -08:00
Jason Sykes
de6f949c64 fix for broken links when using file system to browse 2014-02-19 15:37:07 -05:00
Tony Tam
82cdec7197 Merge pull request #107 from SimonKaluza/patch-1
Update Objective-C's run-time type-check in SWGApiClient to allow NSArrays
2014-02-19 12:30:32 -08:00
Tony Tam
ab7e152877 Merge pull request #139 from cb372/pass-version-to-mustache
Add the API version to the Mustache model when generating supporting files
2014-02-19 12:24:09 -08:00
Tony Tam
0ec694940e fixed target directory 2014-02-19 12:16:31 -08:00
Tony Tam
5a4af29f0e fix for #156 2014-02-19 12:15:50 -08:00
Tony Tam
d72578e492 removed .yml suffix 2014-02-19 12:13:51 -08:00
Tony Tam
405e8b1786 Merge pull request #151 from yanoosh/accepts-header
Added consumes and produces to php templates.
2014-02-11 22:32:29 -08:00
Janusz Jabłoński
8909bd4ba1 Added consumes and produces to php templates. 2014-02-11 12:42:30 +01:00
Tony Tam
e9af56eb87 Update README.md 2014-02-06 18:14:17 -08:00
Tony Tam
ee361e9ae2 Merge pull request #150 from msolujic/master
Added 'char' and 'short' to alowed special words for Java generator.
2014-02-06 18:07:22 -08:00
msolujic
a580c38fed Added 'char' and 'short' to alowed special words for Java generator. 2014-02-07 02:53:09 +01:00
Tony Tam
668059a2c4 added travis build file 2014-02-05 09:08:14 -08:00
Tony Tam
31a53d5842 fix for #147 2014-02-05 08:59:28 -08:00
Tony Tam
e4e768062a Merge pull request #142 from bkowalik/master
BasicGenerator refactoring
2014-02-03 23:16:05 -08:00
Tony Tam
3192240dc0 Merge pull request #126 from cb372/joda-time-dependency
Add joda-time support to BasicJavaGenerator
2014-02-03 22:36:39 -08:00
Tony Tam
2d9a011f82 Merge pull request #133 from giodude/master
Explicitly defined type of a few properties
2014-02-03 22:36:01 -08:00
Tony Tam
476aed7f5b Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-02-03 17:31:35 -08:00
Tony Tam
09580c2d87 added publish fat jar 2014-02-03 17:31:19 -08:00
Bartosz Kowalik
48a07d031e BasicGenerator refactoring 2014-01-30 10:36:36 +01:00
Tony Tam
7414a9d56a Merge pull request #141 from radius314/master
Fix for non-GET verbs
2014-01-29 17:37:07 -08:00
Tony Tam
91e08b5524 fix for #140 2014-01-29 17:14:28 -08:00
Danny Gershman
8abb6521b4 removed line break 2014-01-29 19:45:24 -05:00
Danny Gershman
6394e5448c the verb wasn’t being set for web client, thus non GETs would probably always fail 2014-01-29 19:35:54 -05:00
Chris Birchall
2f5651d988 Add the API version to the Mustache model when generating supporting files.
This makes it easy to generate a client with version numbering in sync
with the server's advertised API version.
2014-01-28 15:44:38 +09:00
Tony Tam
a7afbd106f Merge pull request #138 from radonsky/add_getter_and_setter_to_parameters
added “getter” and “setter” to operation parameter properties
2014-01-27 14:31:48 -08:00
Marek Radonsky
d67774d90f added “getter” and “setter” to operation parameter properties 2014-01-27 13:56:28 -08:00
Tony Tam
07f36d3500 Merge pull request #137 from radonsky/clone_required_parameters
clone the parameter map when creating list of required parameters
2014-01-27 13:22:06 -08:00
Marek Radonsky
cc1bcf7989 clone the parameter map when creating list of required parameters 2014-01-27 13:11:20 -08:00
Tony Tam
096653daf7 removed old pom 2014-01-27 07:50:38 -08:00
Tony Tam
773a6b50eb fixed scala-reflect library inclusion 2014-01-27 07:50:23 -08:00
Tony Tam
bb3bd0d357 regenerated clients 2014-01-27 07:49:58 -08:00
Tony Tam
16eb944d2f Merge branch 'master' of github.com:wordnik/swagger-codegen 2014-01-27 07:48:44 -08:00
Tony Tam
74df3ab4f7 fix for csharp array response type 2014-01-27 07:48:29 -08:00
Chris Birchall
d18e75bbf1 Fixup: change spaces to tab 2014-01-26 11:34:04 +09:00
Chris Birchall
b7cffe4121 Add and register Jackson Joda-Time module 2014-01-26 11:31:08 +09:00
Tony Tam
5180b09acb Merge pull request #134 from bkowalik/master
Lack of models description bugfix
2014-01-24 10:44:45 -08:00
Bartosz Kowalik
6fad954147 Lack of models description bugfix 2014-01-24 19:33:50 +01:00
Giovanni Botta
3b1eac0e50 Explicitly defined type of a few properties
As per [this issue](https://github.com/wordnik/swagger-codegen/issues/130) this change makes the signature of those three properties consistent with their superclass so that traits assuming that signature can be mixed in.
2014-01-24 09:37:03 -05:00
Tony Tam
7715dbf0f2 Merge pull request #132 from gyeh/master
Fix docs to point to correct swagger spec URL
2014-01-22 13:45:48 -08:00
gyeh
bbb682c13d Fix docs to point to correct swagger spec URL 2014-01-22 12:01:44 -08:00
Tony Tam
42a8514c22 updated to scalatra 2.3 2014-01-21 09:40:42 -08:00
Tony Tam
ffca1e2969 updated listings 2014-01-21 09:39:30 -08:00
Tony Tam
1aa65bc14b Merge pull request #131 from cb372/fix-auth-deser
Fix deserialization of "authorizations" fields
2014-01-21 09:36:56 -08:00
Chris Birchall
1f46819b61 Fix deserialization of "authorizations" fields
Deserializer should expect a Map[String, AuthorizationType], not a
List[String].
2014-01-21 20:17:34 +09:00
Tony Tam
5892fdb2bb manual merge of #125 2014-01-16 20:34:26 -08:00
Tony Tam
32d792de01 Merge pull request #122 from vaelen/android-ignore-ssl-certificates
Update android target to work with self signed certificates if needed.
2014-01-16 20:30:19 -08:00
Tony Tam
82646f34ca Merge pull request #108 from backstop/generate-client-without-exit
Extract actual work from generateClient so that we can call it without killing the JVM.
2014-01-16 20:29:27 -08:00
Tony Tam
4f25ea7e6b Merge pull request #127 from cb372/fix-pom-fields
Improve groupId, artifactId, name in generated pom.xml
2014-01-16 20:19:25 -08:00
Chris Birchall
146f5c4c2a Improve groupId, artifactId, name in generated pom.xml
1. Replace hardcoded groupId (`com.wordnik`) with `package` variable.

2. artifactId and name were using non-existent variable `artifactId`.
This results in an empty artifactId, which makes Maven puke.
Replaced them with a sensible hardcoded value, "api-client".
2014-01-17 11:39:22 +09:00
Chris Birchall
6b9cba1411 Add joda-time support to BasicJavaGenerator
* Add joda-time as a dependency in pom.xml
* Add import mappings for commonly used joda-time classes
2014-01-17 10:34:19 +09:00
Tony Tam
a413efc3ca Merge pull request #121 from vaelen/fix-android-param-names
Fixes a bug where the wrong name was being used for header parameters in the Android code generator.
2014-01-16 13:36:57 -08:00
Tony Tam
6c8aed5dcc Merge pull request #112 from vaelen/fix-no-content
Updated Java client to handle the case of a NO_CONTENT response.
2014-01-16 13:36:06 -08:00
Andrew Young
52905fd6de Adds http scheme back in. 2014-01-08 16:32:30 -08:00
Andrew Young
f8807c7440 Code cleanup. 2014-01-08 16:32:13 -08:00
Andrew Young
755591f9e5 Updates the android target to use a version of HttpClient that is closer
to the version shipped with Android.  Also adds support for skipping SSL
certificate verifcation.  This allows the client to be used with self
signed certificates.

Conflicts:
	src/main/resources/android-java/apiInvoker.mustache
2014-01-08 16:31:50 -08:00
Andrew Young
896d0d4b54 [#61769706] Fixes a bug where the wrong name was being used for header
parameters in the Android code generator.
2014-01-06 22:54:42 -08:00
Tony Tam
cf95d4e59e added android sample 2014-01-06 12:27:57 -08:00
Tony Tam
b503994577 added android sample 2014-01-06 12:27:31 -08:00
Tony Tam
569f77b512 added yml2swagger 2013-12-20 16:42:59 -08:00
Tony Tam
773fb89acb Merge pull request #111 from RobBlairInq/issues/67
Issues/67 - generate expected exceptions in java templates when parameters are missing
2013-12-04 23:32:11 -08:00
Tony Tam
890b1ee3c2 updated package 2013-12-03 12:15:20 -08:00
Andrew Young
bfb5b721c5 Merge remote-tracking branch 'upstream/master' into fix-no-content
Conflicts:
	samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java
2013-12-02 13:42:15 -08:00
Robert Blair
9b6995f28c Merge branch 'master' into issues/67 2013-11-29 10:49:48 -08:00
Tony Tam
1b8bb4a0a6 rebuilt client 2013-11-28 13:28:26 -10:00
Tony Tam
7f35b875a4 Merge branch 'issues/91' of git://github.com/RobBlairInq/swagger-codegen into RobBlairInq-issues/91 2013-11-28 10:56:36 -10:00
Tony Tam
b5d2ed0322 Merge pull request #113 from RobBlairInq/issues/rebuildall
add script to run all the sample build scripts
2013-11-28 11:01:37 -08:00
Robert Blair
a7b78a6210 add script to run all the sample build scripts 2013-11-27 20:30:31 -08:00
Robert Blair
90c14fd116 issue/91 - and also check in the generated fils 2013-11-27 20:04:57 -08:00
Robert Blair
830ad87fcb issues/91 - enum in model commented out by default 2013-11-27 18:03:57 -08:00
Rob Blair
3a8928f869 issues/91 - regenerate petstore java files 2013-11-27 14:19:56 -08:00
Rob Blair
f883c5e77c issues/91 - allow enum and min/max to be used in templates
* parse numeric min / max values, include in parameters
* pass along the allowable values in the model used by templates
* ensure ‘hasMore’ is set for more parameter lists used by templates
* java model now includes min / max in comment, and allowed enum values as model children
* note: enums in spec can contain non-java characters, so the User.java in examples does not compile presently.
2013-11-27 14:18:35 -08:00
Andrew Young
8cc83d180d Fixed spacing issue. 2013-11-27 12:58:58 -08:00
Andrew Young
65cc529ec6 Updated to handle the case of a NO_CONTENT response. 2013-11-27 12:52:38 -08:00
Andrew Young
9686ceed2d Updated sample code to reflect changes. 2013-11-27 12:52:38 -08:00
Robert Blair
2c73efa536 And rebuild the samples for android-java 2013-11-27 08:02:42 -08:00
Robert Blair
800312361f Also android-java templates:
Rebuild wording sample ApiInvoker from latest.To throw expected ApiException instead of NullPointerException, check required parameters before use
2013-11-27 08:02:03 -08:00
Robert Blair
59897c19a9 Rebuild wording sample ApiInvoker from latest. 2013-11-27 01:16:58 -08:00
Robert Blair
08a3e9e881 Rebuild generated java samples with ApiException checking properly located 2013-11-27 01:16:21 -08:00
Robert Blair
1e2f7cb1f8 To throw expected ApiException instead of NullPointerException, check required parameters before use 2013-11-27 01:13:51 -08:00
Robert Blair
17c38115e6 rebuild java files before changes to template 2013-11-27 01:05:13 -08:00
Robert Blair
0ee6531fcd Version mapping for scala 2.10.* should be consistent. 2013-11-27 01:02:04 -08:00
George Shakhnazaryan
87c12c155d Extract actual work from generateClient so that we can call it without killing the JVM. 2013-11-19 15:55:06 -06:00
SimonKaluza
b373e4312e Fixed SWGApiClient.m's run-type type checking to allow NSArrays to be passed (for Swagger-generated methods that rely on List parameters in the HTTP body) 2013-11-12 23:26:09 -05:00
Ivan Porto Carrero
b39a609226 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-11-09 12:18:42 -08:00
Ivan Porto Carrero
d25f64cca0 change to return transpor client in async scala client 2013-11-09 12:18:20 -08:00
Tony Tam
0d40a53e06 Merge pull request #101 from joeltgf/master
Change "success" response status code in Java ApiInvoker to all 2xx responses vs. just 200.
2013-11-04 09:57:09 -08:00
Joel Caplin
c779905163 Rationalize response status code check. Ensure that all bona fide 2xx responses are treated in the same way that "200 OK" is.
Previously, was explicitly checking for response code 200 (ClientResponse.Status.OK).

Now, checks the family of the response to make sure it is successful (Family.SUCCESSFUL). This enables us to POST to resources that return 201 created - without having to handle a checked ApiException.
2013-10-31 18:23:44 -07:00
Tony Tam
59da358eb5 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-10-22 12:08:56 -07:00
Tony Tam
b815ffa403 formatting 2013-10-22 12:08:43 -07:00
Tony Tam
27a8be2381 upped version for release 2013-10-22 12:08:31 -07:00
Tony Tam
d5b53a1778 updated templates 2013-10-22 02:24:37 -07:00
Tony Tam
01b745c366 added hack to support writing json models in 1.1 format 2013-10-22 02:23:50 -07:00
Russell Horton
af96f33e6f regenerated python, python3 and php clients 2013-10-18 16:24:08 -07:00
Tony Tam
2dda926cb6 added path to spec files 2013-10-18 16:05:50 -07:00
Tony Tam
8fb6fc847c fix for #81 2013-10-18 15:26:20 -07:00
Tony Tam
11d1b8fcd4 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-10-18 14:46:21 -07:00
Tony Tam
5076d76a74 updated scripts to detect scala version and use appropriate library if possible 2013-10-18 14:46:03 -07:00
Tony Tam
044621b325 fixed import issue for objc 2013-10-18 14:45:45 -07:00
Tony Tam
5a3426dee6 renamed to use SWG as default prefix 2013-10-18 14:45:29 -07:00
Tony Tam
b6b28bb1a2 added version checking to avoid runtime scala incompatibilities 2013-10-18 14:45:05 -07:00
Tony Tam
189569518d updated to use afnetworking, cocoapods 2013-10-18 14:44:44 -07:00
Tony Tam
731fddbc30 regenerated client 2013-10-18 14:44:02 -07:00
Tony Tam
c4990b773d regenerated client 2013-10-18 14:43:26 -07:00
Tony Tam
d56c5e3b44 regenerated client 2013-10-18 14:42:57 -07:00
Tony Tam
6f1a4a2f82 Merge pull request #70 from sibblegp/fix_python_obj_type
Only check in lists and dictionaries
2013-10-18 08:25:10 -07:00
Tony Tam
a96d49f045 Merge pull request #100 from JanxSpirit/master
more descriptive exception message than MatchError
2013-10-16 20:21:11 -07:00
Gregg Carrier
ee19dfadf1 more descriptive exception message than MatchError 2013-10-16 22:11:15 -04:00
Tony Tam
2c5524476e Merge pull request #98 from markac/master
Fix Java Generator to always generate valid Java variable names
2013-10-07 22:10:28 -07:00
Mark Crowther
7bde2ffd6e Fix Java Generator to always generate valid Java variable names 2013-10-03 15:59:40 +01:00
Ivan Porto Carrero
f17654cd96 adds bodyParamRequired 2013-10-01 20:17:11 -07:00
Tony Tam
0a47fc23a3 Merge pull request #96 from df-jsykes/master
Fix for sidebar never scrolling in static docs, preventing the user from seeing all operations.
2013-09-30 15:04:06 -07:00
Jason Sykes
13eb435138 removed trigger 2013-09-30 17:56:39 -04:00
Jason Sykes
329f2817c2 Fix to scroll left side of sample docs 2013-09-30 17:50:36 -04:00
Tony Tam
609cef0b65 added android client 2013-09-20 12:34:12 -07:00
Tony Tam
cfa1f1a3c1 formatting 2013-09-19 08:13:50 -07:00
Tony Tam
e851262875 Merge pull request #95 from canadaduane/http_lc
Add an 'httpMethodLowerCase' property
2013-09-18 15:02:43 -07:00
Duane Johnson
7956ccc979 Add an 'httpMethodLowerCase' property
Some libraries use lower case httpMethod names for method calls. For
example, Ruby's Faraday library uses 'get', 'put', 'post', 'delete'.

Rather than this unweildy Ruby code produced by a mustache template:
  self.send("GET".downcase, path, request_opts)

This patch would allow for a more tidy output such as:
  get(path, request_opts)
2013-09-18 15:47:41 -06:00
Tony Tam
13bc111bd6 added some logging for fatal container issues 2013-09-18 12:55:12 -07:00
Tony Tam
cc0a30edf8 added header support, suppressed println 2013-09-18 11:55:45 -07:00
Tony Tam
0ffc6cb7a0 added header passing for codegen 2013-09-17 13:44:45 -07:00
Tony Tam
6a2f53f07d added type modification 2013-09-16 17:35:15 -07:00
Tony Tam
930b1ea0ea updated java example 2013-09-16 17:35:01 -07:00
Tony Tam
8e8e5308b6 added validation error if response not specified 2013-09-16 16:25:19 -07:00
Tony Tam
8f71d3fc50 added form params 2013-09-16 16:25:00 -07:00
Tony Tam
a123d8f066 added set mapping 2013-09-16 16:24:44 -07:00
Tony Tam
ea15cad8d5 fixes for position, and null arg removal 2013-09-16 16:24:24 -07:00
Tony Tam
e4a4f25f22 updated test to match changes in petstore as deployed 2013-09-16 16:23:56 -07:00
Tony Tam
93677742d3 Merge pull request #93 from canadaduane/swagger_config
Fix Ruby Request class: no access to inject_format on Class object
2013-09-12 17:33:26 -07:00
Duane Johnson
389765c113 Fix Ruby Request class: no access to inject_format on Class object 2013-09-12 16:05:59 -06:00
Tony Tam
5ef5fa7296 fixed container type translation 2013-09-12 13:57:03 -07:00
Tony Tam
4e408e6d80 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-09-12 13:42:01 -07:00
Tony Tam
a140ea2b9d fixed response type with array of simple types 2013-09-12 13:41:53 -07:00
Ivan Porto Carrero
b920881490 allow api level config of default imports in async scala 2013-09-09 18:51:04 -07:00
Tony Tam
56d5167a27 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-09-09 17:53:11 -07:00
Tony Tam
ddf81948a8 fixed bug where inner simple types were not being processed 2013-09-09 17:52:49 -07:00
Tony Tam
6652028d71 fixed bug where inner simple types were not being processed 2013-09-09 17:52:30 -07:00
Tony Tam
c9fccc5c75 removed lc array 2013-09-09 17:52:06 -07:00
Tony Tam
f766937ac7 added set support 2013-09-09 17:51:48 -07:00
Tony Tam
54f0823ec4 Update README.md 2013-09-09 15:25:38 -07:00
Tony Tam
5f61d20610 fixed build error 2013-09-09 13:59:55 -07:00
Ivan Porto Carrero
7ed2df2722 one more qualified type 2013-09-07 10:15:28 -07:00
Ivan Porto Carrero
a8a2a41315 Fill out qualified type when it's provided in the json 2013-09-06 22:14:48 -07:00
Ivan Porto Carrero
676283875b add the ability to exclude packages for models in the async scala codegen 2013-09-06 20:52:14 -07:00
Ivan Porto Carrero
4f95550977 fix set generation in async client 2013-09-05 21:58:24 -07:00
Ivan Porto Carrero
7056081605 fix Array[long] to List[Long] 2013-09-05 21:45:19 -07:00
Tony Tam
c90083855f added set test 2013-09-05 17:15:36 -07:00
Tony Tam
2f997e6b29 added fix for set 2013-09-05 17:15:10 -07:00
Tony Tam
8ad07d069c Merge pull request #87 from canadaduane/rubyclean
Change ruby generation to be a little more ruby-esque
2013-09-02 21:17:15 -07:00
Tony Tam
51e29cdfaf Merge pull request #88 from silentdth/master
documentation for compiling on Windows
2013-09-02 21:05:20 -07:00
Ivan Porto Carrero
811425a15f Revert "use position property in json to preserve ordering across generations"
This reverts commit 9ee361df5b.
2013-08-31 19:57:54 -07:00
Ivan Porto Carrero
9ee361df5b use position property in json to preserve ordering across generations 2013-08-31 19:46:14 -07:00
Benjamin Dodd
c1df192f09 documentation for compiling on Windows 2013-08-31 19:58:04 +12:00
Duane Johnson
7d6660d56c Change ruby generation to be a little more ruby-esque
Cleaned up some very long lines, added indentation, and shortened
the repetitive parts of the model mustache template.
2013-08-30 17:07:11 -06:00
Tony Tam
450b3c7ed5 fixed array with simple types, added test 2013-08-28 17:28:52 -07:00
Ivan Porto Carrero
e1e95fc1d2 remove redundant brace 2013-08-27 20:22:22 -07:00
Mike O'Connor
8365270134 bump version 2013-08-27 20:22:34 -04:00
Mike O'Connor
33163cd253 options should be unwrapped 2013-08-27 17:04:09 -04:00
Ivan Porto Carrero
2b04a5a127 Fix using the typeMappings 2013-08-26 17:55:28 -07:00
Ivan Porto Carrero
baa0a45537 add array type mapping 2013-08-26 02:05:39 -07:00
Ivan Porto Carrero
6747e3eb0b update to sbt 0.13.0 2013-08-25 18:20:23 -07:00
Ivan Porto Carrero
bad8d7c4b3 build.sbt edit 2013-08-24 19:42:51 -07:00
Ivan Porto Carrero
2610ac7fc3 update async scala client to use type classes for serializing and deserializing 2013-08-24 19:36:43 -07:00
Ivan Porto Carrero
e2730ae34e fix async scala client generator 2013-08-22 15:31:42 -07:00
Tony Tam
beeeb133e6 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-08-22 13:18:13 -07:00
Tony Tam
01dc29d789 fix for jsonschema format in model property with array 2013-08-22 13:18:03 -07:00
Ivan Porto Carrero
21085b472a bump version 2013-08-22 10:09:22 -07:00
Tony Tam
5483ba5ae7 fix for type 2013-08-20 22:53:13 -07:00
Tony Tam
4a50bb3183 updated to 1.2 spec support 2013-08-17 10:10:37 -07:00
Tony Tam
daeb964bfc updated import 2013-08-16 21:22:14 -07:00
Tony Tam
ad4bf57535 updated prefix 2013-08-16 21:22:06 -07:00
Tony Tam
83ff341e5e fix for #83 2013-08-16 17:53:03 -07:00
Tony Tam
701d4c15a9 updated to 1.2 2013-08-16 17:43:02 -07:00
Tony Tam
01ff7be020 updated to 1.2 2013-08-16 17:22:02 -07:00
Tony Tam
a7bf8b6314 fixes for inner types, spec 1.2 conversion 2013-08-16 17:16:20 -07:00
Tony Tam
c386edb2e4 fixes for inner types, spec 1.2 conversion 2013-08-16 17:16:04 -07:00
Cody Allen
9e12191a64 Fix wrapping default values in an Option for optional params 2013-08-16 09:26:33 -07:00
Ivan Porto Carrero
feb6c188d3 Fix isNotRequired/required on models 2013-08-14 23:16:50 -07:00
Tony Tam
1e245583c9 updated docs 2013-08-14 17:56:08 -07:00
Tony Tam
0e03509cbc added checking 2013-08-14 17:56:03 -07:00
Tony Tam
3bf486e49d updated script 2013-08-14 17:19:20 -07:00
Tony Tam
2497e3a8cf fix for serializer 2013-08-14 17:19:03 -07:00
Tony Tam
d798725d9e added file 2013-08-14 14:49:10 -07:00
Tony Tam
f0517880e7 updated converter args, serializer 2013-08-14 14:43:13 -07:00
Tony Tam
dd68c31fb4 fixed tests 2013-08-14 14:41:35 -07:00
Tony Tam
f6622fbb59 added spec converter 2013-08-14 13:52:19 -07:00
Tony Tam
aa1fbb680b updates for response class to 1.2 spec 2013-08-11 15:36:16 -07:00
Tony Tam
93067a0ce0 updated 1.2 tests 2013-08-11 09:42:53 -07:00
Tony Tam
5a064d6bad updated 1.2 tests 2013-08-11 09:26:32 -07:00
Tony Tam
feb5a2ff3b updated to 1.2 spec 2013-08-10 09:55:30 -07:00
Tony Tam
73a70a65ff added 1.2 spec tests 2013-08-10 09:54:37 -07:00
Tony Tam
3b81d81143 added 1.2 spec tests 2013-08-10 09:54:14 -07:00
Tony Tam
74543f75f9 merged pom + invoker changes, added correct mapping for list 2013-08-08 16:18:57 -07:00
Tony Tam
d9d6cc1e76 fixed filePath 2013-08-08 16:18:33 -07:00
Tony Tam
a3f5c0c688 fixed content type for java client 2013-08-08 16:05:05 -07:00
Tony Tam
17b63b2be8 more refactoring to support 1.2 spec 2013-08-08 15:32:37 -07:00
Tony Tam
558a9cbf64 updated support for relative base paths 2013-08-08 13:53:14 -07:00
Tony Tam
021f269d9d prep for swagger-1.2 support 2013-08-08 12:13:27 -07:00
Tony Tam
7f73007ec4 prep for swagger-1.2 support 2013-08-08 12:13:08 -07:00
Tony Tam
1a1bfd2c7c added logger per #273 2013-08-01 18:21:19 -07:00
Tony Tam
90b34333f5 changed response code 2013-07-31 20:43:29 -07:00
Tony Tam
fa59f168a7 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-07-30 23:55:57 -07:00
Tony Tam
9102a333e3 moved files to version-specific 2013-07-30 23:55:43 -07:00
Tony Tam
43bc3f5be2 formatting 2013-07-30 23:55:19 -07:00
Tony Tam
fbc09aa77b renamed to separate spec versions 2013-07-30 23:55:05 -07:00
Russell Horton
03619b19a1 in PHP client, add query params for all methods, not just GET 2013-07-23 17:50:07 -07:00
Tony Tam
422e79dd01 Update README.md 2013-07-21 10:07:14 -07:00
Tony Tam
b9a60649a8 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-07-20 23:13:23 -07:00
Tony Tam
a06dd72989 added exit to quit template engine 2013-07-20 23:13:12 -07:00
Tony Tam
932dc843f9 updated urls per #75 2013-07-20 23:12:58 -07:00
Tony Tam
c45c8d251a Merge pull request #73 from victorgit/master
Code that generates a groovy plugin based on the swagger resources
2013-07-18 07:41:08 -07:00
Victor Trakhtenberg
ea6a9305be Groovy client generation 2013-07-18 14:31:47 +03:00
Victor Trakhtenberg
c82a5c8aaa Groovy client generation 2013-07-18 13:30:16 +03:00
Victor Trakhtenberg
8135cd65dc Groovy client generation 2013-07-18 13:27:22 +03:00
Tony Tam
db68a3acbd Merge pull request #63 from geoffreys/master
C# template compiler error for non-string parameters
2013-07-16 21:50:16 -07:00
George Sibble
0628c63b15 Check for None Type
Signed-off-by: George Sibble <gsibble@gmail.com>
2013-07-16 14:32:17 -07:00
George Sibble
4d05b5d81f Only check in lists and dictionaries
The "in" operator also works on strings which can cause problems with this line if the attribute and the object are named the same thing.

Signed-off-by: George Sibble <gsibble@gmail.com>
2013-07-16 14:20:49 -07:00
Tony Tam
24af6a00c6 added 2.9.1 launcher support 2013-07-09 16:01:34 -07:00
Tony Tam
fd72c1b9f1 fix for #69, fixed test output 2013-07-03 13:48:35 -07:00
Tony Tam
885cd36165 added support for swagger 1.2 spec 2013-06-30 21:36:52 -07:00
Ivan Porto Carrero
a31780e08f Make the launcher scripts use the assembly generated jar 2013-06-25 20:10:48 -07:00
Ivan Porto Carrero
dc3a4b4eb5 allow adding typeMappings and includes through config 2013-06-23 18:35:48 -07:00
Tony Tam
c1e018947d changed to staging repo 2013-06-23 08:55:47 -07:00
Ivan Porto Carrero
4a3321f253 use sonatype repos for publishing 2013-06-22 22:34:47 -07:00
Ivan Porto Carrero
c9614ab795 force maven style publishing 2013-06-22 22:34:21 -07:00
Ivan Porto Carrero
500262bd03 allow using Map[String, List[String]] 2013-06-22 22:01:43 -07:00
Ivan Porto Carrero
4467fe66c6 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-06-22 17:45:02 -07:00
Geoff Steffens
981ce3d990 Support non-string parameters in querystring 2013-06-19 14:47:40 +10:00
Tony Tam
936387d1df fix for #61 2013-06-17 21:33:40 -07:00
Tony Tam
d14f74b82c removed primitives from reserved words 2013-06-17 20:58:06 -07:00
Tony Tam
85b1fb71c2 Merge pull request #60 from radius314/feature/code-comments
Feature/code comments
2013-06-05 08:53:19 -07:00
Tony Tam
9e8f817a6b Merge pull request #59 from radius314/feature/escaping-forward-slash-windows
fixing replaceAll bug on windows with escaping paths, changed replaceAll...
2013-06-05 08:18:19 -07:00
Tony Tam
697f6dc7c7 updated names 2013-06-04 11:08:34 -07:00
Danny Gershman
d038ef4799 needed to update the compile file for documentation 2013-06-04 01:15:47 -04:00
Danny Gershman
3a2d7adc35 code comment templating added 2013-06-03 19:02:09 -04:00
Ivan Porto Carrero
0e8274ff3b use latest swagger async http client 2013-06-02 18:28:10 -07:00
Tony Tam
a335fe008d added groupId 2013-06-01 12:15:23 -07:00
Tony Tam
251384bb47 added groupId 2013-06-01 12:15:14 -07:00
Tony Tam
54ec7f2bb2 added artifact id 2013-06-01 12:11:59 -07:00
Tony Tam
2199d08e72 added support for artifact id 2013-06-01 12:11:12 -07:00
Danny Gershman
e9fa4434f2 fixing replaceAll bug on windows with escaping paths, changed replaceAll() to replace() 2013-05-30 15:35:47 -04:00
Tony Tam
154b2fdeca Merge pull request #56 from radius314/feature/csharp-templates
created CSharp codegen templating
2013-05-28 11:50:54 -07:00
Danny Gershman
cf05602924 removed property name cleanup due to naming conflicts 2013-05-28 14:42:28 -04:00
Danny Gershman
9a73eb8994 created CSharp codegen templating 2013-05-28 14:17:41 -04:00
Tony Tam
181e7a8b55 Update README.md 2013-05-20 14:26:09 -06:00
Tony Tam
6635616826 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-05-20 13:24:30 -07:00
Tony Tam
71426e58a3 added screenshot 2013-05-20 13:24:22 -07:00
Tony Tam
00d279ccd5 Merge pull request #54 from sibblegp/master
Make injection of .format in Ruby optional
2013-05-18 15:02:29 -07:00
Mike
a4cd839c1e Make the injection of '.{format}' into the root path component optional 2013-05-18 20:25:55 +00:00
George Sibble
4354002bce Merge branch 'master' of git://github.com/wordnik/swagger-codegen 2013-05-18 16:10:37 -04:00
George Sibble
106e2b7cb9 Merge branch 'master' of github.com:sibblegp/swagger-codegen 2013-05-18 16:09:42 -04:00
George Sibble
8443e7a749 Remove "Content-Type" Header from requests with no request body 2013-05-18 16:09:28 -04:00
Tony Tam
3f3471997e removed swagger-core deps 2013-05-18 16:09:28 -04:00
Tony Tam
90fbbec405 removed swagger-core deps 2013-05-18 16:09:28 -04:00
David M. Lee
384ac98295 Display an error when an API fails to parse. 2013-05-18 16:09:28 -04:00
David M. Lee
53f1394c25 Corrected typo in statis HTML API docs 2013-05-18 16:09:28 -04:00
Tony Tam
5eff3fd976 added CORS filter 2013-05-18 16:09:28 -04:00
Tony Tam
f4c859aede removed unused files 2013-05-18 16:09:28 -04:00
Tony Tam
65f2ec1f79 updated links 2013-05-18 16:09:28 -04:00
Tony Tam
c3cb548fb3 updated links 2013-05-18 16:09:28 -04:00
Tony Tam
996e605008 fixed typo 2013-05-18 16:09:28 -04:00
Tony Tam
92ac02e6c6 added java sample 2013-05-18 16:09:27 -04:00
Tony Tam
ffc6a2fc9e updated to snapshot 2013-05-18 16:09:27 -04:00
Tony Tam
36bf178947 updated readme 2013-05-18 16:09:27 -04:00
Tony Tam
a757416a0e removed commented out block 2013-05-18 16:09:27 -04:00
Tony Tam
f167959a38 updated example 2013-05-18 16:09:27 -04:00
Tony Tam
e8e8c18c8f added field 2013-05-18 16:09:27 -04:00
Tony Tam
e91df944cc formatting 2013-05-18 16:09:27 -04:00
Tony Tam
cc4fecb217 formatting 2013-05-18 16:09:27 -04:00
Tony Tam
2443d3d91b updated readme 2013-05-18 16:09:27 -04:00
Tony Tam
f2f33b98f7 updated to scalatra 2.2.0 2013-05-18 16:09:27 -04:00
Tony Tam
184a9d0d5c added README 2013-05-18 16:09:27 -04:00
Eugen Anghel
90aa2ab4eb made Models optional 2013-05-18 16:09:27 -04:00
Tony Tam
2fab0b46c8 added files 2013-05-18 16:09:27 -04:00
Tony Tam
bff8736889 added file upload support 2013-05-18 16:09:27 -04:00
Tony Tam
37e5571965 added file upload support 2013-05-18 16:09:27 -04:00
Tony Tam
6c3935f7ea added file support 2013-05-18 16:09:27 -04:00
Tony Tam
dbf42de407 added file upload support 2013-05-18 16:09:26 -04:00
Tony Tam
900fbe6e75 removed files 2013-05-15 15:21:50 -07:00
Tony Tam
fe4af50fb0 added more logic for static files 2013-05-15 15:21:11 -07:00
Ivan Porto Carrero
81c103b12d use async http client with service locator 2013-05-12 20:13:58 -07:00
Ivan Porto Carrero
023013b6fe have an empty body param for setting a different value for write requests 2013-05-12 17:18:15 -07:00
Ivan Porto Carrero
dfdd8cac94 fixes #52: running the validator now uses the sbt-assembly generated jar 2013-05-09 20:43:55 -06:00
Tony Tam
d30441dd27 Merge pull request #51 from spatex/master
fixes for error messages in Java/JaxRS generated code
2013-05-06 12:46:18 -07:00
Ivan Porto Carrero
bd565be660 update logback in generated client and use package as organization 2013-05-05 22:38:59 -07:00
Ivan Porto Carrero
ad81434310 integrate with sbt assembly generated jar 2013-05-05 22:06:59 -07:00
Ivan Porto Carrero
965df0bc2a Adds shell script for generating async scala client 2013-05-05 21:57:24 -07:00
Tony Tam
cb1c36721c added files 2013-05-05 15:31:21 -07:00
Tony Tam
fede9e97e4 updated templates 2013-05-05 15:29:40 -07:00
Tony Tam
617baa29cd updated docs 2013-05-05 15:29:01 -07:00
Tara Neier
645109111e adding handling for api error messages in java-jaxrs template 2013-05-04 20:30:01 -07:00
Tony Tam
24aa603230 regenerated client 2013-04-22 09:50:02 -07:00
Tony Tam
8b8a956155 regenerated sample 2013-04-22 09:49:45 -07:00
Tony Tam
5e801dd1d7 updated repos, removed scala runtime 2013-04-22 09:49:15 -07:00
Ivan Porto Carrero
98200e6b39 add logger 2013-04-10 18:39:41 +02:00
Ivan Porto Carrero
f3405bcf29 really fix stackoverflow 2013-04-09 19:33:22 +02:00
Ivan Porto Carrero
1724c9328e Make recurseModel method tail-recursive, fix stack overflow error 2013-04-09 17:20:08 +02:00
Ivan Porto Carrero
025502efad Adds async scala client generation 2013-04-09 16:28:47 +02:00
George Sibble
397ebd4bdb Remove "Content-Type" Header from requests with no request body 2013-04-06 13:54:59 -07:00
Tony Tam
6adf368c08 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-04-04 22:18:03 -07:00
Tony Tam
871e0e30f1 removed swagger-core deps 2013-04-04 22:17:25 -07:00
Tony Tam
07ab7d98a6 removed swagger-core deps 2013-04-04 22:16:52 -07:00
Tony Tam
69d4c2a27b Merge pull request #47 from leedm777/parse-failures
Display an error when an API fails to parse.
2013-04-03 13:26:59 -07:00
David M. Lee
0b4fa11486 Display an error when an API fails to parse. 2013-04-03 15:12:57 -05:00
Tony Tam
7929dbfee1 Merge pull request #46 from leedm777/static-docs-typo
Corrected typo in statis HTML API docs
2013-04-03 12:52:03 -07:00
David M. Lee
73b234fd23 Corrected typo in statis HTML API docs 2013-04-03 14:44:49 -05:00
Tony Tam
df333fdfb5 added CORS filter 2013-04-03 00:27:51 -07:00
Tony Tam
99c292a7ad removed unused files 2013-04-03 00:27:41 -07:00
Tony Tam
8cd540e2e1 updated links 2013-04-03 00:22:33 -07:00
Tony Tam
9bef2a8ac6 updated links 2013-04-03 00:20:32 -07:00
Tony Tam
e3ac63da93 fixed typo 2013-04-03 00:19:27 -07:00
Tony Tam
958206c469 added java sample 2013-04-03 00:19:21 -07:00
Tony Tam
98f1941b30 updated to snapshot 2013-03-22 11:03:21 -07:00
Tony Tam
812dc0f528 updated readme 2013-03-21 21:50:42 -07:00
Tony Tam
9fa5737f54 removed commented out block 2013-03-21 21:47:01 -07:00
Tony Tam
0188c719d0 updated example 2013-03-21 21:44:19 -07:00
Tony Tam
45ac101779 added field 2013-03-21 21:43:53 -07:00
Tony Tam
a75a406e05 formatting 2013-03-20 22:27:03 -07:00
Tony Tam
80b031710e formatting 2013-03-20 22:26:24 -07:00
Tony Tam
87b1d71f72 updated readme 2013-03-20 21:38:23 -07:00
Tony Tam
9a86b1df8b updated to scalatra 2.2.0 2013-03-20 21:35:41 -07:00
Tony Tam
b86eb53256 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-03-20 16:17:15 -07:00
Tony Tam
9f5be1cf5a added README 2013-03-20 16:17:04 -07:00
Tony Tam
a1da95c9a5 Merge pull request #40 from eugen/make-models-optional
made Models optional
2013-03-20 07:18:48 -07:00
Eugen Anghel
cb422950f8 made Models optional 2013-03-20 09:49:56 +02:00
Tony Tam
af5f8909a6 added files 2013-03-13 23:47:05 -07:00
Tony Tam
0a7e606650 added file upload support 2013-03-13 23:45:26 -07:00
Tony Tam
c47e553425 added file upload support 2013-03-13 23:45:10 -07:00
Tony Tam
7659ab5a47 added file support 2013-03-13 20:06:48 -07:00
Tony Tam
a31ae97ea0 added file upload support 2013-03-13 19:59:15 -07:00
Ivan Porto Carrero
3cbf2abc5c Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-03-08 23:02:03 +01:00
mrjf
d92294695d Merge pull request #37 from sibblegp/master
Fix Object Type Detection
2013-03-07 12:53:29 -08:00
George Sibble
d7e93cbda9 Fix Object Type Detection to Not Incorrectly Convert Booleans and 0 Integers to None
Prior to this patch, zero integers and False booleans were being converted to None since both evaluate the origin if statement (it not obj) to True.

Signed-off-by: George Sibble <gsibble@gmail.com>
2013-03-07 12:43:46 -06:00
mrjf
a9e0635d31 Merge pull request #34 from sibblegp/master
Add URL query parameters to all calls, not just GET
2013-03-06 22:35:28 -08:00
mrjf
f22dbc510d Merge pull request #36 from mrjf/master
in Swagger.php, use dirname instead of grepping for slash, which could be / or \
2013-03-06 10:08:13 -08:00
Russell Horton
16aa731867 in Swagger.php, use dirname instead of grepping for slash, which could be / or \ 2013-03-06 10:06:35 -08:00
Tony Tam
e1f295398e added files per #35 2013-03-05 17:44:21 -08:00
George Sibble
d00c5d0ad8 Fix typo in python template 2013-03-04 20:05:11 -06:00
George Sibble
29a132496e Fix My Own Mistake (GET Triggered an error)
Signed-off-by: George Sibble <gsibble@gmail.com>
2013-03-04 19:58:59 -06:00
George Sibble
c032b3c2d4 Move URL Query Parameters into All HTTP Verbs
HTTP Spec states that URL query parameters can be in all verbs.  Should probably check all languages to make sure that query parameters are always passed even if it is not a GET call.

Signed-off-by: George Sibble <gsibble@gmail.com>
2013-03-04 19:30:24 -06:00
Tony Tam
68ce5d78f9 added test to verify nested List objects are recursed 2013-03-01 14:37:28 -08:00
Tony Tam
70fef15f81 name clean-up 2013-02-28 20:22:02 -08:00
Tony Tam
7b651dedcd removed null guards 2013-02-28 20:19:04 -08:00
Tony Tam
a6af380833 removed println 2013-02-28 17:28:15 -08:00
Tony Tam
b0993379ee added model test 2013-02-28 17:27:56 -08:00
Tony Tam
7e7005abe2 Merge pull request #33 from sibblegp/master
Bug Fix:  Null JSON value breaks integer conversion
2013-02-28 17:27:06 -08:00
George Sibble
55cf01d9f7 Also for Python 3 2013-02-28 15:06:59 -08:00
George Sibble
7354d6722f Include TypeError Detection
Check for NoneType in Python
2013-02-28 15:04:35 -08:00
Ivan Porto Carrero
8e7c3b7164 update sbt script 2013-02-25 10:27:31 +01:00
Tony Tam
c33358d48f updated docs 2013-02-22 19:15:17 -08:00
Tony Tam
ea541a6cf7 updated docs 2013-02-22 19:12:35 -08:00
Tony Tam
9a067c7821 added sample output docs 2013-02-22 19:04:01 -08:00
Tony Tam
67d48e4e35 fixed data type 2013-02-22 19:03:43 -08:00
Tony Tam
1b89879a47 updated output path 2013-02-22 19:03:32 -08:00
Tony Tam
79c4a09181 changed to use java 2013-02-22 19:03:22 -08:00
Tony Tam
ea35f2cf0e disabled parallel tests 2013-02-22 18:55:13 -08:00
Tony Tam
828607c67b added static doc script 2013-02-22 18:23:27 -08:00
Tony Tam
64ffd7be36 removed fail on warning 2013-02-22 18:19:01 -08:00
Tony Tam
4003a0d61c turned model into map 2013-02-22 18:18:17 -08:00
Tony Tam
631b44fee2 updated path 2013-02-22 18:16:59 -08:00
Tony Tam
c2c1bbc417 Merge pull request #23 from mrjf/master
wordnik.com api clients for python, python3 and php
2013-02-21 11:07:02 -08:00
Tony Tam
10c5a8346f Merge pull request #31 from ceraslabs/master
Fixed compilation error
2013-02-21 11:03:57 -08:00
Hongbin Lu
c0c2f0bebc Fixed an error that escaping a non-string object 2013-02-21 17:33:37 +00:00
Hongbin Lu
85e8ead0cf Fixed a ArrayList cannot be resolved error 2013-02-21 17:19:16 +00:00
Tony Tam
2e0ac79f0c Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-02-21 00:24:32 -05:00
Tony Tam
b7dae2a846 cleaned up compiler warnings 2013-02-21 00:24:20 -05:00
Ivan Porto Carrero
cf470009ba update to sbt 0.12.2 2013-02-20 18:26:11 +01:00
Russell Horton
434102550f update php wordnik sample app 2013-02-10 13:24:39 -08:00
Russell Horton
00ac23c462 separate PHP query, header and path param serialization and encoding 2013-02-10 13:24:01 -08:00
Tony Tam
402266e65b removed optional name field for models 2013-02-06 17:03:30 -08:00
Tony Tam
852eb0bf49 added error handling 2013-02-06 17:03:19 -08:00
Tony Tam
84e17c7707 made public 2013-02-06 16:39:44 -08:00
Tony Tam
fb4a6c968c better error messages 2013-02-06 16:39:31 -08:00
Tony Tam
b3076d95b2 began adding friendly validation messages 2013-02-05 17:52:17 -08:00
Tony Tam
a2bff39427 added credentials for publish 2013-01-14 14:22:15 -08:00
Tony Tam
0d82786715 fixed scalate deps for mvn build 2013-01-14 13:49:16 -08:00
Tony Tam
17a433fb59 Merge pull request #24 from wordnik/sbtify
use sbt for building, only use json4s-jackson
2013-01-14 13:41:23 -08:00
Ivan Porto Carrero
55ce19a233 also build for 2.10 2013-01-14 01:56:19 +01:00
Ivan Porto Carrero
59d74a83af use sbt for building, only use json4s-jackson 2013-01-14 01:06:19 +01:00
Tony Tam
dea4b746b7 Merge branch 'master' of github.com:wordnik/swagger-codegen 2013-01-04 11:08:49 -08:00
Tony Tam
61f5031f8a updated with npm-managed swagger package 2013-01-04 11:08:20 -08:00
Tony Tam
5d60632aa6 updated with npm-managed swagger package 2013-01-04 11:07:12 -08:00
ramesh
fe30ed3580 Fixed issue in configuring output path for supporting files. 2013-01-03 14:27:43 -08:00
Tony Tam
7370354535 fixed repo 2012-12-26 21:22:50 -08:00
Tony Tam
b2890a00a3 removed println 2012-12-26 20:06:29 -08:00
Tony Tam
f329b94625 fixed string bug 2012-12-26 20:02:03 -08:00
Russell Horton
62352a126e removing unneeded capitalized data types 2012-12-21 11:27:48 -08:00
Russell Horton
16be3a7f54 added sample readmes 2012-12-20 15:32:05 -08:00
Russell Horton
1de97d204d updated env var documentation 2012-12-20 14:53:51 -08:00
Russell Horton
2bc8cc01a5 tests for python3 wordnik.com api client 2012-12-20 14:38:15 -08:00
Russell Horton
6266a94857 generated python3 client for wordnik.com api 2012-12-20 14:35:48 -08:00
Russell Horton
bd19ef489c python3 wordnik.com api client generation 2012-12-20 14:35:27 -08:00
Russell Horton
a7b9a930e5 tests for python wordnik.com api client 2012-12-20 14:35:10 -08:00
Russell Horton
39659d8c36 generated python wordnik.com api client 2012-12-20 14:34:33 -08:00
Russell Horton
22ebb85c35 python wordnik.com api generation 2012-12-20 14:34:01 -08:00
Russell Horton
30109204d9 generated php client for wordnik.com api 2012-12-20 14:33:45 -08:00
Russell Horton
3cd48e17d2 php tests for wordnik.com api client 2012-12-20 14:32:51 -08:00
Russell Horton
da5c7a77c3 php wordnik.com api client generation 2012-12-20 14:32:29 -08:00
Russell Horton
43708f6395 map lower case type names as well as upper 2012-12-20 14:26:19 -08:00
Russell Horton
29cec989b2 better escaping for path parameters 2012-12-20 14:25:47 -08:00
Russell Horton
93c0134da9 better url escaping for path values 2012-12-20 14:25:14 -08:00
Russell Horton
5840120124 added Scrabble score method and model 2012-12-20 14:24:42 -08:00
Tony Tam
9d014e89bc added distro target 2012-12-18 23:25:27 -08:00
Tony Tam
15a3e15f2f Merge branch 'master' of github.com:wordnik/swagger-codegen 2012-12-18 22:54:12 -08:00
Tony Tam
95d77807c2 cleaned up toApiName to strip bad chars 2012-12-18 22:53:46 -08:00
Tony Tam
28221b5f5a added more lenient int extraction, optional basepath 2012-12-18 22:53:25 -08:00
Tony Tam
c9397ce1e7 changed to use paramName instead of baseName to support the toParamName method 2012-12-18 22:53:03 -08:00
Tony Tam
a1f8bcd0ae Update README.md 2012-12-08 21:16:40 -08:00
Tony Tam
f1f466b69f made extracter smarter with bool, int, string 2012-12-08 12:52:03 -08:00
Tony Tam
df48f4d8a9 added models to map 2012-12-05 07:38:10 -08:00
Tony Tam
4c6cea87f1 [maven-release-plugin] prepare for next development iteration 2012-12-04 17:55:57 -08:00
1074 changed files with 85611 additions and 32429 deletions

5
.gitignore vendored
View File

@@ -23,3 +23,8 @@ samples/server-generator/node/output/node_modules
samples/server-generator/scalatra/target
samples/server-generator/scalatra/output/.history
target
.idea
.lib
atlassian-ide-plugin.xml
.DS_Store

4
.travis.yml Normal file
View File

@@ -0,0 +1,4 @@
language: java
script: mvn verify
jdk:
- oraclejdk7

263
README.md
View File

@@ -1,142 +1,219 @@
# Swagger Code Generator
[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.png)](https://travis-ci.org/swagger-api/swagger-codegen)
## Overview
This is the swagger codegen project, which allows generation of client libraries automatically from a
Swagger-compliant server. You can find out more about both the spec and the framework at
http://swagger.wordnik.com. For more information about Wordnik's APIs, please visit http://developer.wordnik.com.
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
## What's Swagger?
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service.
Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
## Compatability
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification:
Swagger Codegen Version | Release Date | Swagger Spec compatability | Notes
----------------------- | ------------ | -------------------------- | -----
2.1.0-M1 | 2015-02-16 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.0-M1](https://github.com/swagger-api/swagger-codegen/tree/v2.1.0-M1)
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)
### Prerequisites
You need the following installed and available in your $PATH:
* [Java 1.6](http://java.oracle.com)
* [Java 7](http://java.oracle.com)
* [Apache maven 3.0.3 or greater](http://maven.apache.org/)
* [Scala](http://www.scala-lang.org)
You also need to add the scala binary to your PATH.
After cloning the project, you need to build it from source with this command:
After cloning the project, you can build it from source with this command:
```
mvn package
```
### To generate a sample client library
You can build a client against Wordnik's [petstore](http://petstore.swagger.wordnik.com) API as follows:
You can build a client against the swagger sample [petstore](http://petstore.swagger.io) API as follows:
```
./bin/scala-petstore.sh
./bin/java-petstore.sh
```
This will run the script in [samples/client/petstore/ScalaPetstoreCodegen.scala](https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) and create the client. You can then
compile and run the client, as well as unit tests against it:
This will run the generator with this command:
```
cd samples/client/petstore/scala
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.0-M1.jar \
-i http://petstore.swagger.io/v2/swagger.json \
-l java \
-o samples/client/petstore/java
```
With a number of options. You can get the options with the -h flag:
```
usage: Codegen
-a,--auth addes authorization headers when fetching the
swagger definitions remotely. Pass in a
URL-encoded string of name:header with a comma
separating multiple values
-d,--debug-info prints additional info for debugging
-h,--help shows this message
-i,--input-spec <arg> location of the swagger spec, as URL or file
-l,--lang <arg> client language to generate.
Available languages include:
[android, java, jaxrs, nodejs, objc, scalatra,
scala, dynamic-html, html, swagger, tizen, php,
python]
-o,--output <arg> where to write the generated files
-t,--template-dir <arg> folder containing the template files
```
You can then compile and run the client, as well as unit tests against it:
```
cd samples/client/petstore/java
mvn package
```
Other languages have petstore samples, too:
```
./bin/flash-petstore.sh
./bin/android-petstore.sh
./bin/java-petstore.sh
./bin/objc-petstore.sh
./bin/php-petstore.sh
./bin/python-petstore.sh
./bin/python3-petstore.sh
./bin/ruby-petstore.sh
```
### Generating libraries from your server
It's just as easy--you can either run the default generators:
```
./bin/runscala.sh com.wordnik.swagger.codegen.BasicScalaGenerator http://petstore.swagger.wordnik.com/api/resources.json special-key
```
Replace `Scala` with `Flash`, `Java`, `Objc`, `PHP`, `Python`, `Python3`, `Ruby`.
You will probably want to override some of the defaults--like packages, etc. For doing this, just create a scala
script with the overrides you want. Follow [ScalaPetstoreCodegen](https://github.com/wordnik/swagger-codegen/blob/master/samples/client/petstore/scala/ScalaPetstoreCodegen.scala) as an example:
For example, create `src/main/scala/MyCodegen.scala` with these contents:
```scala
import com.wordnik.swagger.codegen.BasicScalaGenerator
object MyCodegen extends BasicScalaGenerator {
def main(args: Array[String]) = generateClient(args)
// location of templates
override def templateDir = "scala"
// where to write generated code
override def destinationDir = "client/scala/src/main/scala"
// api invoker package
override def invokerPackage = "com.myapi.client"
// package for models
override def modelPackage = Some("com.myapi.client.model")
// package for api classes
override def apiPackage = Some("com.myapi.client.api")
// supporting classes
override def supportingFiles = List(
("apiInvoker.mustache", destinationDir + java.io.File.separator + packageName.replaceAll("\\.", java.io.File.separator), "ApiInvoker.scala"),
("pom.mustache", destinationDir, "pom.xml")
)
}
```
Now you can generate your client like this:
```
./bin/runscala.sh src/main/scala/MyCodegen.scala http://my.api.com/resources.json super-secret-key
```
w00t! Thanks to the scala interpretor, you didn't even need to recompile.
It's just as easy--just use the `-i` flag to point to either a server or file.
### Modifying the client library format
Don't like the default swagger client syntax? Want a different language supported? No problem! Swagger codegen
processes mustache templates with the [scalate](http://scalate.fusesource.org/) engine. You can modify our templates or
make your own.
Don't like the default swagger client syntax? Want a different language supported? No problem! Swagger codegen processes mustache templates with the [jmustache](https://github.com/samskivert/jmustache) engine. You can modify our templates or make your own.
You can look at `src/main/resources/${your-language}` for examples. To make your own templates, create your own files
and override the `templateDir` in your script to point to the right place. It actually is that easy.
You can look at `modules/swagger-codegen/src/main/resources/${your-language}` for examples. To make your own templates, create your own files and use the `-t` flag to specify your tempalte folder. It actually is that easy.
### Where is Javascript???
See our [javascript library](http://github.com/wordnik/swagger.js)--it's completely dynamic and doesn't require
See our [javascript library](http://github.com/swagger-api/swagger-js)--it's completely dynamic and doesn't require
static code generation.
There is a third-party component called [swagger-js-codegen](https://github.com/wcandillon/swagger-js-codegen) that can generate angularjs or nodejs source code from a swagger specification.
#### Generating a client from flat files (i.e. no remote server calls)
If you don't want to call your server, you can save the swagger spec files into a directory and pass an argument
to the code generator like this:
```
-DfileMap=/path/to/files
-i ./modules/swagger-codegen/src/test/resources/2_0/petstore.json
```
Or for example:
Great for creating libraries on your ci server, from the [Swagger Editor](http://editor.swagger.io)... or while coding on an airplane.
### Customizing the generator
There are different aspects of customizing the code generator beyond just creating or modifying templates. Each language has a supporting configuration file to handle different type mappings, etc:
```
./bin/java-petstore-filemap.sh
$ ls -1 modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/
AndroidClientCodegen.java
JavaClientCodegen.java
JaxRSServerCodegen.java
NodeJSServerCodegen.java
ObjcClientCodegen.java
PhpClientCodegen.java
PythonClientCodegen.java
ScalaClientCodegen.java
ScalatraServerCodegen.java
StaticDocCodegen.java
StaticHtmlGenerator.java
SwaggerGenerator.java
TizenClientCodegen.java
```
Which simple passes `-DfileMap=src/test/resources/petstore` as an argument. Great for creating libraries on your
ci server... or while coding on an airplane.
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc., you may want to extend these.
To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:
```
package com.mycompany.swagger.codegen;
import com.wordnik.swagger.codegen.languages.*;
public class MyObjcCodegen extends ObjcClientCodegen {
static {
PREFIX = "HELO";
}
}
```
and specify the `classname` when running the generator:
```
-i com.mycompany.swagger.codegen.MyObjcCodegen
```
Your subclass will now be loaded and overrides the `PREFIX` value in the superclass.
### Validating your swagger spec
You can use the validation tool to see that your server is creating a proper spec file. If you want to learn
more about the spec file and format, please see [swagger-core](https://github.com/wordnik/swagger-core/wiki). This
tool will read the server and generate a report of any violations of the spec. If there are violations, the
client codegen and ui may not work correctly.
To validate an api and write output to ./swagger-errors.html:
You have options. The easiest is to use our [online validator](https://github.com/swagger-api/validator-badge) which not only will let you validate your spec, but with the debug flag, you can see what's wrong with your spec. For example:
http://online.swagger.io/validator/debug?url=http://petstore.swagger.io/v2/swagger.json
### Generating dynamic html api documentation
To do so, just use the `-l dynamic-html` flag when reading a spec file. This creates HTML documentation that is available as a single-page application with AJAX. To view the documentation:
```
./bin/validate.sh http://petstore.swagger.wordnik.com/api/resources.json "" ./swagger-errors.html
cd samples/dynamic-html/
npm install
node .
```
Which launches a node.js server so the AJAX calls have a place to go.
### Generating static html api documentation
To do so, just use the `-l html` flag when reading a spec file. This creates a single, simple HTML file with embedded css so you can ship it as an email attachment, or load it from your filesystem:
```
cd samples/html/
open index.html
```
### To build a server stub
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:
### node.js
```
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.0-M1.jar \
-i http://petstore.swagger.io/v2/swagger.json \
-l nodejs \
-o samples/server/petstore/nodejs
```
### rails-grape
#### Not yet migrated to this branch
### scala scalatra
```
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.0-M1.jar \
-i http://petstore.swagger.io/v2/swagger.json \
-l scalatra \
-o samples/server/petstore/scalatra
```
### java jax-rs
```
java -jar modules/swagger-codegen-distribution/target/swagger-codegen-distribution-2.1.0-M1.jar \
-i http://petstore.swagger.io/v2/swagger.json \
-l jaxrs \
-o samples/server/petstore/jaxrs
```
### To build the codegen library
@@ -147,24 +224,12 @@ This will create the swagger-codegen library from source.
mvn package
```
Note! The templates are included in the library generated. If you want to modify the templates, you'll need to
either repackage the library OR modify your codegen script to use a file path!
### To build a server stub
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:
* [javascript node.js Server generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/node)
* [ruby sinatra generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/sinatra)
* [scala scalatra generator](https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/scalatra)
Note! The templates are included in the library generated. If you want to modify the templates, you'll need to either repackage the library OR specify a path to your scripts
License
-------
Copyright 2012 Wordnik, Inc.
Copyright 2015 Reverb Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

6
bin/Version.scala Normal file
View File

@@ -0,0 +1,6 @@
val version = scala.util.Properties.scalaPropOrElse("version.number", "unknown").toString match {
case s if s startsWith "2.10" => "2.10"
case s if s startsWith "2.11" => "2.11"
case e: String => e
}
println(version)

31
bin/all-petstore.sh Executable file
View 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
cd $APP_DIR
./bin/android-java-petstore.sh
./bin/dynamic-html.sh
./bin/html.sh
./bin/jaxrs-petstore-server.sh
./bin/java-petstore-filemap.sh
./bin/java-petstore.sh
./bin/php-petstore.sh
./bin/python-petstore.sh
./bin/objc-petstore.sh
./bin/scala-petstore.sh
./bin/tizen-petstore.sh

24
bin/all-wordnik.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/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
cd $APP_DIR
./bin/android-java-wordnik-api.sh
./bin/java-wordnik-api.sh
./bin/objc-wordnik-api.sh
./bin/scala-wordnik-api.sh

36
bin/android-java-petstore.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -o samples/client/petstore/android-java"
java $JAVA_OPTS -jar $executable $ags

36
bin/android-java-wordnik-api.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l android -o samples/client/wordnik/android-java"
java $JAVA_OPTS -jar $executable $ags

36
bin/dynamic-html.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l dynamic-html -o samples/dynamic-html"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +0,0 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/flash/FlashPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key

36
bin/html-petstore.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l html -o samples/html"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +0,0 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key

View File

@@ -1,6 +1,36 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/sh
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/java/JavaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +1,36 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/sh
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/wordnik-api/java/JavaWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json
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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l java -o samples/client/wordnik/java"
java $JAVA_OPTS -jar $executable $ags

36
bin/jaxrs-petstore-server.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs"
java $JAVA_OPTS -jar $executable $ags

36
bin/nodejs-petstore-server.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l nodejs -o samples/server/petstore/nodejs"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +1,36 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/sh
export CLASSPATH="$DIR/../target/*:$DIR/../target/lib/*"
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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/objc/ObjcPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +1,36 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/sh
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/wordnik-api/objc/ObjcWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json
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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l objc -o samples/client/wordnik/objc"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +1,36 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/sh
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/php/PHPPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l php -o samples/client/petstore/php"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +1,36 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/sh
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/python/PythonPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python -o samples/client/petstore/python"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +0,0 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/python3/Python3PetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key

View File

@@ -1,6 +0,0 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/ruby/RubyPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key

View File

@@ -1,7 +0,0 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@"

View File

@@ -1,6 +1,36 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/sh
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/petstore/scala/ScalaPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/api-docs.json special-key
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scala -o samples/client/petstore/scala"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +1,36 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#!/bin/sh
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties -DfileMap=samples/client/wordnik-api/spec-files"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH "$@" samples/client/wordnik-api/scala/ScalaWordnikApiCodegen.scala http://api.wordnik.com/v4/resources.json
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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/wordnik.json -l scala -o samples/client/wordnik/scala"
java $JAVA_OPTS -jar $executable $ags

36
bin/scalatra-petstore-server.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scalatra -o samples/server/petstore/scalatra"
java $JAVA_OPTS -jar $executable $ags

36
bin/tizen-petstore.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/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
root=./modules/swagger-codegen-distribution/pom.xml
# gets version of swagger-codegen
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.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="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l tizen -o samples/client/petstore/tizen"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -1,6 +0,0 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*"
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
JAVA_OPTS=$JAVA_OPTS scala -cp $CLASSPATH com.wordnik.swagger.codegen.spec.Validator "$@"

View File

@@ -0,0 +1,80 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.1.1-M1</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen-distribution</artifactId>
<packaging>jar</packaging>
<name>swagger-codegen (executable)</name>
<version>2.1.1-M1</version>
<build>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<outputDirectory>target/classes</outputDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<defaultGoal>install</defaultGoal>
<directory>target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.wordnik.swagger.codegen.Codegen</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>true</createDependencyReducedPom>
<dependencyReducedPomLocation>
${java.io.tmpdir}/dependency-reduced-pom.xml
</dependencyReducedPomLocation>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,7 @@
package com.wordnik.swagger.codegen;
public class Readme {
public String getInfo() {
return "See the documentation for swagger-codegen";
}
}

View File

@@ -0,0 +1,341 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen-project</artifactId>
<version>2.1.1-M1</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen</artifactId>
<packaging>jar</packaging>
<name>swagger-codegen (core library)</name>
<version>2.1.1-M1</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>install</defaultGoal>
<extensions>
<extension>
<groupId>org.jvnet.wagon-svn</groupId>
<artifactId>wagon-svn</artifactId>
<version>1.8</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>1.0-alpha-6</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-1</version>
</extension>
</extensions>
<directory>target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.wordnik.swagger.codegen.Codegen</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<configuration>
<recompileMode>incremental</recompileMode>
</configuration>
<jvmArgs>
<jvmArg>-Xmx384m</jvmArg>
</jvmArgs>
<args>
<arg>-target:jvm-1.6</arg>
<arg>-deprecation</arg>
</args>
<launchers>
<launcher>
<id>run-scalatest</id>
<mainClass>org.scalatest.tools.Runner</mainClass>
<args>
<arg>-p</arg>
<arg>${project.build.testOutputDirectory}</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx512m</jvmArg>
</jvmArgs>
</launcher>
</launchers>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<mode>development</mode>
<url>${project.url}</url>
<implementation-version>${project.version}</implementation-version>
<package>com.wordnik</package>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<configuration>
<releaseProfiles>release</releaseProfiles>
<goals>sign</goals>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>release-profile</id>
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration />
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>prepare-package</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<outputDirectory>target/site</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<aggregate>true</aggregate>
<debug>true</debug>
<links>
<link>http://java.sun.com/javaee/5/docs/api</link>
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
</links>
<excludePackageNames />
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.6</version>
<reportSets>
<reportSet>
<reports>
<report>project-team</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-compat-spec-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>com.samskivert</groupId>
<artifactId>jmustache</artifactId>
<version>${jmustache-version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io-version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${felix-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang-version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>${commons-cli-version}</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

View File

@@ -0,0 +1,104 @@
/**
* Copyright 2015 Reverb, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.codegen.ClientOpts;
import com.wordnik.swagger.annotations.*;
import com.wordnik.swagger.models.Swagger;
import com.wordnik.swagger.models.auth.AuthorizationValue;
import java.util.*;
import java.net.URLEncoder;
import java.net.URLDecoder;
public class ClientOptInput {
private ClientOpts opts;
private Swagger swagger;
private List<AuthorizationValue> auths;
protected CodegenConfig config;
public ClientOptInput swagger(Swagger swagger) {
this.setSwagger(swagger);
return this;
}
public ClientOptInput opts(ClientOpts opts) {
this.setOpts(opts);
return this;
}
public void setAuth(String urlEncodedAuthString) {
List<AuthorizationValue> auths = new ArrayList<AuthorizationValue>();
if(urlEncodedAuthString != null && !"".equals(urlEncodedAuthString)) {
String[] parts = urlEncodedAuthString.split(",");
for(String part : parts) {
String[] kvPair = part.split(":");
if(kvPair.length == 2) {
auths.add(new AuthorizationValue(URLDecoder.decode(kvPair[0]), URLDecoder.decode(kvPair[1]), "header"));
}
}
}
this.auths = auths;
}
public String getAuth() {
if(auths != null) {
StringBuilder b = new StringBuilder();
for(AuthorizationValue v : auths) {
try {
if(b.toString().length() > 0)
b.append(",");
b.append(URLEncoder.encode(v.getKeyName(), "UTF-8"))
.append(":")
.append(URLEncoder.encode(v.getValue(), "UTF-8"));
}
catch (Exception e) {
// continue
e.printStackTrace();
}
}
return b.toString();
}
else
return null;
}
public List<AuthorizationValue> getAuthorizationValues() {
return auths;
}
public CodegenConfig getConfig() {
return config;
}
public void setConfig(CodegenConfig config) {
this.config = config;
}
public void setOpts(ClientOpts opts) {
this.opts = opts;
}
public ClientOpts getOpts() {
return opts;
}
public void setSwagger(Swagger swagger) {
this.swagger = swagger;
}
@ApiModelProperty(dataType="Object")
public Swagger getSwagger() {
return swagger;
}
}

View File

@@ -0,0 +1,52 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.codegen.auth.*;
import java.util.*;
public class ClientOpts {
protected String uri;
protected String target;
protected AuthMethod auth;
protected Map<String, String> properties = new HashMap<String, String>();
protected String outputDirectory;
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public Map<String, String> getProperties() {
return properties;
}
public void setProperties(Map<String, String> properties) {
this.properties = properties;
}
public String getOutputDirectory() {
return outputDirectory;
}
public void setOutputDirectory(String outputDirectory) {
this.outputDirectory = outputDirectory;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ClientOpts: {\n");
sb.append(" uri: ").append(uri).append(",");
sb.append(" auth: ").append(auth).append(",");
sb.append(properties);
sb.append("}");
return sb.toString();
}
}

View File

@@ -0,0 +1,138 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.codegen.languages.*;
import com.wordnik.swagger.models.Swagger;
import com.wordnik.swagger.models.auth.AuthorizationValue;
import com.wordnik.swagger.util.*;
import io.swagger.parser.SwaggerParser;
import org.apache.commons.cli.*;
import java.io.File;
import java.util.*;
public class Codegen extends DefaultGenerator {
static Map<String, CodegenConfig> configs = new HashMap<String, CodegenConfig>();
static String configString;
static {
List<CodegenConfig> extensions = getExtensions();
StringBuilder sb = new StringBuilder();
for(CodegenConfig config : extensions) {
if(sb.toString().length() != 0)
sb.append(", ");
sb.append(config.getName());
configs.put(config.getName(), config);
configString = sb.toString();
}
}
static String debugInfoOptions = "\nThe following additional debug options are available for all codegen targets:" +
"\n -DdebugSwagger prints the swagger specification as interpreted by the codegen" +
"\n -DdebugModels prints models passed to the template engine" +
"\n -DdebugOperations prints operations passed to the template engine" +
"\n -DdebugSupportingFiles prints additional data passed to the template engine";
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
Options options = new Options();
options.addOption("h", "help", false, "shows this message");
options.addOption("l", "lang", true, "client language to generate.\nAvailable languages include:\n\t[" + configString + "]");
options.addOption("o", "output", true, "where to write the generated files");
options.addOption("i", "input-spec", true, "location of the swagger spec, as URL or file");
options.addOption("t", "template-dir", true, "folder containing the template files");
options.addOption("d", "debug-info", false, "prints additional info for debugging");
options.addOption("a", "auth", false, "addes authorization headers when fetching the swagger definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values");
ClientOptInput clientOptInput = new ClientOptInput();
ClientOpts clientOpts = new ClientOpts();
Swagger swagger = null;
CommandLine cmd = null;
try {
CommandLineParser parser = new BasicParser();
CodegenConfig config = null;
cmd = parser.parse(options, args);
if (cmd.hasOption("d")) {
usage(options);
System.out.println(debugInfoOptions);
return;
}
if (cmd.hasOption("a"))
clientOptInput.setAuth(cmd.getOptionValue("a"));
if (cmd.hasOption("l"))
clientOptInput.setConfig(getConfig(cmd.getOptionValue("l")));
else {
usage(options);
return;
}
if (cmd.hasOption("o"))
clientOptInput.getConfig().setOutputDir(cmd.getOptionValue("o"));
if (cmd.hasOption("h")) {
if(cmd.hasOption("l")) {
config = getConfig(String.valueOf(cmd.getOptionValue("l")));
if(config != null) {
options.addOption("h", "help", true, config.getHelp());
usage(options);
return;
}
}
usage(options);
return;
}
if (cmd.hasOption("i"))
swagger = new SwaggerParser().read(cmd.getOptionValue("i"), clientOptInput.getAuthorizationValues());
if (cmd.hasOption("t"))
clientOpts.getProperties().put("templateDir", String.valueOf(cmd.getOptionValue("t")));
}
catch (Exception e) {
usage(options);
return;
}
try{
clientOptInput
.opts(clientOpts)
.swagger(swagger);
new Codegen().opts(clientOptInput).generate();
}
catch (Exception e) {
e.printStackTrace();
}
}
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());
}
return output;
}
static void usage(Options options) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp( "Codegen", options );
}
public static CodegenConfig getConfig(String name) {
if(configs.containsKey(name)) {
return configs.get(name);
}
else {
// see if it's a class
try {
System.out.println("loading class " + name);
Class customClass = Class.forName(name);
System.out.println("loaded");
return (CodegenConfig)customClass.newInstance();
}
catch (Exception e) {
throw new RuntimeException("can't load class " + name);
}
}
}
}

View File

@@ -0,0 +1,53 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
public interface CodegenConfig {
CodegenType getTag();
String getName();
String getHelp();
Map<String, Object> additionalProperties();
String apiPackage();
String apiFileFolder();
String fileSuffix();
String outputFolder();
String templateDir();
String modelFileFolder();
String modelPackage();
String toApiName(String name);
String toModelName(String name);
String toParamName(String name);
String escapeReservedWord(String name);
String getTypeDeclaration(Property p);
String getTypeDeclaration(String name);
void processOpts();
Set<String> reservedWords();
List<SupportingFile> supportingFiles();
void setOutputDir(String dir);
String getOutputDir();
CodegenModel fromModel(String name, Model model);
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation);
Set<String> defaultIncludes();
Map<String, String> typeMapping();
Map<String, String> instantiationTypes();
Map<String, String> importMapping();
Map<String, String> apiTemplateFiles();
Map<String, String> modelTemplateFiles();
void processSwagger(Swagger swagger);
String toApiFilename(String name);
String toModelFilename(String name);
String toModelImport(String name);
String toApiImport(String name);
void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations);
Map<String, Object> postProcessModels(Map<String, Object> objs);
Map<String, Object> postProcessOperations(Map<String, Object> objs);
Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs);
}

View File

@@ -0,0 +1,16 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
public class CodegenModel {
public String parent;
public String name, classname, description, classVarName, modelJson;
public String defaultValue;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
public Set<String> imports = new HashSet<String>();
public Boolean hasVars, emptyVars, hasMoreModels;
public ExternalDocs externalDocs;
}

View File

@@ -0,0 +1,38 @@
package com.wordnik.swagger.codegen;
import java.util.HashMap;
import java.util.Map;
public final class CodegenModelFactory {
private static final Map<CodegenModelType, Class<?>> typeMapping = new HashMap<CodegenModelType, Class<?>>();
/**
* Configure a different implementation class.
* @param type the type that shall be replaced
* @param implementation the implementation class must extend the default class and must provide a public no-arg constructor
*/
public static void setTypeMapping(CodegenModelType type, Class<?> implementation) {
if (!type.getDefaultImplementation().isAssignableFrom(implementation)) {
throw new IllegalArgumentException(implementation.getSimpleName() + " doesn't extend " + type.getDefaultImplementation().getSimpleName());
}
try {
implementation.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
typeMapping.put(type, implementation);
}
@SuppressWarnings("unchecked")
public static <T> T newInstance(CodegenModelType type) {
Class<?> classType = typeMapping.get(type);
try {
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,20 @@
package com.wordnik.swagger.codegen;
public enum CodegenModelType {
MODEL(CodegenModel.class),
OPERATION(CodegenOperation.class),
PARAMETER(CodegenParameter.class),
PROPERTY(CodegenProperty.class),
RESPONSE(CodegenResponse.class);
private final Class<?> defaultImplementation;
private CodegenModelType(Class<?> defaultImplementation) {
this.defaultImplementation = defaultImplementation;
}
public Class<?> getDefaultImplementation() {
return defaultImplementation;
}
}

View File

@@ -0,0 +1,30 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*;
import java.util.*;
public class CodegenOperation {
public Boolean hasConsumes, hasProduces, hasParams, returnTypeIsPrimitive,
returnSimpleType, subresourceOperation, isMapContainer, isListContainer;
public String path, operationId, returnType, httpMethod, returnBaseType,
returnContainer, summary, notes, baseName, defaultResponse;
public List<Map<String, String>> consumes, produces;
public CodegenParameter bodyParam;
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> pathParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> queryParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> headerParams = new ArrayList<CodegenParameter>();
public List<CodegenParameter> formParams = new ArrayList<CodegenParameter>();
public List<String> tags;
public List<CodegenResponse> responses = new ArrayList<CodegenResponse>();
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();
public Set<String> imports = new HashSet<String>();
public List<Map<String, String>> examples;
public ExternalDocs externalDocs;
// legacy support
public String nickname;
}

View File

@@ -0,0 +1,37 @@
package com.wordnik.swagger.codegen;
public class CodegenParameter {
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam;
public String baseName, paramName, dataType, collectionFormat, description, baseType;
/**
* Determines whether this parameter is mandatory. If the parameter is in "path",
* this property is required and its value MUST be true. Otherwise, the property
* MAY be included and its default value is false.
*/
public Boolean required;
public CodegenParameter copy() {
CodegenParameter output = new CodegenParameter();
output.isFile = this.isFile;
output.notFile = this.notFile;
output.hasMore = this.hasMore;
output.isContainer = this.isContainer;
output.secondaryParam = this.secondaryParam;
output.baseName = this.baseName;
output.paramName = this.paramName;
output.dataType = this.dataType;
output.collectionFormat = this.collectionFormat;
output.description = this.description;
output.baseType = this.baseType;
output.isFormParam = this.isFormParam;
output.isQueryParam = this.isQueryParam;
output.isPathParam = this.isPathParam;
output.isHeaderParam = this.isHeaderParam;
output.isCookieParam = this.isCookieParam;
output.isBodyParam = this.isBodyParam;
output.required = this.required;
return output;
}
}

View File

@@ -0,0 +1,24 @@
package com.wordnik.swagger.codegen;
import java.util.*;
public class CodegenProperty {
public String baseName, complexType, getter, setter, description, datatype, datatypeWithEnum,
name, min, max, defaultValue, baseType, containerType;
/** maxLength validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.1 */
public Integer maxLength;
/** minLength validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.2 */
public Integer minLength;
/** pattern validation for strings, see http://json-schema.org/latest/json-schema-validation.html#rfc.section.5.2.3 */
public String pattern;
/** A free-form property to include an example of an instance for this schema. */
public String example;
public Double minimum, maximum, exclusiveMinimum, exclusiveMaximum;
public Boolean hasMore = null, required = null, secondaryParam = null;
public Boolean isPrimitiveType, isContainer, isNotContainer;
public boolean isEnum;
public List<String> _enum;
public Map<String, Object> allowableValues;
}

View File

@@ -0,0 +1,10 @@
package com.wordnik.swagger.codegen;
import java.util.*;
public class CodegenResponse {
public String code, message;
public Boolean hasMore;
public List<Map<String, String>> examples;
Object schema;
}

View File

@@ -0,0 +1,34 @@
package com.wordnik.swagger.codegen;
import com.fasterxml.jackson.annotation.*;
import java.util.Map;
import java.util.HashMap;
public enum CodegenType {
CLIENT, SERVER, DOCUMENTATION, OTHER;
private static Map<String, CodegenType> names = new HashMap<String, CodegenType>();
static {
names.put("client", CLIENT);
names.put("server", SERVER);
names.put("documentation", DOCUMENTATION);
names.put("other", OTHER);
}
@JsonCreator
public static CodegenType forValue(String value) {
return names.get(value.toLowerCase());
}
@JsonValue
public String toValue() {
for (Map.Entry<String, CodegenType> entry : names.entrySet()) {
if (entry.getValue() == this)
return entry.getKey();
}
return null; // or fail
}
}

View File

@@ -0,0 +1,901 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*;
import com.wordnik.swagger.models.parameters.*;
import com.wordnik.swagger.models.properties.*;
import com.wordnik.swagger.util.Json;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
public class DefaultCodegen {
Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
protected String outputFolder = "";
protected Set<String> defaultIncludes = new HashSet<String>();
protected Map<String, String> typeMapping = new HashMap<String, String>();
protected Map<String, String> instantiationTypes = new HashMap<String, String>();
protected Set<String> reservedWords = new HashSet<String>();
protected Set<String> languageSpecificPrimitives = new HashSet<String>();
protected Map<String, String> importMapping = new HashMap<String, String>();
protected String modelPackage = "", apiPackage = "", fileSuffix;
protected Map<String, String> apiTemplateFiles = new HashMap<String, String>();
protected Map<String, String> modelTemplateFiles = new HashMap<String, String>();
protected String templateDir;
protected Map<String, Object> additionalProperties = new HashMap<String, Object>();
protected List<SupportingFile> supportingFiles = new ArrayList<SupportingFile>();
public void processOpts(){
if(additionalProperties.containsKey("templateDir")) {
this.setTemplateDir((String)additionalProperties.get("templateDir"));
}
}
// override with any special post-processing
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return objs;
}
// override with any special post-processing
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
return objs;
}
// override with any special post-processing
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
return objs;
}
// override with any special handling of the entire swagger spec
public void processSwagger(Swagger swagger) {}
// override with any special text escaping logic
public String escapeText(String input) {
if(input != null) {
String output = input.replaceAll("\n", " ");
output = output.replace("\"", "\\\"");
return output;
}
return input;
}
public Set<String> defaultIncludes() {
return defaultIncludes;
}
public Map<String, String> typeMapping() {
return typeMapping;
}
public Map<String, String> instantiationTypes() {
return instantiationTypes;
}
public Set<String> reservedWords() {
return reservedWords;
}
public Set<String> languageSpecificPrimitives() {
return languageSpecificPrimitives;
}
public Map<String, String> importMapping() {
return importMapping;
}
public String modelPackage() {
return modelPackage;
}
public String apiPackage() {
return apiPackage;
}
public String fileSuffix() {
return fileSuffix;
}
public String templateDir() {
return templateDir;
}
public Map<String, String> apiTemplateFiles() {
return apiTemplateFiles;
}
public Map<String, String> modelTemplateFiles() {
return modelTemplateFiles;
}
public String apiFileFolder() {
return outputFolder + "/" + apiPackage().replaceAll("\\.", "/");
}
public String modelFileFolder() {
return outputFolder + "/" + modelPackage().replaceAll("\\.", "/");
}
public Map<String, Object> additionalProperties() {
return additionalProperties;
}
public List<SupportingFile> supportingFiles() {
return supportingFiles;
}
public String outputFolder() {
return outputFolder;
}
public void setOutputDir(String dir) {
this.outputFolder = dir;
}
public String getOutputDir() {
return outputFolder();
}
public void setTemplateDir(String templateDir) {
this.templateDir = templateDir;
}
public String toApiFilename(String name) {
return initialCaps(name) + "Api";
}
public String toModelFilename(String name) {
return name;
}
public String toVarName(String name) {
if(reservedWords.contains(name))
return escapeReservedWord(name);
else
return name;
}
public String toParamName(String name) {
if(reservedWords.contains(name)) {
return escapeReservedWord(name);
}
return name;
}
public String escapeReservedWord(String name) {
throw new RuntimeException("reserved word " + name + " not allowed");
}
public String toModelImport(String name) {
if("".equals(modelPackage()))
return name;
else
return modelPackage() + "." + name;
}
public String toApiImport(String name) {
return apiPackage() + "." + name;
}
public DefaultCodegen() {
defaultIncludes = new HashSet<String>(
Arrays.asList("double",
"int",
"long",
"short",
"char",
"float",
"String",
"boolean",
"Boolean",
"Double",
"Void",
"Integer",
"Long",
"Float")
);
typeMapping = new HashMap<String, String>();
typeMapping.put("array", "List");
typeMapping.put("map", "Map");
typeMapping.put("List", "List");
typeMapping.put("boolean", "Boolean");
typeMapping.put("string", "String");
typeMapping.put("int", "Integer");
typeMapping.put("float", "Float");
typeMapping.put("number", "BigDecimal");
typeMapping.put("DateTime", "Date");
typeMapping.put("long", "Long");
typeMapping.put("short", "Short");
typeMapping.put("char", "String");
typeMapping.put("double", "Double");
typeMapping.put("object", "Object");
typeMapping.put("integer", "Integer");
instantiationTypes = new HashMap<String, String>();
reservedWords = new HashSet<String>();
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");
importMapping.put("Map", "java.util.Map");
importMapping.put("HashMap", "java.util.HashMap");
importMapping.put("Array", "java.util.List");
importMapping.put("ArrayList", "java.util.ArrayList");
importMapping.put("List", "java.util.*");
importMapping.put("Set", "java.util.*");
importMapping.put("DateTime", "org.joda.time.*");
importMapping.put("LocalDateTime", "org.joda.time.*");
importMapping.put("LocalDate", "org.joda.time.*");
importMapping.put("LocalTime", "org.joda.time.*");
}
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;
}
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 ArrayList<" + inner + ">() ";
}
else
return "null";
}
/**
* returns the swagger type for the property
**/
public String getSwaggerType(Property p) {
String datatype = null;
if(p instanceof StringProperty)
datatype = "string";
else if (p instanceof BooleanProperty)
datatype = "boolean";
else if(p instanceof DateProperty)
datatype = "date";
else if(p instanceof DateTimeProperty)
datatype = "DateTime";
else if (p instanceof DoubleProperty)
datatype = "double";
else if (p instanceof FloatProperty)
datatype = "float";
else if (p instanceof IntegerProperty)
datatype = "integer";
else if (p instanceof LongProperty)
datatype = "long";
else if (p instanceof MapProperty)
datatype = "map";
else if (p instanceof DecimalProperty)
datatype = "number";
else if (p instanceof RefProperty) {
RefProperty r = (RefProperty)p;
datatype = r.get$ref();
if(datatype.indexOf("#/definitions/") == 0)
datatype = datatype.substring("#/definitions/".length());
}
else {
if(p != null) datatype = p.getType();
}
return datatype;
}
public String initialCaps(String name) {
return Character.toUpperCase(name.charAt(0)) + name.substring(1);
}
public String getTypeDeclaration(String name) {
return name;
}
public String getTypeDeclaration(Property p) {
String swaggerType = getSwaggerType(p);
if(typeMapping.containsKey(swaggerType))
return typeMapping.get(swaggerType);
return swaggerType;
}
public String toApiName(String name) {
if(name.length() == 0)
return "DefaultApi";
return initialCaps(name) + "Api";
}
public String toModelName(String name) {
return initialCaps(name);
}
public CodegenModel fromModel(String name, Model model) {
CodegenModel m = CodegenModelFactory.newInstance(CodegenModelType.MODEL);
if(reservedWords.contains(name))
m.name = escapeReservedWord(name);
else
m.name = name;
m.description = model.getDescription();
m.classname = toModelName(name);
m.classVarName = toVarName(name);
m.modelJson = Json.pretty(model);
m.externalDocs = model.getExternalDocs();
int count = 0;
if(model instanceof ArrayModel) {
ArrayModel am = (ArrayModel) model;
ArrayProperty arrayProperty = new ArrayProperty(am.getItems());
CodegenProperty cp = fromProperty(name, arrayProperty);
if(cp.complexType != null && !defaultIncludes.contains(cp.complexType))
m.imports.add(cp.complexType);
m.parent = toInstantiationType(arrayProperty);
String containerType = cp.containerType;
if(instantiationTypes.containsKey(containerType))
m.imports.add(instantiationTypes.get(containerType));
if(typeMapping.containsKey(containerType)) {
containerType = typeMapping.get(containerType);
cp.containerType = containerType;
m.imports.add(containerType);
}
}
else if (model instanceof RefModel) {
// TODO
}
else {
ModelImpl impl = (ModelImpl) model;
if(impl.getAdditionalProperties() != null) {
MapProperty mapProperty = new MapProperty(impl.getAdditionalProperties());
CodegenProperty cp = fromProperty(name, mapProperty);
if(cp.complexType != null && !defaultIncludes.contains(cp.complexType))
m.imports.add(cp.complexType);
m.parent = toInstantiationType(mapProperty);
String containerType = cp.containerType;
if(instantiationTypes.containsKey(containerType))
m.imports.add(instantiationTypes.get(containerType));
if(typeMapping.containsKey(containerType)) {
containerType = typeMapping.get(containerType);
cp.containerType = containerType;
m.imports.add(containerType);
}
}
if(impl.getProperties() != null && impl.getProperties().size() > 0) {
m.hasVars = true;
for(String key: impl.getProperties().keySet()) {
Property prop = impl.getProperties().get(key);
if(prop == null) {
LOGGER.warn("null property for " + key);
}
else {
CodegenProperty cp = fromProperty(key, prop);
cp.required = false;
if(impl.getRequired() != null) {
for(String req : impl.getRequired()) {
if(key.equals(req))
cp.required = true;
}
}
if(cp.complexType != null && !defaultIncludes.contains(cp.complexType)) {
m.imports.add(cp.complexType);
}
m.vars.add(cp);
count += 1;
if(count != impl.getProperties().keySet().size())
cp.hasMore = new Boolean(true);
if(cp.isContainer != null) {
String arrayImport = typeMapping.get("array");
if(arrayImport != null &&
!languageSpecificPrimitives.contains(arrayImport) &&
!defaultIncludes.contains(arrayImport))
m.imports.add(arrayImport);
}
if(cp.complexType != null &&
!languageSpecificPrimitives.contains(cp.complexType) &&
!defaultIncludes.contains(cp.complexType))
m.imports.add(cp.complexType);
if(cp.baseType != null &&
!languageSpecificPrimitives.contains(cp.baseType) &&
!defaultIncludes.contains(cp.baseType))
m.imports.add(cp.baseType);
}
}
}
else {
m.emptyVars = true;
}
}
return m;
}
public CodegenProperty fromProperty(String name, Property p) {
if(p == null) {
LOGGER.error("unexpected missing property for name " + null);
return null;
}
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
property.name = toVarName(name);
property.baseName = name;
property.description = escapeText(p.getDescription());
property.getter = "get" + initialCaps(name);
property.setter = "set" + initialCaps(name);
property.example = p.getExample();
property.defaultValue = toDefaultValue(p);
String type = getSwaggerType(p);
if(p instanceof AbstractNumericProperty) {
AbstractNumericProperty np = (AbstractNumericProperty) p;
property.minimum = np.getMinimum();
property.maximum = np.getMaximum();
property.exclusiveMinimum = np.getExclusiveMinimum();
property.exclusiveMaximum = np.getExclusiveMaximum();
// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
if(np.getMinimum() != null)
allowableValues.put("min", np.getMinimum());
if(np.getMaximum() != null)
allowableValues.put("max", np.getMaximum());
property.allowableValues = allowableValues;
}
if(p instanceof StringProperty) {
StringProperty sp = (StringProperty) p;
property.maxLength = sp.getMaxLength();
property.minLength = sp.getMinLength();
property.pattern = sp.getPattern();
if(sp.getEnum() != null) {
List<String> _enum = sp.getEnum();
property._enum = _enum;
property.isEnum = true;
// legacy support
Map<String, Object> allowableValues = new HashMap<String, Object>();
allowableValues.put("values", _enum);
property.allowableValues = allowableValues;
}
}
property.datatype = getTypeDeclaration(p);
// this can cause issues for clients which don't support enums
if(property.isEnum)
property.datatypeWithEnum = StringUtils.capitalize(property.name) + "Enum";
else
property.datatypeWithEnum = property.datatype;
property.baseType = getSwaggerType(p);
if(p instanceof ArrayProperty) {
property.isContainer = true;
property.containerType = "array";
ArrayProperty ap = (ArrayProperty) p;
CodegenProperty cp = fromProperty("inner", ap.getItems());
if(cp == null) {
LOGGER.warn("skipping invalid property " + Json.pretty(p));
}
else {
property.baseType = getSwaggerType(p);
if(!languageSpecificPrimitives.contains(cp.baseType))
property.complexType = cp.baseType;
else
property.isPrimitiveType = true;
}
}
else if(p instanceof MapProperty) {
property.isContainer = true;
property.containerType = "map";
MapProperty ap = (MapProperty) p;
CodegenProperty cp = fromProperty("inner", ap.getAdditionalProperties());
property.baseType = getSwaggerType(p);
if(!languageSpecificPrimitives.contains(cp.baseType))
property.complexType = cp.baseType;
else
property.isPrimitiveType = true;
}
else {
property.isNotContainer = true;
if(languageSpecificPrimitives().contains(type))
property.isPrimitiveType = true;
else
property.complexType = property.baseType;
}
return property;
}
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation){
CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION);
Set<String> imports = new HashSet<String>();
String operationId = operation.getOperationId();
if(operationId == null) {
String tmpPath = path;
tmpPath = tmpPath.replaceAll("\\{", "");
tmpPath = tmpPath.replaceAll("\\}", "");
String[] parts = (tmpPath + "/" + httpMethod).split("/");
StringBuilder builder = new StringBuilder();
if("/".equals(tmpPath)) {
// must be root tmpPath
builder.append("root");
}
for(int i = 0; i < parts.length; i++) {
String part = parts[i];
if(part.length() > 0) {
if(builder.toString().length() == 0)
part = Character.toLowerCase(part.charAt(0)) + part.substring(1);
else
part = initialCaps(part);
builder.append(part);
}
}
operationId = builder.toString();
LOGGER.warn("generated operationId " + operationId);
}
op.path = path;
op.operationId = operationId;
op.summary = escapeText(operation.getSummary());
op.notes = escapeText(operation.getDescription());
op.tags = operation.getTags();
Response methodResponse = null;
if(operation.getConsumes() != null && operation.getConsumes().size() > 0) {
List<Map<String, String>> c = new ArrayList<Map<String, String>>();
int count = 0;
for(String key: operation.getConsumes()) {
Map<String, String> mediaType = new HashMap<String, String>();
mediaType.put("mediaType", key);
count += 1;
if (count < operation.getConsumes().size())
mediaType.put("hasMore", "true");
c.add(mediaType);
}
op.consumes = c;
op.hasConsumes = true;
}
if(operation.getProduces() != null && operation.getProduces().size() > 0) {
List<Map<String, String>> c = new ArrayList<Map<String, String>>();
int count = 0;
for(String key: operation.getProduces()) {
Map<String, String> mediaType = new HashMap<String, String>();
mediaType.put("mediaType", key);
count += 1;
if (count < operation.getProduces().size())
mediaType.put("hasMore", "true");
c.add(mediaType);
}
op.produces = c;
op.hasProduces = true;
}
if(operation.getResponses() != null) {
for(String responseCode: new TreeSet<String>(operation.getResponses().keySet())) {
Response response = operation.getResponses().get(responseCode);
if (responseCode.startsWith("2")) {
// use the first, i.e. the smallest 2xx response status as methodResponse
methodResponse = response;
break;
}
}
if(methodResponse == null && operation.getResponses().keySet().contains("default")) {
methodResponse = operation.getResponses().get("default");
}
for(String responseCode: operation.getResponses().keySet()) {
Response response = operation.getResponses().get(responseCode);
if(response != methodResponse) {
CodegenResponse r = fromResponse(responseCode, response);
op.responses.add(r);
}
for(int i = 0; i < op.responses.size() - 1; i++) {
CodegenResponse r = op.responses.get(i);
r.hasMore = new Boolean(true);
}
}
}
if(methodResponse != null) {
if (methodResponse.getSchema() != null) {
CodegenProperty cm = fromProperty("response", methodResponse.getSchema());
Property responseProperty = methodResponse.getSchema();
if(responseProperty instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) responseProperty;
CodegenProperty innerProperty = fromProperty("response", ap.getItems());
op.returnBaseType = innerProperty.baseType;
}
else {
if(cm.complexType != null)
op.returnBaseType = cm.complexType;
else
op.returnBaseType = cm.baseType;
}
op.examples = toExamples(methodResponse.getExamples());
op.defaultResponse = toDefaultValue(responseProperty);
op.returnType = cm.datatype;
if(cm.isContainer != null) {
op.returnContainer = cm.containerType;
if("map".equals(cm.containerType))
op.isMapContainer = Boolean.TRUE;
else if ("list".equalsIgnoreCase(cm.containerType))
op.isListContainer = Boolean.TRUE;
}
else
op.returnSimpleType = true;
if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null)
op.returnTypeIsPrimitive = true;
}
addHeaders(methodResponse, op.responseHeaders);
}
if(op.returnBaseType == null) {
op.returnTypeIsPrimitive = true;
op.returnSimpleType = true;
}
if(op.returnBaseType != null &&
!defaultIncludes.contains(op.returnBaseType) &&
!languageSpecificPrimitives.contains(op.returnBaseType))
imports.add(op.returnBaseType);
List<Parameter> parameters = operation.getParameters();
CodegenParameter bodyParam = null;
List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>();
List<CodegenParameter> pathParams = new ArrayList<CodegenParameter>();
List<CodegenParameter> queryParams = new ArrayList<CodegenParameter>();
List<CodegenParameter> headerParams = new ArrayList<CodegenParameter>();
List<CodegenParameter> cookieParams = new ArrayList<CodegenParameter>();
List<CodegenParameter> formParams = new ArrayList<CodegenParameter>();
if(parameters != null) {
for(Parameter param : parameters) {
CodegenParameter p = fromParameter(param, imports);
allParams.add(p);
if(param instanceof QueryParameter) {
p.isQueryParam = new Boolean(true);
queryParams.add(p.copy());
}
else if(param instanceof PathParameter) {
p.required = true;
p.isPathParam = new Boolean(true);
pathParams.add(p.copy());
}
else if(param instanceof HeaderParameter) {
p.isHeaderParam = new Boolean(true);
headerParams.add(p.copy());
}
else if(param instanceof CookieParameter) {
p.isCookieParam = new Boolean(true);
cookieParams.add(p.copy());
}
else if(param instanceof BodyParameter) {
p.isBodyParam = new Boolean(true);
bodyParam = p;
bodyParams.add(p.copy());
}
else if(param instanceof FormParameter) {
if("file".equalsIgnoreCase(((FormParameter)param).getType()))
p.isFile = true;
else
p.notFile = true;
p.isFormParam = new Boolean(true);
formParams.add(p.copy());
}
}
}
for(String i: imports) {
if(!defaultIncludes.contains(i) && !languageSpecificPrimitives.contains(i)){
op.imports.add(i);
}
}
op.bodyParam = bodyParam;
op.httpMethod = httpMethod.toUpperCase();
op.allParams = addHasMore(allParams);
op.bodyParams = addHasMore(bodyParams);
op.pathParams = addHasMore(pathParams);
op.queryParams = addHasMore(queryParams);
op.headerParams = addHasMore(headerParams);
// op.cookieParams = cookieParams;
op.formParams = addHasMore(formParams);
// legacy support
op.nickname = operationId;
if(op.allParams.size() > 0)
op.hasParams = true;
op.externalDocs = operation.getExternalDocs();
return op;
}
public CodegenResponse fromResponse(String responseCode, Response response) {
CodegenResponse r = CodegenModelFactory.newInstance(CodegenModelType.RESPONSE);
if("default".equals(responseCode))
r.code = "0";
else
r.code = responseCode;
r.message = response.getDescription();
r.schema = response.getSchema();
r.examples = toExamples(response.getExamples());
return r;
}
public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
CodegenParameter p = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
p.baseName = param.getName();
p.description = param.getDescription();
p.required = param.getRequired();
if(param instanceof SerializableParameter) {
SerializableParameter qp = (SerializableParameter) param;
Property property = null;
String collectionFormat = null;
if("array".equals(qp.getType())) {
Property inner = qp.getItems();
if(inner == null) {
LOGGER.warn("warning! No inner type supplied for array parameter \"" + qp.getName() + "\", using String");
inner = new StringProperty().description("//TODO automatically added by swagger-codegen");
}
property = new ArrayProperty(inner);
collectionFormat = qp.getCollectionFormat();
CodegenProperty pr = fromProperty("inner", inner);
p.baseType = pr.datatype;
imports.add(pr.baseType);
}
else
property = PropertyBuilder.build(qp.getType(), qp.getFormat(), null);
if(property == null) {
LOGGER.warn("warning! Property type \"" + qp.getType() + "\" not found for parameter \"" + param.getName() + "\", using String");
property = new StringProperty().description("//TODO automatically added by swagger-codegen. Type was " + qp.getType() + " but not supported");
}
CodegenProperty model = fromProperty(qp.getName(), property);
p.collectionFormat = collectionFormat;
p.dataType = model.datatype;
p.paramName = toParamName(qp.getName());
if(model.complexType != null) {
imports.add(model.complexType);
}
}
else {
BodyParameter bp = (BodyParameter) param;
Model model = bp.getSchema();
if(model instanceof ModelImpl) {
ModelImpl impl = (ModelImpl) model;
CodegenModel cm = fromModel(bp.getName(), impl);
if(cm.emptyVars != null && cm.emptyVars == false) {
p.dataType = getTypeDeclaration(cm.classname);
imports.add(p.dataType);
}
else {
// TODO: missing format, so this will not always work
Property prop = PropertyBuilder.build(impl.getType(), null, null);
CodegenProperty cp = fromProperty("property", prop);
if(cp != null) {
p.dataType = cp.datatype;
}
}
}
else if(model instanceof ArrayModel) {
// to use the built-in model parsing, we unwrap the ArrayModel
// and get a single property from it
ArrayModel impl = (ArrayModel) model;
CodegenModel cm = fromModel(bp.getName(), impl);
// get the single property
ArrayProperty ap = new ArrayProperty().items(impl.getItems());
CodegenProperty cp = fromProperty("inner", ap);
if(cp.complexType != null) {
imports.add(cp.complexType);
}
imports.add(cp.baseType);
p.dataType = cp.datatype;
p.isContainer = true;
}
else{
Model sub = bp.getSchema();
if(sub instanceof RefModel) {
String name = ((RefModel)sub).getSimpleRef();
if(typeMapping.containsKey(name))
name = typeMapping.get(name);
else {
name = toModelName(name);
if(defaultIncludes.contains(name)) {
imports.add(name);
}
imports.add(name);
name = getTypeDeclaration(name);
}
p.dataType = name;
}
}
p.paramName = toParamName(bp.getName());
}
return p;
}
protected List<Map<String, String>> toExamples(Map<String, String> examples) {
if(examples == null)
return null;
List<Map<String, String>> output = new ArrayList<Map<String, String>>();
for(String key: examples.keySet()) {
String value = examples.get(key);
Map<String, String> kv = new HashMap<String, String>();
kv.put("contentType", key);
kv.put("example", value);
output.add(kv);
}
return output;
}
private void addHeaders(Response response, List<CodegenProperty> target) {
if (response.getHeaders() != null) {
for (Map.Entry<String, Property> headers : response.getHeaders().entrySet()) {
target.add(fromProperty(headers.getKey(), headers.getValue()));
}
}
}
private List<CodegenParameter> addHasMore(List<CodegenParameter> objs) {
if(objs != null) {
for(int i = 0; i < objs.size(); i++) {
if(i > 0)
objs.get(i).secondaryParam = new Boolean(true);
if(i < objs.size() - 1)
objs.get(i).hasMore = new Boolean(true);
}
}
return objs;
}
private Map<String, Object> addHasMore(Map<String, Object> objs) {
if(objs != null) {
for(int i = 0; i < objs.size() - 1; i++) {
if(i > 0)
objs.put("secondaryParam", new Boolean(true));
if(i < objs.size() - 1)
objs.put("hasMore", true);
}
}
return objs;
}
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
List<CodegenOperation> opList = operations.get(tag);
if(opList == null) {
opList = new ArrayList<CodegenOperation>();
operations.put(tag, opList);
}
opList.add(co);
co.baseName = tag;
}
}

View File

@@ -0,0 +1,381 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.*;
import com.wordnik.swagger.util.*;
import com.samskivert.mustache.*;
import org.apache.commons.io.FileUtils;
import java.util.*;
import java.util.regex.*;
import java.io.*;
public class DefaultGenerator implements Generator {
protected CodegenConfig config;
protected ClientOptInput opts = null;
protected Swagger swagger = null;
public Generator opts(ClientOptInput opts) {
this.opts = opts;
this.swagger = opts.getSwagger();
ClientOpts clientOpts = opts.getOpts();
this.config = opts.getConfig();
this.config.additionalProperties().putAll(clientOpts.getProperties());
return this;
}
public List<File> generate() {
if(swagger == null || config == null) {
throw new RuntimeException("missing swagger input or config!");
}
if(System.getProperty("debugSwagger") != null) {
Json.prettyPrint(swagger);
}
List<File> files = new ArrayList<File>();
try {
config.processOpts();
if(swagger.getInfo() != null) {
Info info = swagger.getInfo();
if(info.getTitle() != null)
config.additionalProperties().put("appName", info.getTitle());
if(info.getDescription() != null)
config.additionalProperties().put("appDescription", info.getDescription());
if(info.getContact() != null) {
Contact contact = info.getContact();
config.additionalProperties().put("infoUrl", contact.getUrl());
if(contact.getEmail() != null)
config.additionalProperties().put("infoEmail", contact.getEmail());
}
if(info.getLicense() != null) {
License license = info.getLicense();
if(license.getName() != null)
config.additionalProperties().put("licenseInfo", license.getName());
if(license.getUrl() != null)
config.additionalProperties().put("licenseUrl", license.getUrl());
}
}
StringBuilder hostBuilder = new StringBuilder();
if(swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
hostBuilder.append(swagger.getSchemes().get(0).toValue());
hostBuilder.append("://");
}
else
hostBuilder.append("https://");
hostBuilder.append(swagger.getHost()).append(swagger.getBasePath());
String basePath = hostBuilder.toString();
List<Object> allOperations = new ArrayList<Object>();
List<Object> allModels = new ArrayList<Object>();
// models
Map<String, Model> definitions = swagger.getDefinitions();
if(definitions != null) {
for(String name: definitions.keySet()) {
Model model = definitions.get(name);
Map<String, Model> modelMap = new HashMap<String, Model>();
modelMap.put(name, model);
Map<String, Object> models = processModels(config, modelMap);
models.putAll(config.additionalProperties());
allModels.add(((List<Object>)models.get("models")).get(0));
for(String templateName : config.modelTemplateFiles().keySet()) {
String suffix = config.modelTemplateFiles().get(templateName);
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix;
String template = readTemplate(config.templateDir() + File.separator + templateName);
Template tmpl = Mustache.compiler()
.withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate (String name) {
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
};
})
.defaultValue("")
.compile(template);
writeToFile(filename, tmpl.execute(models));
files.add(new File(filename));
}
}
}
if(System.getProperty("debugModels") != null) {
System.out.println("############ Model info ############");
Json.prettyPrint(allModels);
}
// apis
Map<String, List<CodegenOperation>> paths = processPaths(swagger.getPaths());
for(String tag : paths.keySet()) {
List<CodegenOperation> ops = paths.get(tag);
Map<String, Object> operation = processOperations(config, tag, ops);
operation.put("basePath", basePath);
operation.put("baseName", tag);
operation.put("modelPackage", config.modelPackage());
operation.putAll(config.additionalProperties());
operation.put("classname", config.toApiName(tag));
allOperations.add(operation);
for(String templateName : config.apiTemplateFiles().keySet()) {
String suffix = config.apiTemplateFiles().get(templateName);
String filename = config.apiFileFolder() +
File.separator +
config.toApiFilename(tag) +
suffix;
String template = readTemplate(config.templateDir() + File.separator + templateName);
Template tmpl = Mustache.compiler()
.withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate (String name) {
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
};
})
.defaultValue("")
.compile(template);
writeToFile(filename, tmpl.execute(operation));
files.add(new File(filename));
}
}
if(System.getProperty("debugOperations") != null) {
System.out.println("############ Operation info ############");
Json.prettyPrint(allOperations);
}
// supporting files
Map<String, Object> bundle = new HashMap<String, Object>();
bundle.putAll(config.additionalProperties());
bundle.put("apiPackage", config.apiPackage());
Map<String, Object> apis = new HashMap<String, Object>();
apis.put("apis", allOperations);
if(swagger.getBasePath() != null) {
bundle.put("basePath", swagger.getBasePath());
}
bundle.put("apiInfo", apis);
bundle.put("models", allModels);
bundle.put("apiFolder", config.apiPackage().replaceAll("\\.", "/"));
bundle.put("modelPackage", config.modelPackage());
if (swagger.getExternalDocs() != null) {
bundle.put("externalDocs", swagger.getExternalDocs());
}
for(int i = 0; i < allModels.size() - 1; i++) {
HashMap<String, CodegenModel> cm = (HashMap<String, CodegenModel>) allModels.get(i);
CodegenModel m = cm.get("model");
m.hasMoreModels = true;
}
config.postProcessSupportingFileData(bundle);
if(System.getProperty("debugSupportingFiles") != null) {
System.out.println("############ Supporting file info ############");
Json.prettyPrint(bundle);
}
for(SupportingFile support : config.supportingFiles()) {
String outputFolder = config.outputFolder();
if(support.folder != null && !"".equals(support.folder))
outputFolder += File.separator + support.folder;
File of = new File(outputFolder);
if(!of.isDirectory())
of.mkdirs();
String outputFilename = outputFolder + File.separator + support.destinationFilename;
if(support.templateFile.endsWith("mustache")) {
String template = readTemplate(config.templateDir() + File.separator + support.templateFile);
Template tmpl = Mustache.compiler()
.withLoader(new Mustache.TemplateLoader() {
public Reader getTemplate (String name) {
return getTemplateReader(config.templateDir() + File.separator + name + ".mustache");
};
})
.defaultValue("")
.compile(template);
writeToFile(outputFilename, tmpl.execute(bundle));
files.add(new File(outputFilename));
}
else {
String template = readTemplate(config.templateDir() + File.separator + support.templateFile);
FileUtils.writeStringToFile(new File(outputFilename), template);
System.out.println("copying file to " + outputFilename);
files.add(new File(outputFilename));
}
}
config.processSwagger(swagger);
}
catch (Exception e) {
e.printStackTrace();
}
return files;
}
public Map<String, List<CodegenOperation>> processPaths(Map<String, Path> paths) {
Map<String, List<CodegenOperation>> ops = new HashMap<String, List<CodegenOperation>>();
List<String> tags = null;
for(String resourcePath : paths.keySet()) {
Path path = paths.get(resourcePath);
processOperation(resourcePath, "get", path.getGet(), ops);
processOperation(resourcePath, "put", path.getPut(), ops);
processOperation(resourcePath, "post", path.getPost(), ops);
processOperation(resourcePath, "delete", path.getDelete(), ops);
processOperation(resourcePath, "patch", path.getPatch(), ops);
processOperation(resourcePath, "options", path.getOptions(), ops);
}
return ops;
}
public void processOperation(String resourcePath, String httpMethod, Operation operation, Map<String, List<CodegenOperation>> operations) {
if(operation != null) {
List<String> tags = operation.getTags();
if(tags == null) {
tags = new ArrayList<String>();
tags.add("default");
}
for(String tag : tags) {
CodegenOperation co = config.fromOperation(resourcePath, httpMethod, operation);
co.tags = new ArrayList<String>();
co.tags.add(sanitizeTag(tag));
config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations);
}
}
}
protected String sanitizeTag(String tag) {
// remove spaces and make strong case
String [] parts = tag.split(" ");
StringBuffer buf = new StringBuffer();
for(String part: parts) {
if(!"".equals(part)) {
buf.append(Character.toUpperCase(part.charAt(0)));
if(part.length() > 1)
buf.append(part.substring(1));
}
}
return buf.toString().replaceAll("[^a-zA-Z ]", "");
}
public File writeToFile(String filename, String contents) throws IOException {
System.out.println("writing file " + filename);
File output = new File(filename);
if(output.getParent() != null && !new File(output.getParent()).exists()) {
File parent = new File(output.getParent());
parent.mkdirs();
}
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(output), "UTF-8"));
out.write(contents);
out.close();
return output;
}
public String readTemplate(String name) {
try{
Reader reader = getTemplateReader(name);
if(reader == null)
throw new RuntimeException("no file found");
java.util.Scanner s = new java.util.Scanner(reader).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
catch(Exception e) {
e.printStackTrace();
}
throw new RuntimeException("can't load template " + name);
}
public Reader getTemplateReader(String name) {
try{
InputStream is = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(name));
if(is == null)
is = new FileInputStream(new File(name));
if(is == null)
throw new RuntimeException("no file found");
return new InputStreamReader(is);
}
catch(Exception e) {
e.printStackTrace();
}
throw new RuntimeException("can't load template " + name);
}
private String getCPResourcePath(String name) {
if (!"/".equals(File.separator))
return name.replaceAll(Pattern.quote(File.separator), "/");
return name;
}
public Map<String, Object> processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops) {
Map<String, Object> operations = new HashMap<String, Object>();
Map<String, Object> objs = new HashMap<String, Object>();
objs.put("classname", config.toApiName(tag));
objs.put("operation", ops);
operations.put("operations", objs);
operations.put("package", config.apiPackage());
Set<String> allImports = new LinkedHashSet<String>();
for(CodegenOperation op: ops) {
allImports.addAll(op.imports);
}
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
for(String i: allImports) {
Map<String, String> im = new LinkedHashMap<String, String>();
String m = config.importMapping().get(i);
if(m == null)
m = config.toModelImport(i);
if(m != null) {
im.put("import", m);
imports.add(im);
}
}
operations.put("imports", imports);
config.postProcessOperations(operations);
return operations;
}
public Map<String, Object> processModels(CodegenConfig config, Map<String, Model> definitions) {
Map<String, Object> objs = new HashMap<String, Object>();
objs.put("package", config.modelPackage());
List<Object> models = new ArrayList<Object>();
List<Object> model = new ArrayList<Object>();
Set<String> allImports = new LinkedHashSet<String>();
for(String key: definitions.keySet()) {
Model mm = definitions.get(key);
CodegenModel cm = config.fromModel(key, mm);
Map<String, Object> mo = new HashMap<String, Object>();
mo.put("model", cm);
models.add(mo);
allImports.addAll(cm.imports);
}
objs.put("models", models);
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
for(String i: allImports) {
Map<String, String> im = new LinkedHashMap<String, String>();
String m = config.importMapping().get(i);
if(m == null)
m = config.toModelImport(i);
if(m != null && !config.defaultIncludes().contains(m)) {
im.put("import", m);
imports.add(im);
}
// add instantiation types
m = config.instantiationTypes().get(i);
if(m != null && !config.defaultIncludes().contains(m)) {
im.put("import", m);
imports.add(im);
}
}
objs.put("imports", imports);
config.postProcessModels(objs);
return objs;
}
}

View File

@@ -0,0 +1,11 @@
package com.wordnik.swagger.codegen;
import com.wordnik.swagger.models.Swagger;
import java.io.File;
import java.util.List;
public interface Generator {
Generator opts(ClientOptInput opts);
List<File> generate();
}

View File

@@ -0,0 +1,13 @@
package com.wordnik.swagger.codegen;
public class SupportingFile {
public String templateFile;
public String folder;
public String destinationFilename;
public SupportingFile(String templateFile, String folder, String destinationFilename) {
this.templateFile = templateFile;
this.folder = folder;
this.destinationFilename = destinationFilename;
}
}

View File

@@ -0,0 +1,6 @@
package com.wordnik.swagger.codegen.auth;
public interface AuthMethod {
String getType();
void setType(String type);
}

View File

@@ -0,0 +1,86 @@
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option dontlognull
option httpclose
option httplog
option forwardfor
option redispatch
timeout connect 10000 # default 10 second time out if a backend is not found
timeout client 300000
timeout server 300000
maxconn 60000
retries 3
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main *:80
default_backend app
acl is_swagger_online hdr_beg(host) -i online.swagger.io
acl is_swagger_io hdr_beg(host) -i swagger.io
acl is_old hdr_beg(host) -i swagger.wordnik.com
acl is_old_editor hdr_beg(host) -i editor.swagger.wordnik.com
acl is_validator_swagger path_beg /swagger.json
# online spec validator
reqrep ([^\ ]*)\ /validator/(.*) \1\ /validator/validator/\2 if is_swagger_online
# something that didn't work
reqrep ([^\ ]*)\ /swagger.json(.*) \1\ /validator/swagger.json if is_validator_swagger
# swagger schema
reqrep ^([^\ :]*)\ /v2/schema.json(.*) \1\ /swagger-api/swagger-spec/master/schemas/v2.0/schema.json\2
acl is_swagger_spec path_beg /swagger-api/swagger-spec
# swagger docs
reqrep ^([^\ :]*)\ /swagger-core/documentation/annotations/apidocs/current(.*) \1\ /swagger-core/apidocs/\2
acl is_swagger_docs path_beg /swagger-core/apidocs
use_backend github_swagger_io if is_swagger_docs
use_backend validator if is_swagger_online
use_backend validator if is_validator_swagger
use_backend github_swagger_io if is_swagger_io !is_swagger_spec
use_backend github_swagger_spec if is_swagger_spec
redirect location http://editor.swagger.io if is_old_editor
redirect location http://swagger.io if is_old
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend github_swagger_io
balance roundrobin
server gh1 swagger-api.github.io:80 check
backend github_swagger_spec
http-request set-header Host raw.githubusercontent.com
rspirep ^Content-type:(.*) Content-Type:\ application/json
rspirep ^Access-Control-Allow-Origin:(.*) Access-Control-Allow-Origin:*
balance roundrobin
server gh2 raw.githubusercontent.com:443 check ssl verify none
backend validator
balance roundrobin
server app1 127.0.0.1:8000 check
backend app
balance roundrobin
server app1 127.0.0.1:8000 check

View File

@@ -0,0 +1,110 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class AndroidClientCodegen 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";
protected String sourceFolder = "src/main/java";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "android";
}
public String getHelp() {
return "Generates an Android client library.";
}
public AndroidClientCodegen() {
super();
outputFolder = "generated-code/android";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
templateDir = "android-java";
apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java"));
supportingFiles.add(new SupportingFile("httpPatch.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "HttpPatch.java"));
supportingFiles.add(new SupportingFile("jsonUtil.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java"));
supportingFiles.add(new SupportingFile("apiException.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"Object")
);
instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
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);
}
}

View File

@@ -0,0 +1,119 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class JavaClientCodegen 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";
protected String sourceFolder = "src/main/java";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "java";
}
public String getHelp() {
return "Generates a Java client library.";
}
public JavaClientCodegen() {
super();
outputFolder = "generated-code/java";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
templateDir = "Java";
apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "continue", "for", "new", "switch", "assert",
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
"native", "super", "while")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.java"));
supportingFiles.add(new SupportingFile("JsonUtil.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "JsonUtil.java"));
supportingFiles.add(new SupportingFile("apiException.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.java"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"Object")
);
instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
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);
}
}

View File

@@ -0,0 +1,149 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.models.Operation;
import com.wordnik.swagger.models.Path;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.api";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-server";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/java";
protected String title = "Swagger Server";
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "jaxrs";
}
public String getHelp() {
return "Generates a Java JAXRS Server application.";
}
public JaxRSServerCodegen() {
super();
outputFolder = "generated-code/javaJaxRS";
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
templateDir = "JavaJaxRS";
apiPackage = "io.swagger.api";
modelPackage = "io.swagger.model";
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
additionalProperties.put("title", title);
supportingFiles.clear();
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("ApiException.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiException.java"));
supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiOriginFilter.java"));
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiResponseMessage.java"));
supportingFiles.add(new SupportingFile("NotFoundException.mustache",
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
supportingFiles.add(new SupportingFile("web.mustache",
("src/main/webapp/WEB-INF"), "web.xml"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float")
);
}
@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 getTypeDeclaration(inner);
}
return super.getTypeDeclaration(p);
}
@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
String basePath = resourcePath;
if(basePath.startsWith("/"))
basePath = basePath.substring(1);
int pos = basePath.indexOf("/");
if(pos > 0)
basePath = basePath.substring(0, pos);
if(basePath == "")
basePath = "default";
else {
if(co.path.startsWith("/" + basePath))
co.path = co.path.substring(("/" + basePath).length());
co.subresourceOperation = !co.path.isEmpty();
}
List<CodegenOperation> opList = operations.get(basePath);
if(opList == null) {
opList = new ArrayList<CodegenOperation>();
operations.put(basePath, opList);
}
opList.add(co);
co.baseName = basePath;
}
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>)objs.get("operations");
if(operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for(CodegenOperation operation : ops) {
if(operation.returnType == null)
operation.returnType = "Void";
else if(operation.returnType.startsWith("List")) {
String rt = operation.returnType;
int end = rt.lastIndexOf(">");
if(end > 0) {
operation.returnType = rt.substring("List<".length(), end);
operation.returnContainer = "List";
}
}
else if(operation.returnType.startsWith("Map")) {
String rt = operation.returnType;
int end = rt.lastIndexOf(">");
if(end > 0) {
operation.returnType = rt.substring("Map<".length(), end);
operation.returnContainer = "Map";
}
}
else if(operation.returnType.startsWith("Set")) {
String rt = operation.returnType;
int end = rt.lastIndexOf(">");
if(end > 0) {
operation.returnType = rt.substring("Set<".length(), end);
operation.returnContainer = "Set";
}
}
}
}
return objs;
}
}

View File

@@ -0,0 +1,110 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.Model;
import com.wordnik.swagger.models.properties.*;
import com.wordnik.swagger.util.Json;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.*;
import java.util.*;
import java.io.File;
public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "nodejs";
}
public String getHelp() {
return "Generates a node.js server application compatible with the 1.2 swagger specification.";
}
public NodeJSServerCodegen() {
super();
outputFolder = "generated-code/nodejs";
apiTemplateFiles.put("api.mustache", ".js");
templateDir = "nodejs";
apiPackage = "app.apis";
modelPackage = "app";
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("models.mustache", modelPackage, "models.js"));
supportingFiles.add(new SupportingFile("main.mustache", "", "main.js"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float")
);
typeMapping.put("array", "array");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
List<Map<String, Object>> o = (List<Map<String, Object>>)objs.get("models");
for(Map<String, Object> modelMap : o) {
try {
CodegenModel m = (CodegenModel) modelMap.get("model");
ObjectNode on = (ObjectNode) Json.mapper().readTree(m.modelJson);
// inject the id field
on.put("id", m.name);
// remove the definitions qualifier with this nasty hack
m.modelJson = Json.pretty(on).replaceAll("\"#/definitions/", "\"");
}
catch (Exception e) {
e.printStackTrace();
// skip conversion
}
}
return objs;
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + apiPackage().replaceAll("\\.", File.separator);
}
public String modelFileFolder() {
return outputFolder + File.separator + modelPackage().replaceAll("\\.", File.separator);
}
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if(typeMapping.containsKey(swaggerType)) {
return typeMapping.get(swaggerType);
}
else
type = swaggerType;
return toModelName(type);
}
}

View File

@@ -0,0 +1,221 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
protected Set<String> foundationClasses = new HashSet<String>();
protected String sourceFolder = "client";
protected static String PREFIX = "SWG";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "objc";
}
public String getHelp() {
return "Generates an Objective-C client library.";
}
public ObjcClientCodegen() {
super();
outputFolder = "generated-code/objc";
modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-body.mustache", ".m");
apiTemplateFiles.put("api-header.mustache", ".h");
apiTemplateFiles.put("api-body.mustache", ".m");
templateDir = "objc";
modelPackage = "";
additionalProperties.put("projectName", "swaggerClient");
defaultIncludes = new HashSet<String>(
Arrays.asList(
"bool",
"int",
"NSString",
"NSObject",
"NSArray",
"NSNumber",
"NSDictionary",
"NSMutableArray",
"NSMutableDictionary")
);
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"NSNumber",
"NSString",
"NSObject",
"bool")
);
reservedWords = new HashSet<String>(
Arrays.asList(
"void", "char", "short", "int", "void", "char", "short", "int",
"long", "float", "double", "signed", "unsigned", "id", "const",
"volatile", "in", "out", "inout", "bycopy", "byref", "oneway",
"self", "super", "description"
));
typeMapping = new HashMap<String, String>();
typeMapping.put("enum", "NSString");
typeMapping.put("Date", "SWGDate");
typeMapping.put("DateTime", "SWGDate");
// typeMapping.put("Date", "SWGDate");
typeMapping.put("boolean", "NSNumber");
typeMapping.put("string", "NSString");
typeMapping.put("integer", "NSNumber");
typeMapping.put("int", "NSNumber");
typeMapping.put("float", "NSNumber");
typeMapping.put("long", "NSNumber");
typeMapping.put("double", "NSNumber");
typeMapping.put("array", "NSArray");
typeMapping.put("map", "NSDictionary");
typeMapping.put("number", "NSNumber");
typeMapping.put("List", "NSArray");
typeMapping.put("object", "NSObject");
importMapping = new HashMap<String, String> ();
importMapping.put("Date", "SWGDate");
foundationClasses = new HashSet<String> (
Arrays.asList(
"NSNumber",
"NSObject",
"NSString",
"NSDictionary")
);
instantiationTypes.put("array", "NSMutableArray");
instantiationTypes.put("map", "NSMutableDictionary");
supportingFiles.add(new SupportingFile("SWGObject.h", sourceFolder, "SWGObject.h"));
supportingFiles.add(new SupportingFile("SWGObject.m", sourceFolder, "SWGObject.m"));
supportingFiles.add(new SupportingFile("SWGApiClient.h", sourceFolder, "SWGApiClient.h"));
supportingFiles.add(new SupportingFile("SWGApiClient.m", sourceFolder, "SWGApiClient.m"));
supportingFiles.add(new SupportingFile("SWGFile.h", sourceFolder, "SWGFile.h"));
supportingFiles.add(new SupportingFile("SWGFile.m", sourceFolder, "SWGFile.m"));
supportingFiles.add(new SupportingFile("SWGDate.h", sourceFolder, "SWGDate.h"));
supportingFiles.add(new SupportingFile("SWGDate.m", sourceFolder, "SWGDate.m"));
supportingFiles.add(new SupportingFile("Podfile.mustache", "", "Podfile"));
}
@Override
public String toInstantiationType(Property p) {
if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return instantiationTypes.get("map");
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return instantiationTypes.get("array");
}
else
return null;
}
@Override
public String getTypeDeclaration(String name) {
if(languageSpecificPrimitives.contains(name) && !foundationClasses.contains(name))
return name;
else
return 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) && !foundationClasses.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
@Override
public String getTypeDeclaration(Property p) {
String swaggerType = getSwaggerType(p);
if(languageSpecificPrimitives.contains(swaggerType) && !foundationClasses.contains(swaggerType))
return toModelName(swaggerType);
else
return swaggerType + "*";
}
@Override
public String toModelName(String type) {
if(typeMapping.keySet().contains(type) ||
foundationClasses.contains(type) ||
importMapping.values().contains(type) ||
defaultIncludes.contains(type) ||
languageSpecificPrimitives.contains(type)) {
return Character.toUpperCase(type.charAt(0)) + type.substring(1);
}
else {
return PREFIX + Character.toUpperCase(type.charAt(0)) + type.substring(1);
}
}
@Override
public String toModelImport(String name) {
if("".equals(modelPackage()))
return name;
else
return modelPackage() + "." + name;
}
@Override
public String toDefaultValue(Property p) {
return null;
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder;
}
@Override
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder;
}
@Override
public String toModelFilename(String name) {
return PREFIX + initialCaps(name);
}
@Override
public String toApiName(String name) {
return PREFIX + initialCaps(name) + "Api";
}
public String toApiFilename(String name) {
return PREFIX + initialCaps(name) + "Api";
}
@Override
public String toVarName(String name) {
String paramName = name.replaceAll("[^a-zA-Z0-9_]","");
if(paramName.startsWith("new") || reservedWords.contains(paramName)) {
return escapeReservedWord(paramName);
}
else
return paramName;
}
public String escapeReservedWord(String name) {
return "_" + name;
}
}

View File

@@ -0,0 +1,114 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "php";
}
public String getHelp() {
return "Generates a PHP client library.";
}
public PhpClientCodegen() {
super();
modelPackage = "models";
outputFolder = "generated-code/php";
modelTemplateFiles.put("model.mustache", ".php");
apiTemplateFiles.put("api.mustache", ".php");
templateDir = "php";
typeMapping.clear();
languageSpecificPrimitives.clear();
reservedWords = new HashSet<String> (
Arrays.asList(
"int")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
languageSpecificPrimitives.add("int");
languageSpecificPrimitives.add("array");
languageSpecificPrimitives.add("map");
languageSpecificPrimitives.add("string");
languageSpecificPrimitives.add("DateTime");
typeMapping.put("long", "int");
typeMapping.put("integer", "int");
typeMapping.put("Array", "array");
typeMapping.put("String", "string");
typeMapping.put("List", "array");
typeMapping.put("map", "map");
supportingFiles.add(new SupportingFile("Swagger.mustache", "", "Swagger.php"));
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
public String modelFileFolder() {
return outputFolder + "/" + 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 type;
}
}
else
type = swaggerType;
if(type == null)
return null;
return type;
}
public String toDefaultValue(Property p) {
return "null";
}
}

View File

@@ -0,0 +1,109 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.io.File;
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
String module = "client";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "python";
}
public String getHelp() {
return "Generates a Python client library.";
}
public PythonClientCodegen() {
super();
outputFolder = "generated-code/python";
modelTemplateFiles.put("model.mustache", ".py");
apiTemplateFiles.put("api.mustache", ".py");
templateDir = "python";
apiPackage = module;
modelPackage = module + ".models";
languageSpecificPrimitives.clear();
languageSpecificPrimitives.add("int");
languageSpecificPrimitives.add("float");
languageSpecificPrimitives.add("long");
languageSpecificPrimitives.add("list");
languageSpecificPrimitives.add("bool");
languageSpecificPrimitives.add("str");
languageSpecificPrimitives.add("datetime");
typeMapping.clear();
typeMapping.put("integer", "int");
typeMapping.put("float", "float");
typeMapping.put("long", "long");
typeMapping.put("double", "float");
typeMapping.put("array", "list");
typeMapping.put("map", "map");
typeMapping.put("boolean", "bool");
typeMapping.put("string", "str");
typeMapping.put("date", "datetime");
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("swagger.mustache", module, "swagger.py"));
supportingFiles.add(new SupportingFile("__init__.mustache", module, "__init__.py"));
supportingFiles.add(new SupportingFile("__init__.mustache", modelPackage.replace('.', File.separatorChar), "__init__.py"));
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + apiPackage().replaceAll("\\.", "/");
}
public String modelFileFolder() {
return outputFolder + "/" + modelPackage().replaceAll("\\.", "/");
}
@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 type;
}
}
else
type = swaggerType;
return type;
}
public String toDefaultValue(Property p) {
// TODO: Support Python def value
return "null";
}
}

View File

@@ -0,0 +1,192 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/java";
protected String authScheme = "";
protected boolean authPreemptive = false;
protected boolean asyncHttpClient = !authScheme.isEmpty();
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "scala";
}
public String getHelp() {
return "Generates a Scala client library.";
}
public ScalaClientCodegen() {
super();
outputFolder = "generated-code/scala";
modelTemplateFiles.put("model.mustache", ".scala");
apiTemplateFiles.put("api.mustache", ".scala");
templateDir = "scala";
apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "case", "catch", "class", "def", "do", "else", "extends",
"false", "final", "finally", "for", "forSome", "if", "implicit",
"import", "lazy", "match", "new", "null", "object", "override", "package",
"private", "protected", "return", "sealed", "super", "this", "throw",
"trait", "try", "true", "type", "val", "var", "while", "with", "yield")
);
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
additionalProperties.put("asyncHttpClient", asyncHttpClient);
additionalProperties.put("authScheme", authScheme);
additionalProperties.put("authPreemptive", authPreemptive);
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.scala"));
importMapping.remove("List");
importMapping.remove("Set");
importMapping.remove("Map");
importMapping.put("DateTime", "org.joda.time.DateTime");
importMapping.put("ListBuffer", "scala.collections.mutable.ListBuffer");
typeMapping = new HashMap<String, String>();
typeMapping.put("enum", "NSString");
typeMapping.put("array", "List");
typeMapping.put("set", "Set");
typeMapping.put("boolean", "Boolean");
typeMapping.put("string", "String");
typeMapping.put("int", "Int");
typeMapping.put("long", "Long");
typeMapping.put("float", "Float");
typeMapping.put("byte", "Byte");
typeMapping.put("short", "Short");
typeMapping.put("char", "Char");
typeMapping.put("long", "Long");
typeMapping.put("double", "Double");
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");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
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;
}
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";
}
}

View File

@@ -0,0 +1,178 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import com.wordnik.swagger.util.Json;
import java.util.*;
import java.io.File;
public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/scala";
public CodegenType getTag() {
return CodegenType.SERVER;
}
public String getName() {
return "scalatra";
}
public String getHelp() {
return "Generates a Scala server application with Scalatra.";
}
public ScalatraServerCodegen() {
super();
outputFolder = "generated-code/scalatra";
modelTemplateFiles.put("model.mustache", ".scala");
apiTemplateFiles.put("api.mustache", ".scala");
templateDir = "scalatra";
apiPackage = "com.wordnik.client.api";
modelPackage = "com.wordnik.client.model";
reservedWords = new HashSet<String> (
Arrays.asList(
"abstract", "continue", "for", "new", "switch", "assert",
"default", "if", "package", "synchronized", "boolean", "do", "goto", "private",
"this", "break", "double", "implements", "protected", "throw", "byte", "else",
"import", "public", "throws", "case", "enum", "instanceof", "return", "transient",
"catch", "extends", "int", "short", "try", "char", "final", "interface", "static",
"void", "class", "finally", "long", "strictfp", "volatile", "const", "float",
"native", "super", "while")
);
defaultIncludes = new HashSet<String>(
Arrays.asList("double",
"Int",
"Long",
"Float",
"Double",
"char",
"float",
"String",
"boolean",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"List",
"Set",
"Map")
);
typeMapping.put("integer", "Int");
typeMapping.put("long", "Long");
additionalProperties.put("appName", "Swagger Sample");
additionalProperties.put("appName", "Swagger Sample");
additionalProperties.put("appDescription", "A sample swagger server");
additionalProperties.put("infoUrl", "http://developers.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("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.sbt", "", "build.sbt"));
supportingFiles.add(new SupportingFile("web.xml", "/src/main/webapp/WEB-INF", "web.xml"));
supportingFiles.add(new SupportingFile("JettyMain.scala", sourceFolder, "JettyMain.scala"));
supportingFiles.add(new SupportingFile("Bootstrap.mustache", sourceFolder, "ScalatraBootstrap.scala"));
supportingFiles.add(new SupportingFile("ServletApp.mustache", sourceFolder, "ServletApp.scala"));
supportingFiles.add(new SupportingFile("project/build.properties", "project", "build.properties"));
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");
importMapping = new HashMap<String, String> ();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");
importMapping.put("Map", "java.util.Map");
importMapping.put("HashMap", "java.util.HashMap");
importMapping.put("Array", "java.util.List");
importMapping.put("ArrayList", "java.util.ArrayList");
importMapping.put("DateTime", "org.joda.time.DateTime");
importMapping.put("LocalDateTime", "org.joda.time.LocalDateTime");
importMapping.put("LocalDate", "org.joda.time.LocalDate");
importMapping.put("LocalTime", "org.joda.time.LocalTime");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
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) {
op.httpMethod = op.httpMethod.toLowerCase();
}
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);
}
}

View File

@@ -0,0 +1,76 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "docs";
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
public String getName() {
return "dynamic-html";
}
public String getHelp() {
return "Generates a dynamic HTML site.";
}
public StaticDocCodegen() {
super();
outputFolder = "docs";
modelTemplateFiles.put("model.mustache", ".html");
apiTemplateFiles.put("operation.mustache", ".html");
templateDir = "swagger-static";
additionalProperties.put("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("main.mustache", "", "main.js"));
supportingFiles.add(new SupportingFile("assets/css/bootstrap-responsive.css",
outputFolder + "/assets/css", "bootstrap-responsive.css"));
supportingFiles.add(new SupportingFile("assets/css/bootstrap.css",
outputFolder + "/assets/css", "bootstrap.css"));
supportingFiles.add(new SupportingFile("assets/css/style.css",
outputFolder + "/assets/css", "style.css"));
supportingFiles.add(new SupportingFile("assets/images/logo.png",
outputFolder + "/assets/images", "logo.png"));
supportingFiles.add(new SupportingFile("assets/js/bootstrap.js",
outputFolder + "/assets/js", "bootstrap.js"));
supportingFiles.add(new SupportingFile("assets/js/jquery-1.8.3.min.js",
outputFolder + "/assets/js", "jquery-1.8.3.min.js"));
supportingFiles.add(new SupportingFile("assets/js/main.js",
outputFolder + "/assets/js", "main.js"));
supportingFiles.add(new SupportingFile("index.mustache",
outputFolder, "index.html"));
instantiationTypes.put("array", "ArrayList");
instantiationTypes.put("map", "HashMap");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + "operations";
}
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + "models";
}
}

View File

@@ -0,0 +1,85 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import com.wordnik.swagger.util.Json;
import java.util.*;
import java.io.File;
public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "com.wordnik.client";
protected String groupId = "com.wordnik";
protected String artifactId = "swagger-client";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/scala";
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
public String getName() {
return "html";
}
public String getHelp() {
return "Generates a static HTML file.";
}
public StaticHtmlGenerator() {
super();
outputFolder = "docs";
templateDir = "htmlDocs";
defaultIncludes = new HashSet<String>();
String partner = "our Partner";
if(System.getProperty("partner") != null)
partner = System.getProperty("partner");
additionalProperties.put("partner", partner);
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("invokerPackage", invokerPackage);
additionalProperties.put("groupId", groupId);
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("index.mustache", "", "index.html"));
reservedWords = new HashSet<String>();
languageSpecificPrimitives = new HashSet<String>();
importMapping = new HashMap<String, String> ();
}
@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;
}
}

View File

@@ -0,0 +1,42 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.util.*;
import com.wordnik.swagger.models.Swagger;
import org.apache.commons.io.FileUtils;
import java.io.File;
public class SwaggerGenerator extends DefaultCodegen implements CodegenConfig {
public CodegenType getTag() {
return CodegenType.DOCUMENTATION;
}
public String getName() {
return "swagger";
}
public String getHelp() {
return "Creates a static swagger.json file.";
}
public SwaggerGenerator() {
super();
outputFolder = "generated-code/swagger";
}
@Override
public void processSwagger(Swagger swagger) {
String swaggerString = Json.pretty(swagger);
try{
String outputFile = outputFolder + File.separator + "swagger.json";
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
System.out.println("wrote file to " + outputFile);
}
catch(Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,247 @@
package com.wordnik.swagger.codegen.languages;
import com.wordnik.swagger.util.Json;
import com.wordnik.swagger.codegen.*;
import com.wordnik.swagger.models.properties.*;
import java.util.*;
import java.io.File;
public class TizenClientCodegen extends DefaultCodegen implements CodegenConfig {
protected Set<String> foundationClasses = new HashSet<String>();
protected String sourceFolder = "client";
protected static String PREFIX = "Sami";
protected Map<String, String> namespaces = new HashMap<String, String>();
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "tizen";
}
public String getHelp() {
return "Generates a Samsung Tizen C++ client library.";
}
public TizenClientCodegen() {
super();
outputFolder = "generated-code/tizen";
modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-body.mustache", ".cpp");
apiTemplateFiles.put("api-header.mustache", ".h");
apiTemplateFiles.put("api-body.mustache", ".cpp");
templateDir = "tizen";
modelPackage = "";
defaultIncludes = new HashSet<String>(
Arrays.asList(
"bool",
"int",
"long")
);
languageSpecificPrimitives = new HashSet<String>();
additionalProperties().put("prefix", PREFIX);
reservedWords = new HashSet<String>(
// VERIFY
Arrays.asList(
"void", "char", "short", "int", "void", "char", "short", "int",
"long", "float", "double", "signed", "unsigned", "id", "const",
"volatile", "in", "out", "inout", "bycopy", "byref", "oneway",
"self", "super"
));
super.typeMapping = new HashMap<String, String>();
typeMapping.put("Date", "DateTime");
typeMapping.put("DateTime", "DateTime");
typeMapping.put("string", "String");
typeMapping.put("integer", "Integer");
typeMapping.put("float", "Float");
typeMapping.put("long", "Long");
typeMapping.put("boolean", "Boolean");
typeMapping.put("double", "Double");
typeMapping.put("array", "IList");
typeMapping.put("map", "HashMap");
typeMapping.put("number", "Long");
typeMapping.put("object", PREFIX + "Object");
importMapping = new HashMap<String, String>();
namespaces = new HashMap<String, String> ();
namespaces.put("DateTime", "Tizen::Base::DateTime");
namespaces.put("Integer", "Tizen::Base::Integer");
namespaces.put("Long", "Tizen::Base::Long");
namespaces.put("Boolean", "Tizen::Base::Boolean");
namespaces.put("Float", "Tizen::Base::Float");
namespaces.put("String", "Tizen::Base::String");
namespaces.put("Double", "Tizen::Base::Double");
namespaces.put("IList", "Tizen::Base::Collection::IList");
namespaces.put("HashMap", "Tizen::Base::Collection::HashMap");
namespaces.put("ArrayList", "Tizen::Base::Collection::ArrayList");
namespaces.put("JsonNumber", "Tizen::Web::Json");
namespaces.put("JsonString", "Tizen::Web::Json");
foundationClasses = new HashSet<String> (
Arrays.asList(
"String",
"Integer",
"Float")
);
supportingFiles.clear();
supportingFiles.add(new SupportingFile("modelFactory.mustache", sourceFolder, PREFIX + "ModelFactory.h"));
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, PREFIX + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, PREFIX + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("apiclient-header.mustache", sourceFolder, PREFIX + "ApiClient.h"));
supportingFiles.add(new SupportingFile("apiclient-body.mustache", sourceFolder, PREFIX + "ApiClient.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
supportingFiles.add(new SupportingFile("error-header.mustache", sourceFolder, PREFIX + "Error.h"));
supportingFiles.add(new SupportingFile("error-body.mustache", sourceFolder, PREFIX + "Error.cpp"));
}
@Override
public String toInstantiationType(Property p) {
if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return instantiationTypes.get("map");
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return instantiationTypes.get("array");
}
else
return null;
}
@Override
public String getTypeDeclaration(String name) {
if(languageSpecificPrimitives.contains(name) && !foundationClasses.contains(name))
return name;
else
return 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) && !foundationClasses.contains(type))
return toModelName(type);
}
else
type = swaggerType;
return toModelName(type);
}
@Override
public String getTypeDeclaration(Property p) {
String swaggerType = getSwaggerType(p);
if(languageSpecificPrimitives.contains(swaggerType) && !foundationClasses.contains(swaggerType))
return toModelName(swaggerType);
else
return swaggerType + "*";
}
@Override
public String toModelName(String type) {
if(typeMapping.keySet().contains(type) ||
typeMapping.values().contains(type) ||
foundationClasses.contains(type) ||
importMapping.values().contains(type) ||
defaultIncludes.contains(type) ||
languageSpecificPrimitives.contains(type)) {
return type;
}
else {
return PREFIX + Character.toUpperCase(type.charAt(0)) + type.substring(1);
}
}
@Override
public String toModelImport(String name) {
if(namespaces.containsKey(name)) {
return "using " + namespaces.get(name) + ";";
}
return "#include \"" + name + ".h\"";
}
@Override
public String toDefaultValue(Property p) {
if(p instanceof StringProperty)
return "new String()";
else if (p instanceof BooleanProperty)
return "new Boolean(false)";
else if(p instanceof DateProperty)
return "new DateTime()";
else if(p instanceof DateTimeProperty)
return "new DateTime()";
else if (p instanceof DoubleProperty)
return "new Double()";
else if (p instanceof FloatProperty)
return "new Float()";
else if (p instanceof IntegerProperty)
return "new Integer()";
else if (p instanceof LongProperty)
return "new Long()";
else if (p instanceof DecimalProperty)
return "new Long()";
else if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return "new HashMap()";
}
else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
return "new ArrayList()";
}
// else
if(p instanceof RefProperty) {
RefProperty rp = (RefProperty) p;
return "new " + toModelName(rp.getSimpleRef()) + "()";
}
return "null";
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder;
}
@Override
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder;
}
@Override
public String toModelFilename(String name) {
return PREFIX + initialCaps(name);
}
@Override
public String toApiName(String name) {
return PREFIX + initialCaps(name) + "Api";
}
public String toApiFilename(String name) {
return PREFIX + initialCaps(name) + "Api";
}
@Override
public String toVarName(String name) {
String paramName = name.replaceAll("[^a-zA-Z0-9_]","");
paramName = Character.toUpperCase(paramName.charAt(0)) + paramName.substring(1);
return "p" + paramName;
}
public String escapeReservedWord(String name) {
return "_" + name;
}
}

View File

@@ -0,0 +1,50 @@
package {{invokerPackage}};
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import static groovyx.net.http.ContentType.JSON
import static java.net.URI.create;
class ApiUtils {
def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) {
def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath)
println "url=$url uriPath=$uriPath"
def http = new HTTPBuilder(url)
http.request( Method.valueOf(method), JSON ) {
uri.path = uriPath
uri.query = queryParams
response.success = { resp, json ->
if (type != null) {
onSuccess(parse(json, container, type))
}
}
response.failure = { resp ->
onFailure(resp.status, resp.statusLine.reasonPhrase)
}
}
}
def buildUrlAndUriPath(basePath, versionPath, resourcePath) {
// HTTPBuilder expects to get as its constructor parameter an URL,
// without any other additions like path, therefore we need to cut the path
// from the basePath as it is represented by swagger APIs
// we use java.net.URI to manipulate the basePath
// then the uriPath will hold the rest of the path
URI baseUri = create(basePath)
def pathOnly = baseUri.getPath()
[basePath-pathOnly, pathOnly+versionPath+resourcePath]
}
def parse(object, container, clazz) {
if (container == "List") {
return object.collect {parse(it, "", clazz)}
} else {
return clazz.newInstance(object)
}
}
}

View File

@@ -0,0 +1,56 @@
package {{package}};
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
import {{invokerPackage}}.ApiUtils
//-------------
{{#imports}}import {{import}}
{{/imports}}
import java.util.*;
@Mixin(ApiUtils)
{{#operations}}
class {{classname}} {
String basePath = "{{basePath}}"
String versionPath = "/api/v1"
{{#operation}}
def {{nickname}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) {
// create path and map variables
String resourcePath = "{{path}}"
// query params
def queryParams = [:]
def headerParams = [:]
{{#requiredParamCount}}
// verify required params are set
if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
throw new RuntimeException("missing required params")
}
{{/requiredParamCount}}
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
queryParams.put("{{paramName}}", String.valueOf({{paramName}}))
{{/queryParams}}
{{#headerParams}}headerParams.put("{{paramName}}", {{paramName}})
{{/headerParams}}
invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams,
"{{httpMethod}}", "{{returnContainer}}",
{{#returnBaseType}}{{{returnBaseType}}}.class {{/returnBaseType}}{{^returnBaseType}}null {{/returnBaseType}})
}
{{/operation}}
}
{{/operations}}

View File

@@ -0,0 +1,32 @@
apply plugin: 'groovy'
apply plugin: 'idea'
def artifactory = 'buildserver.supportspace.com'
group = 'com.supportspace'
archivesBaseName = 'swagger-gen-groovy'
version = '0.1'
buildscript {
repositories {
maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' }
}
dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16')
}
}
repositories {
mavenCentral()
mavenLocal()
mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone'])
maven { url "http://$artifactory:8080/artifactory/repo" }
}
dependencies {
groovy "org.codehaus.groovy:groovy-all:2.0.5"
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.6'
}
task wrapper(type: Wrapper) { gradleVersion = '1.6' }

View File

@@ -0,0 +1,21 @@
package {{package}};
import groovy.transform.Canonical
{{#imports}}import {{import}};
{{/imports}}
{{#models}}
{{#model}}
@Canonical
class {{classname}} {
{{#vars}}
{{#description}}/* {{{description}}} */
{{/description}}
{{{datatype}}} {{name}} = {{{defaultValue}}}
{{/vars}}
}
{{/model}}
{{/models}}

View File

@@ -0,0 +1,23 @@
package {{invokerPackage}};
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.datatype.joda.*;
public class JsonUtil {
public static ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.registerModule(new JodaModule());
}
public static ObjectMapper getJsonMapper() {
return mapper;
}
}

View File

@@ -0,0 +1,109 @@
package {{package}};
import {{invokerPackage}}.ApiException;
import {{invokerPackage}}.ApiInvoker;
import {{modelPackage}}.*;
import java.util.*;
{{#imports}}import {{import}};
{{/imports}}
import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.util.Map;
import java.util.HashMap;
{{#operations}}
public class {{classname}} {
String basePath = "{{basePath}}";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public ApiInvoker getInvoker() {
return apiInvoker;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
{{#operation}}
{{#errorList}} //error info- code: {{code}} reason: "{{reason}}" model: {{#responseModel}}{{responseModel}}
{{/responseModel}}{{^responseModel}}<none>
{{/responseModel}}
{{/errorList}}
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
{{#requiredParamCount}}
// verify required params are set
if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
throw new ApiException(400, "missing required params");
}
{{/requiredParamCount}}
// create path and map variables
String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}
.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}};
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
queryParams.put("{{baseName}}", String.valueOf({{paramName}}));
{{/queryParams}}
{{#headerParams}}headerParams.put("{{baseName}}", {{paramName}});
{{/headerParams}}
String[] contentTypes = {
{{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
{{#formParams}}{{#notFile}}
hasFields = true;
mp.field("{{baseName}}", {{paramName}}, MediaType.MULTIPART_FORM_DATA_TYPE);
{{/notFile}}{{#isFile}}
hasFields = true;
mp.field("{{baseName}}", {{paramName}}, MediaType.MULTIPART_FORM_DATA_TYPE);
{{/isFile}}{{/formParams}}
if(hasFields)
postBody = mp;
}
else {
{{#formParams}}{{#notFile}}formParams.put("{{baseName}}", {{paramName}});{{/notFile}}
{{/formParams}}
}
try {
String response = apiInvoker.invokeAPI(basePath, path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, contentType);
if(response != null){
return {{#returnType}}({{{returnType}}}) ApiInvoker.deserialize(response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}};
}
else {
return {{#returnType}}null{{/returnType}};
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return {{#returnType}} null{{/returnType}};
}
else {
throw ex;
}
}
}
{{/operation}}
}
{{/operations}}

View File

@@ -1,7 +1,5 @@
package {{invokerPackage}};
import com.wordnik.swagger.core.util.JsonUtil;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.annotation.*;
@@ -13,43 +11,59 @@ import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.api.client.WebResource.Builder;
import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.MediaType;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.io.IOException;
import java.net.URLEncoder;
import java.io.UnsupportedEncodingException;
public class ApiInvoker {
private static ApiInvoker INSTANCE = new ApiInvoker();
private Map<String, Client> hostMap = new HashMap<String, Client>();
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private boolean isDebug = false;
public void enableDebug() {
isDebug = true;
}
public static ApiInvoker getInstance() {
return INSTANCE;
}
public void addDefaultHeader(String key, String value) {
defaultHeaderMap.put(key, value);
}
public String escapeString(String str) {
return str;
try{
return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
}
catch(UnsupportedEncodingException e) {
return str;
}
}
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
if(null != containerType) {
containerType = containerType.toLowerCase();
}
try{
if("List".equals(containerType)) {
if("list".equals(containerType) || "array".equals(containerType)) {
JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls);
List response = (List<?>) JsonUtil.getJsonMapper().readValue(json, typeInfo);
return response;
}
else if(String.class.equals(cls)) {
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1) {
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
return json.substring(1, json.length() - 2);
}
else
else
return json;
}
else {
@@ -63,34 +77,38 @@ public class ApiInvoker {
public static String serialize(Object obj) throws ApiException {
try {
if (obj != null) return JsonUtil.getJsonMapper().writeValueAsString(obj);
else return null;
if (obj != null)
return JsonUtil.getJsonMapper().writeValueAsString(obj);
else
return null;
}
catch (Exception e) {
throw new ApiException(500, e.getMessage());
}
}
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams) throws ApiException {
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String contentType) throws ApiException {
Client client = getClient(host);
StringBuilder b = new StringBuilder();
for(String key : queryParams.keySet()) {
String value = queryParams.get(key);
if (value != null){
if(b.toString().length() == 0) b.append("?");
else b.append("&");
if(b.toString().length() == 0)
b.append("?");
else
b.append("&");
b.append(escapeString(key)).append("=").append(escapeString(value));
}
}
String querystring = b.toString();
Builder builder = client.resource(host + path + querystring).type("application/json");
Builder builder = client.resource(host + path + querystring).accept("application/json");
for(String key : headerParams.keySet()) {
builder.header(key, headerParams.get(key));
}
for(String key : defaultHeaderMap.keySet()) {
if(!headerParams.containsKey(key)) {
builder.header(key, defaultHeaderMap.get(key));
@@ -102,33 +120,71 @@ public class ApiInvoker {
response = (ClientResponse) builder.get(ClientResponse.class);
}
else if ("POST".equals(method)) {
response = builder.post(ClientResponse.class, serialize(body));
if(body == null)
response = builder.post(ClientResponse.class, null);
else if(body instanceof FormDataMultiPart) {
response = builder.type(contentType).post(ClientResponse.class, body);
}
else
response = builder.type(contentType).post(ClientResponse.class, serialize(body));
}
else if ("PUT".equals(method)) {
response = builder.put(ClientResponse.class, serialize(body));
if(body == null)
response = builder.put(ClientResponse.class, serialize(body));
else {
if("application/x-www-form-urlencoded".equals(contentType)) {
StringBuilder formParamBuilder = new StringBuilder();
// encode the form params
for(String key : formParams.keySet()) {
String value = formParams.get(key);
if(value != null && !"".equals(value.trim())) {
if(formParamBuilder.length() > 0) {
formParamBuilder.append("&");
}
try {
formParamBuilder.append(URLEncoder.encode(key, "utf8")).append("=").append(URLEncoder.encode(value, "utf8"));
}
catch (Exception e) {
// move on to next
}
}
}
response = builder.type(contentType).put(ClientResponse.class, formParamBuilder.toString());
}
else
response = builder.type(contentType).put(ClientResponse.class, serialize(body));
}
}
else if ("DELETE".equals(method)) {
if(body == null)
response = builder.delete(ClientResponse.class, serialize(body));
else
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
}
else {
throw new ApiException(500, "unknown method type " + method);
}
if(response.getClientResponseStatus() == ClientResponse.Status.OK) {
if(response.getClientResponseStatus() == ClientResponse.Status.NO_CONTENT) {
return null;
}
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
return (String) response.getEntity(String.class);
}
else {
throw new ApiException(
response.getClientResponseStatus().getStatusCode(),
response.getEntity(String.class));
response.getEntity(String.class));
}
}
private Client getClient(String host) {
if(!hostMap.containsKey(host)) {
Client client = Client.create();
client.addFilter(new LoggingFilter());
hostMap.put(host, client);
}
return hostMap.get(host);
if(!hostMap.containsKey(host)) {
Client client = Client.create();
if(isDebug)
client.addFilter(new LoggingFilter());
hostMap.put(host, client);
}
return hostMap.get(host);
}
}

View File

@@ -0,0 +1,51 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import com.wordnik.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty;
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
@ApiModel(description = "{{{description}}}")
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
{{#vars}}{{#isEnum}}
public enum {{datatypeWithEnum}} {
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
};
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
@ApiModelProperty(required = {{required}}, value = "{{{description}}}")
@JsonProperty("{{name}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/vars}}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
{{/vars}}sb.append("}\n");
return sb.toString();
}
}
{{/model}}
{{/models}}

View File

@@ -0,0 +1,168 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<packaging>jar</packaging>
<name>{{artifactId}}</name>
<version>{{artifactVersion}}</version>
<scm>
<connection>scm:git:git@github.com:wordnik/swagger-mustache.git</connection>
<developerConnection>scm:git:git@github.com:wordnik/swagger-codegen.git</developerConnection>
<url>https://github.com/wordnik/swagger-codegen</url>
</scm>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemProperties>
<property>
<name>loggerPath</name>
<value>conf/log4j.properties</value>
</property>
</systemProperties>
<argLine>-Xms512m -Xmx1500m</argLine>
<parallel>methods</parallel>
<forkMode>pertest</forkMode>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- attach test jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add_sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add_test_sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<swagger-annotations-version>1.5.0-M1</swagger-annotations-version>
<jersey-version>1.7</jersey-version>
<jackson-version>2.1.4</jackson-version>
<jodatime-version>2.3</jodatime-version>
<junit-version>4.8.1</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
</properties>
</project>

View File

@@ -0,0 +1,9 @@
package {{apiPackage}};
public class ApiException extends Exception{
private int code;
public ApiException (int code, String msg) {
super(msg);
this.code = code;
}
}

View File

@@ -0,0 +1,26 @@
package {{apiPackage}};
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
public class ApiOriginFilter implements javax.servlet.Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
}

View File

@@ -0,0 +1,68 @@
package {{apiPackage}};
import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage {
public static final int ERROR = 1;
public static final int WARNING = 2;
public static final int INFO = 3;
public static final int OK = 4;
public static final int TOO_BUSY = 5;
int code;
String type;
String message;
public ApiResponseMessage(){}
public ApiResponseMessage(int code, String message){
this.code = code;
switch(code){
case ERROR:
setType("error");
break;
case WARNING:
setType("warning");
break;
case INFO:
setType("info");
break;
case OK:
setType("ok");
break;
case TOO_BUSY:
setType("too busy");
break;
default:
setType("unknown");
break;
}
this.message = message;
}
@XmlTransient
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -0,0 +1,9 @@
package {{apiPackage}};
public class NotFoundException extends ApiException {
private int code;
public NotFoundException (int code, String msg) {
super(code, msg);
this.code = code;
}
}

View File

@@ -0,0 +1,46 @@
package {{package}};
import {{modelPackage}}.*;
import com.wordnik.swagger.annotations.*;
import com.sun.jersey.multipart.FormDataParam;
{{#imports}}import {{import}};
{{/imports}}
import java.util.List;
import {{package}}.NotFoundException;
import java.io.InputStream;
import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.FormDataParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.*;
@Path("/{{baseName}}")
@Api(value = "/{{baseName}}", description = "the {{baseName}} API")
{{#operations}}
public class {{classname}} {
{{#operation}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
// {{returnType}}
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}})
@ApiResponses(value = { {{#responses}}
@ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},
{{/hasMore}}{{/responses}} })
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
{{/hasMore}}{{/allParams}})
throws NotFoundException {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
{{/operation}}
}
{{/operations}}

View File

@@ -0,0 +1 @@
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isBodyParam}}

View File

@@ -0,0 +1,2 @@
{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @FormDataParam("file") InputStream inputStream,
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}

View File

@@ -0,0 +1 @@
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@HeaderParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}

View File

@@ -0,0 +1,51 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import com.wordnik.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty;
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
@ApiModel(description = "{{{description}}}")
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
{{#vars}}{{#isEnum}}
public enum {{datatypeWithEnum}} {
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
};
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
@ApiModelProperty(required = {{required}}, value = "{{{description}}}")
@JsonProperty("{{name}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/vars}}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
{{/vars}}sb.append("}\n");
return sb.toString();
}
}
{{/model}}
{{/models}}

View File

@@ -0,0 +1 @@
{{#isPathParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}

View File

@@ -0,0 +1,135 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<packaging>jar</packaging>
<name>{{artifactId}}</name>
<version>{{artifactVersion}}</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<webAppConfig>
<contextPath>{{^basePath}}/{{/basePath}}{{#basePath}}{{basePath}}{{/basePath}}</contextPath>
</webAppConfig>
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<webDefaultXml>${project.basedir}/conf/jetty/webdefault.xml</webDefaultXml>
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8002</port>
<maxIdleTime>60000</maxIdleTime>
<confidentialPort>8443</confidentialPort>
</connector>
</connectors>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jersey-jaxrs</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.9.1</artifactId>
<version>${scala-test-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
</dependency>
</dependencies>
<properties>
<swagger-core-version>1.5.1-M1</swagger-core-version>
<jetty-version>8.1.11.v20130520</jetty-version>
<jersey-version>1.13</jersey-version>
<slf4j-version>1.6.3</slf4j-version>
<scala-test-version>1.6.1</scala-test-version>
<junit-version>4.8.1</junit-version>
<servlet-api-version>2.5</servlet-api-version>
</properties>
</project>

View File

@@ -1,3 +1,5 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.4")
libraryDependencies <+= sbtVersion(v => v match {
case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8"
case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10"

View File

@@ -0,0 +1 @@
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @QueryParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.wordnik.swagger.jaxrs.json;com.wordnik.swagger.jaxrs.listing;{{apiPackage}}</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.PostReplaceFilter</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>DefaultJaxrsConfig</servlet-name>
<servlet-class>com.wordnik.swagger.jaxrs.config.DefaultJaxrsConfig</servlet-class>
<init-param>
<param-name>api.version</param-name>
<param-value>1.0.0</param-value>
</init-param>
<init-param>
<param-name>swagger.api.title</param-name>
<param-value>{{{title}}}</param-value>
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>http://localhost:8002</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>ApiOriginFilter</filter-name>
<filter-class>{{apiPackage}}.ApiOriginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ApiOriginFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@@ -0,0 +1,13 @@
com.wordnik.swagger.codegen.languages.AndroidClientCodegen
com.wordnik.swagger.codegen.languages.JavaClientCodegen
com.wordnik.swagger.codegen.languages.JaxRSServerCodegen
com.wordnik.swagger.codegen.languages.NodeJSServerCodegen
com.wordnik.swagger.codegen.languages.ObjcClientCodegen
com.wordnik.swagger.codegen.languages.ScalatraServerCodegen
com.wordnik.swagger.codegen.languages.ScalaClientCodegen
com.wordnik.swagger.codegen.languages.StaticDocCodegen
com.wordnik.swagger.codegen.languages.StaticHtmlGenerator
com.wordnik.swagger.codegen.languages.SwaggerGenerator
com.wordnik.swagger.codegen.languages.TizenClientCodegen
com.wordnik.swagger.codegen.languages.PhpClientCodegen
com.wordnik.swagger.codegen.languages.PythonClientCodegen

View File

@@ -2,36 +2,46 @@ package {{package}};
import {{invokerPackage}}.ApiException;
import {{invokerPackage}}.ApiInvoker;
import {{modelPackage}}.*;
import java.util.*;
{{#imports}}import {{import}};
{{/imports}}
import java.util.*;
import java.util.Map;
import java.util.HashMap;
import java.io.File;
{{#operations}}
public class {{classname}} {
String basePath = "{{basePath}}";
ApiInvoker apiInvoker = ApiInvoker.getInstance();
public void addHeader(String key, String value) {
getInvoker().addDefaultHeader(key, value);
}
public ApiInvoker getInvoker() {
return apiInvoker;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getBasePath() {
return basePath;
}
{{#operation}}
{{#errorList}} //error info- code: {{code}} reason: "{{reason}}" model: {{#responseModel}}{{responseModel}}
{{/responseModel}}{{^responseModel}}<none>
{{/responseModel}}
{{/errorList}}
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
// create path and map variables
String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}})){{/pathParams}};
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
{{#requiredParamCount}}
// verify required params are set
@@ -40,15 +50,24 @@ public class {{classname}} {
}
{{/requiredParamCount}}
// create path and map variables
String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}};
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
queryParams.put("{{paramName}}", String.valueOf({{paramName}}));
queryParams.put("{{baseName}}", String.valueOf({{paramName}}));
{{/queryParams}}
{{#headerParams}}headerParams.put("{{paramName}}", {{paramName}});
{{#headerParams}}headerParams.put("{{baseName}}", {{paramName}});
{{/headerParams}}
String contentType = "application/json";
try {
String response = apiInvoker.invokeAPI(basePath, path, "{{httpMethod}}", queryParams, {{#bodyParam}}{{bodyParam}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}, headerParams);
String response = apiInvoker.invokeAPI(basePath, path, "{{httpMethod}}", queryParams, postBody, headerParams, contentType);
if(response != null){
return {{#returnType}}({{{returnType}}}) ApiInvoker.deserialize(response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}};
}
@@ -57,7 +76,7 @@ public class {{classname}} {
}
} catch (ApiException ex) {
if(ex.getCode() == 404) {
return {{#returnType}} null{{/returnType}};
return {{#returnType}} null{{/returnType}};
}
else {
throw ex;
@@ -66,4 +85,4 @@ public class {{classname}} {
}
{{/operation}}
}
{{/operations}}
{{/operations}}

View File

@@ -0,0 +1,29 @@
package {{invokerPackage}};
public class ApiException extends Exception {
int code = 0;
String message = null;
public ApiException() {}
public ApiException(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -0,0 +1,283 @@
package {{invokerPackage}};
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.http.*;
import org.apache.http.client.*;
import org.apache.http.client.methods.*;
import org.apache.http.conn.*;
import org.apache.http.conn.scheme.*;
import org.apache.http.conn.ssl.*;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.impl.conn.*;
import org.apache.http.params.*;
import org.apache.http.util.EntityUtils;
import java.io.File;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.URLEncoder;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class ApiInvoker {
private static ApiInvoker INSTANCE = new ApiInvoker();
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private HttpClient client = null;
private boolean ignoreSSLCertificates = false;
private ClientConnectionManager ignoreSSLConnectionManager;
public ApiInvoker() {
initConnectionManager();
}
public static ApiInvoker getInstance() {
return INSTANCE;
}
public void ignoreSSLCertificates(boolean ignoreSSLCertificates) {
this.ignoreSSLCertificates = ignoreSSLCertificates;
}
public void addDefaultHeader(String key, String value) {
defaultHeaderMap.put(key, value);
}
public String escapeString(String str) {
return str;
}
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
try{
if("List".equals(containerType)) {
JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls);
List response = (List<?>) JsonUtil.getJsonMapper().readValue(json, typeInfo);
return response;
}
else if(String.class.equals(cls)) {
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
return json.substring(1, json.length() - 2);
else
return json;
}
else {
return JsonUtil.getJsonMapper().readValue(json, cls);
}
}
catch (IOException e) {
throw new ApiException(500, e.getMessage());
}
}
public static String serialize(Object obj) throws ApiException {
try {
if (obj != null)
return JsonUtil.getJsonMapper().writeValueAsString(obj);
else
return null;
}
catch (Exception e) {
throw new ApiException(500, e.getMessage());
}
}
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, String contentType) throws ApiException {
HttpClient client = getClient(host);
StringBuilder b = new StringBuilder();
for(String key : queryParams.keySet()) {
String value = queryParams.get(key);
if (value != null){
if(b.toString().length() == 0)
b.append("?");
else
b.append("&");
b.append(escapeString(key)).append("=").append(escapeString(value));
}
}
String url = host + path + b.toString();
HashMap<String, String> headers = new HashMap<String, String>();
for(String key : headerParams.keySet()) {
headers.put(key, headerParams.get(key));
}
for(String key : defaultHeaderMap.keySet()) {
if(!headerParams.containsKey(key)) {
headers.put(key, defaultHeaderMap.get(key));
}
}
headers.put("Accept", "application/json");
HttpResponse response = null;
try{
if("GET".equals(method)) {
HttpGet get = new HttpGet(url);
get.addHeader("Accept", "application/json");
for(String key : headers.keySet()) {
get.setHeader(key, headers.get(key));
}
response = client.execute(get);
}
else if ("POST".equals(method)) {
HttpPost post = new HttpPost(url);
if (body != null) {
post.setHeader("Content-Type", contentType);
post.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
post.setHeader(key, headers.get(key));
}
response = client.execute(post);
}
else if ("PUT".equals(method)) {
HttpPut put = new HttpPut(url);
if(body != null) {
put.setHeader("Content-Type", contentType);
put.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
put.setHeader(key, headers.get(key));
}
response = client.execute(put);
}
else if ("DELETE".equals(method)) {
HttpDelete delete = new HttpDelete(url);
for(String key : headers.keySet()) {
delete.setHeader(key, headers.get(key));
}
response = client.execute(delete);
}
else if ("PATCH".equals(method)) {
HttpPatch patch = new HttpPatch(url);
if (body != null) {
patch.setHeader("Content-Type", contentType);
patch.setEntity(new StringEntity(serialize(body), "UTF-8"));
}
for(String key : headers.keySet()) {
patch.setHeader(key, headers.get(key));
}
response = client.execute(patch);
}
int code = response.getStatusLine().getStatusCode();
String responseString = null;
if(code == 204)
responseString = "";
else if(code >= 200 && code < 300) {
if(response.getEntity() != null) {
HttpEntity resEntity = response.getEntity();
responseString = EntityUtils.toString(resEntity);
}
}
else {
if(response.getEntity() != null) {
HttpEntity resEntity = response.getEntity();
responseString = EntityUtils.toString(resEntity);
}
else
responseString = "no data";
throw new ApiException(code, responseString);
}
return responseString;
}
catch(IOException e) {
throw new ApiException(500, e.getMessage());
}
}
private HttpClient getClient(String host) {
if (client == null) {
if (ignoreSSLCertificates && ignoreSSLConnectionManager != null) {
// Trust self signed certificates
client = new DefaultHttpClient(ignoreSSLConnectionManager, new BasicHttpParams());
} else {
client = new DefaultHttpClient();
}
}
return client;
}
private void initConnectionManager() {
try {
final SSLContext sslContext = SSLContext.getInstance("SSL");
// set up a TrustManager that trusts everything
TrustManager[] trustManagers = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
}};
sslContext.init(null, trustManagers, new SecureRandom());
SSLSocketFactory sf = new SSLSocketFactory((KeyStore)null) {
private javax.net.ssl.SSLSocketFactory sslFactory = sslContext.getSocketFactory();
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
throws IOException, UnknownHostException {
return sslFactory.createSocket(socket, host, port, autoClose);
}
public Socket createSocket() throws IOException {
return sslFactory.createSocket();
}
};
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Scheme httpsScheme = new Scheme("https", sf, 443);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
ignoreSSLConnectionManager = new SingleClientConnManager(new BasicHttpParams(), schemeRegistry);
} catch (NoSuchAlgorithmException e) {
// This will only be thrown if SSL isn't available for some reason.
} catch (KeyManagementException e) {
// This might be thrown when passing a key into init(), but no key is being passed.
} catch (GeneralSecurityException e) {
// This catches anything else that might go wrong.
// If anything goes wrong we default to the standard connection manager.
}
}
}

View File

@@ -0,0 +1,16 @@
package {{invokerPackage}};
import org.apache.http.client.methods.*;
public class HttpPatch extends HttpPost {
public static final String METHOD_PATCH = "PATCH";
public HttpPatch(final String url) {
super(url);
}
@Override
public String getMethod() {
return METHOD_PATCH;
}
}

View File

@@ -0,0 +1,20 @@
package {{invokerPackage}};
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
public class JsonUtil {
public static ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
public static ObjectMapper getJsonMapper() {
return mapper;
}
}

View File

@@ -0,0 +1,51 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import com.wordnik.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty;
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
@ApiModel(description = "{{{description}}}")
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
{{#vars}}{{#isEnum}}
public enum {{datatypeWithEnum}} {
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
};
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}}
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
* maximum: {{maximum}}{{/maximum}}
**/
@ApiModelProperty(required = {{required}}, value = "{{{description}}}")
@JsonProperty("{{name}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/vars}}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class {{classname}} {\n");
{{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}}
{{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n");
{{/vars}}sb.append("}\n");
return sb.toString();
}
}
{{/model}}
{{/models}}

View File

@@ -0,0 +1,162 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<packaging>jar</packaging>
<name>{{artifactId}}</name>
<version>{{artifactVersion}}</version>
<scm>
<connection>scm:git:git@github.com:wordnik/swagger-mustache.git</connection>
<developerConnection>scm:git:git@github.com:wordnik/swagger-codegen.git</developerConnection>
<url>https://github.com/wordnik/swagger-codegen</url>
</scm>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemProperties>
<property>
<name>loggerPath</name>
<value>conf/log4j.properties</value>
</property>
</systemProperties>
<argLine>-Xms512m -Xmx1500m</argLine>
<parallel>methods</parallel>
<forkMode>pertest</forkMode>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- attach test jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add_sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add_test_sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient-version}</version>
<scope>compile</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<properties>
<swagger-annotations-version>1.5.1-M1</swagger-annotations-version>
<jackson-version>2.1.4</jackson-version>
<junit-version>4.8.1</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
<httpclient-version>4.0</httpclient-version>
</properties>
</project>

View File

@@ -0,0 +1,59 @@
package {{package}}
{{#imports}}import {{import}}
{{/imports}}
import com.wordnik.swagger.client._
import scala.concurrent.{ Future, Await }
import scala.concurrent.duration._
import collection.mutable
{{#operations}}
class {{className}}(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
{{#operation}}
def {{nickname}}({{#allParams}}
{{#optional}}
{{paramName}}: Option[{{dataType}}] = {{#defaultValue}}Some({{defaultValue}}){{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{#hasMore}}, {{/hasMore}}
{{/optional}}
{{^optional}}
{{paramName}}: {{dataType}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#hasMore}}, {{/hasMore}}
{{/optional}}{{/allParams}})(implicit reader: ClientResponseReader[{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}}]{{#bodyParams}}, writer: RequestWriter[{{dataType}}]{{/bodyParams}}){{#returnType}}: Future[{{returnType}}]{{/returnType}}{{^returnType}}: Future[Unit]{{/returnType}} = {
// create path and map variables
val path =
(addFmt("{{path}}"){{#pathParams}}
replaceAll ("\\{" + "{{baseName}}" + "\\}",{{paramName}}.toString)
{{/pathParams}})
// query params
val queryParams = new mutable.HashMap[String, String]
val headerParams = new mutable.HashMap[String, String]
{{#requiredParamCount}}
// verify required params are set
val paramCount = (Set[Any]({{/requiredParamCount}}{{#requiredParams}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) - null).size
if (paramCount != {{requiredParamCount}}) sys.error("missing required params")
{{/requiredParamCount}}
{{#queryParams}}
{{#optional}}
if({{paramName}} != null) {{paramName}}.foreach { v => queryParams += "{{baseName}}" -> v.toString }
{{/optional}}
{{^optional}}
if({{paramName}} != null) queryParams += "{{baseName}}" -> {{paramName}}.toString
{{/optional}}
{{/queryParams}}
{{#headerParams}}headerParams += "{{baseName}}" -> {{paramName}}.toString
{{/headerParams}}
val resFuture = client.submit("{{httpMethod}}", path, queryParams.toMap, headerParams.toMap, {{#bodyParam}}writer.write({{bodyParam}}){{/bodyParam}}{{^bodyParam}}"{{emptyBodyParam}}"{{/bodyParam}})
resFuture flatMap { resp =>
process(reader.read(resp))
}
}
{{/operation}}
}
{{/operations}}

View File

@@ -0,0 +1,26 @@
package {{package}}
{{#imports}}import {{import}}
{{/imports}}
import com.wordnik.swagger.client._
import apis._
import java.io.Closeable
class {{clientName}}(config: SwaggerConfig) extends Closeable {
val locator = config.locator
val name = config.name
private[this] val client = transportClient
protected def transportClient: TransportClient = new RestClient(config)
{{#apiInfo}}
{{#apis}}
val {{name}} = new {{className}}(client, config)
{{/apis}}
{{/apiInfo}}
def close() {
client.close()
}
}

View File

@@ -0,0 +1,15 @@
package {{package}}
import org.joda.time.DateTime
{{#models}}
{{#model}}
case class {{classname}} (
{{#vars}}
{{name}}: {{#isNotRequired}}Option[{{/isNotRequired}}{{datatype}}{{#isNotRequired}}]{{/isNotRequired}} {{#hasMore}},{{/hasMore}}{{#description}} // {{description}}{{/description}}{{newline}}
{{/vars}}
)
{{/model}}
{{/models}}

View File

@@ -0,0 +1,11 @@
organization := "{{package}}"
name := "{{projectName}}-client"
libraryDependencies += "com.wordnik.swagger" %% "swagger-async-httpclient" % "0.3.0-WN5"
libraryDependencies += "joda-time" % "joda-time" % "2.3"
libraryDependencies += "org.joda" % "joda-convert" % "1.3.1"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.0.13" % "provided"

Some files were not shown because too many files have changed in this diff Show More