Skip to content

Commit eafcc43

Browse files
committed
Merge pull request #851 from swagger-api/develop_2.0
merge from develop 2.0 for release
2 parents 915ad77 + 570383d commit eafcc43

File tree

415 files changed

+43638
-51834
lines changed

Some content is hidden

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

415 files changed

+43638
-51834
lines changed

bin/all-petstore.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ cd $APP_DIR
2525
./bin/jaxrs-petstore-server.sh
2626
./bin/java-petstore.sh
2727
./bin/qt5-petstore.sh
28+
./bin/perl-petstore.sh
2829
./bin/php-petstore.sh
2930
./bin/python-petstore.sh
3031
./bin/retrofit-petstore.sh

modules/swagger-codegen-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger</groupId>
55
<artifactId>swagger-codegen-project</artifactId>
6-
<version>2.1.1</version>
6+
<version>2.1.2</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-codegen/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger</groupId>
55
<artifactId>swagger-codegen-project</artifactId>
6-
<version>2.1.1</version>
6+
<version>2.1.2</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-codegen/src/main/resources/Groovy/ApiUtils.mustache

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@ import static java.net.URI.create;
88

99
class ApiUtils {
1010
11-
def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) {
12-
def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath)
13-
println "url=$url uriPath=$uriPath"
14-
def http = new HTTPBuilder(url)
15-
http.request( Method.valueOf(method), JSON ) {
16-
uri.path = uriPath
17-
uri.query = queryParams
18-
response.success = { resp, json ->
19-
if (type != null) {
20-
onSuccess(parse(json, container, type))
21-
}
22-
}
23-
response.failure = { resp ->
24-
onFailure(resp.status, resp.statusLine.reasonPhrase)
25-
}
26-
}
27-
}
28-
29-
30-
def buildUrlAndUriPath(basePath, versionPath, resourcePath) {
31-
// HTTPBuilder expects to get as its constructor parameter an URL,
32-
// without any other additions like path, therefore we need to cut the path
33-
// from the basePath as it is represented by swagger APIs
34-
// we use java.net.URI to manipulate the basePath
35-
// then the uriPath will hold the rest of the path
36-
URI baseUri = create(basePath)
37-
def pathOnly = baseUri.getPath()
38-
[basePath-pathOnly, pathOnly+versionPath+resourcePath]
39-
}
40-
41-
42-
def parse(object, container, clazz) {
43-
if (container == "List") {
44-
return object.collect {parse(it, "", clazz)}
45-
} else {
46-
return clazz.newInstance(object)
47-
}
48-
}
11+
def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) {
12+
def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath)
13+
println "url=$url uriPath=$uriPath"
14+
def http = new HTTPBuilder(url)
15+
http.request( Method.valueOf(method), JSON ) {
16+
uri.path = uriPath
17+
uri.query = queryParams
18+
response.success = { resp, json ->
19+
if (type != null) {
20+
onSuccess(parse(json, container, type))
21+
}
22+
}
23+
response.failure = { resp ->
24+
onFailure(resp.status, resp.statusLine.reasonPhrase)
25+
}
26+
}
27+
}
28+
29+
30+
def buildUrlAndUriPath(basePath, versionPath, resourcePath) {
31+
// HTTPBuilder expects to get as its constructor parameter an URL,
32+
// without any other additions like path, therefore we need to cut the path
33+
// from the basePath as it is represented by swagger APIs
34+
// we use java.net.URI to manipulate the basePath
35+
// then the uriPath will hold the rest of the path
36+
URI baseUri = create(basePath)
37+
def pathOnly = baseUri.getPath()
38+
[basePath-pathOnly, pathOnly+versionPath+resourcePath]
39+
}
40+
41+
42+
def parse(object, container, clazz) {
43+
if (container == "List") {
44+
return object.collect {parse(it, "", clazz)}
45+
} else {
46+
return clazz.newInstance(object)
47+
}
48+
}
4949

5050
}
Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package {{package}};
22

33

4+
5+
6+
47
import groovyx.net.http.*
58
import static groovyx.net.http.ContentType.*
69
import static groovyx.net.http.Method.*
@@ -14,40 +17,40 @@ import java.util.*;
1417

1518
@Mixin(ApiUtils)
1619
{{#operations}}
17-
class {{classname}} {
20+
class {{classname}} {
1821
String basePath = "{{basePath}}"
1922
String versionPath = "/api/v1"
2023
2124
22-
{{#operation}}
23-
def {{nickname}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) {
24-
// create path and map variables
25-
String resourcePath = "{{path}}"
25+
{{#operation}}
26+
def {{nickname}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) {
27+
// create path and map variables
28+
String resourcePath = "{{path}}"
2629
2730
28-
// query params
29-
def queryParams = [:]
30-
def headerParams = [:]
31+
// query params
32+
def queryParams = [:]
33+
def headerParams = [:]
3134
32-
{{#requiredParamCount}}
33-
// verify required params are set
34-
if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
35-
throw new RuntimeException("missing required params")
36-
}
37-
{{/requiredParamCount}}
35+
{{#requiredParamCount}}
36+
// verify required params are set
37+
if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) {
38+
throw new RuntimeException("missing required params")
39+
}
40+
{{/requiredParamCount}}
3841

39-
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
40-
queryParams.put("{{paramName}}", String.valueOf({{paramName}}))
41-
{{/queryParams}}
42+
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
43+
queryParams.put("{{paramName}}", String.valueOf({{paramName}}))
44+
{{/queryParams}}
4245

43-
{{#headerParams}}headerParams.put("{{paramName}}", {{paramName}})
44-
{{/headerParams}}
46+
{{#headerParams}}headerParams.put("{{paramName}}", {{paramName}})
47+
{{/headerParams}}
4548

46-
invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams,
47-
"{{httpMethod}}", "{{returnContainer}}",
48-
{{#returnBaseType}}{{{returnBaseType}}}.class {{/returnBaseType}}{{^returnBaseType}}null {{/returnBaseType}})
49+
invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams,
50+
"{{httpMethod}}", "{{returnContainer}}",
51+
{{#returnBaseType}}{{{returnBaseType}}}.class {{/returnBaseType}}{{^returnBaseType}}null {{/returnBaseType}})
4952

50-
}
51-
{{/operation}}
52-
}
53+
}
54+
{{/operation}}
55+
}
5356
{{/operations}}

modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ archivesBaseName = 'swagger-gen-groovy'
66
version = '0.1'
77

88
buildscript {
9-
repositories {
10-
maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' }
11-
}
12-
dependencies {
13-
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16')
14-
}
9+
repositories {
10+
maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' }
11+
}
12+
dependencies {
13+
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16')
14+
}
1515
}
1616

1717
repositories {
18-
mavenCentral()
19-
mavenLocal()
20-
mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone'])
21-
maven { url "http://$artifactory:8080/artifactory/repo" }
18+
mavenCentral()
19+
mavenLocal()
20+
mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone'])
21+
maven { url "http://$artifactory:8080/artifactory/repo" }
2222
}
2323

2424
dependencies {
25-
groovy "org.codehaus.groovy:groovy-all:2.0.5"
26-
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.6'
25+
groovy "org.codehaus.groovy:groovy-all:2.0.5"
26+
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.6'
2727
2828
2929
}

modules/swagger-codegen/src/main/resources/Groovy/model.mustache

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import groovy.transform.Canonical
44
{{#imports}}import {{import}};
55
{{/imports}}
66
{{#models}}
7-
{{#model}}
8-
@Canonical
9-
class {{classname}} {
10-
{{#vars}}
7+
{{#model}}
8+
@Canonical
9+
class {{classname}} {
10+
{{#vars}}
1111

12-
{{#description}}/* {{{description}}} */
13-
{{/description}}
14-
{{{datatype}}} {{name}} = {{{defaultValue}}}
15-
{{/vars}}
12+
{{#description}}/* {{{description}}} */
13+
{{/description}}
14+
{{{datatype}}} {{name}} = {{{defaultValue}}}
15+
{{/vars}}
16+
1617

18+
}
1719

18-
}
19-
20-
{{/model}}
20+
{{/model}}
2121
{{/models}}

0 commit comments

Comments
 (0)