Skip to content

Commit 3b3738e

Browse files
committed
Merge pull request #847 from wing328/fix_indentation
Fix indentation
2 parents 1644956 + 680078d commit 3b3738e

File tree

240 files changed

+21337
-25481
lines changed

Some content is hidden

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

240 files changed

+21337
-25481
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,15 @@
55
## Overview
66
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.
77

8-
## What's Swagger?
9-
10-
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.
11-
12-
138
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.
149

1510

16-
## Compatability
11+
## Compatibility
1712
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification:
1813

1914
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
2015
----------------------- | ------------ | -------------------------- | -----
21-
2.1.0 | 2015-06-09 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
16+
2.1.0 | 2015-06-09 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
2217
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)
2318
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)
2419

@@ -29,6 +24,17 @@ You need the following installed and available in your $PATH:
2924
* [Java 7](http://java.oracle.com)
3025

3126
* [Apache maven 3.0.3 or greater](http://maven.apache.org/)
27+
28+
#### OS X Users
29+
Don't forget to install Java 7. You probably have 1.6 or 1.8.
30+
31+
Export JAVA_HOME in order to user proper Java version:
32+
```
33+
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
34+
export PATH=${JAVA_HOME}/bin:$PATH
35+
```
36+
37+
#### Building
3238

3339
After cloning the project, you can build it from source with this command:
3440

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/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)