();
@@ -193,11 +193,11 @@ namespace {{packageName}}.Api
String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
// make the HTTP request
- IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
- {{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}), response.Headers);{{/returnType}}{{^returnType}}
+ {{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
return;{{/returnType}}
}
{{/operation}}
diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache
index ac07a3fd9f55..9473309ff83a 100644
--- a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache
+++ b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache
@@ -87,6 +87,13 @@
{{/hasQueryParams}}
+ {{#hasFormParams}}
+ Form parameters
+
+ {{#formParams}}{{>formParam}}{{/formParams}}
+
+ {{/hasFormParams}}
+
diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache
index d69f0e7b1617..8d9a5755d7bb 100644
--- a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache
+++ b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache
@@ -124,6 +124,20 @@ code {
font-style: italic;
}
+.param-enum-header {
+width: 700px;
+padding: 0 0 0 60px;
+color: #777;
+font-weight: bold;
+}
+
+.param-enum {
+width: 700px;
+padding: 0 0 0 80px;
+color: #777;
+font-style: italic;
+}
+
.field-label {
padding: 0;
margin: 0;
diff --git a/modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache b/modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache
index f3fca3f41a75..e740ea593ab0 100644
--- a/modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache
+++ b/modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache
@@ -28,7 +28,7 @@ sub to_hash {
sub TO_JSON {
my $self = shift;
my $_data = {};
- foreach my $_key (keys $self->get_attribute_map) {
+ foreach my $_key (keys %{$self->get_attribute_map}) {
if (defined $self->{$_key}) {
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
}
@@ -40,7 +40,7 @@ sub TO_JSON {
sub from_hash {
my ($self, $hash) = @_;
# loop through attributes and use swagger_types to deserialize the data
- while ( my ($_key, $_type) = each $self->get_swagger_types ) {
+ while ( my ($_key, $_type) = each %{$self->get_swagger_types} ) {
if ($_type =~ /^array\[/i) { # array
my $_subclass = substr($_type, 6, -1);
my @_array = ();
diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
index 9db41df2aeec..e2193b1d754f 100644
--- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
@@ -239,9 +239,14 @@ class ApiClient
$data = $http_body;
}
} else {
+ $data = json_decode($http_body);
+ if (json_last_error() > 0) { // if response is a string
+ $data = $http_body;
+ }
+
throw new ApiException(
"[".$response_info['http_code']."] Error connecting to the API ($url)",
- $response_info['http_code'], $http_header, $http_body
+ $response_info['http_code'], $http_header, $data
);
}
return array($data, $http_header);
diff --git a/modules/swagger-codegen/src/main/resources/php/ApiException.mustache b/modules/swagger-codegen/src/main/resources/php/ApiException.mustache
index 79d1b4fe0a15..b9022f42a901 100644
--- a/modules/swagger-codegen/src/main/resources/php/ApiException.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/ApiException.mustache
@@ -46,30 +46,30 @@ use \Exception;
class ApiException extends Exception
{
- /**
- * The HTTP body of the server response.
- * @var string
+ /**
+ * The HTTP body of the server response either as Json or string.
+ * @var mixed
*/
protected $responseBody;
-
+
/**
* The HTTP header of the server response.
* @var string[]
*/
protected $responseHeaders;
-
+
/**
* The deserialized response object
* @var $responseObject;
*/
protected $responseObject;
-
+
/**
* Constructor
* @param string $message Error message
- * @param string $code HTTP status code
+ * @param int $code HTTP status code
* @param string $responseHeaders HTTP response header
- * @param string $responseBody Deseralized response object
+ * @param mixed $responseBody HTTP body of the server response either as Json or string
*/
public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null)
{
@@ -77,7 +77,7 @@ class ApiException extends Exception
$this->responseHeaders = $responseHeaders;
$this->responseBody = $responseBody;
}
-
+
/**
* Gets the HTTP response header
*
@@ -87,17 +87,17 @@ class ApiException extends Exception
{
return $this->responseHeaders;
}
-
+
/**
- * Gets the HTTP response body
+ * Gets the HTTP body of the server response either as Json or string
*
- * @return string HTTP response body
+ * @return mixed HTTP body of the server response either as Json or string
*/
public function getResponseBody()
{
return $this->responseBody;
}
-
+
/**
* Sets the deseralized response object (during deserialization)
* @param mixed $obj Deserialized response object
diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache
index db1d4c8cb4f2..78eaeb7cc6bf 100644
--- a/modules/swagger-codegen/src/main/resources/php/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/api.mustache
@@ -140,7 +140,18 @@ use \{{invokerPackage}}\ObjectSerializer;
}{{/pathParams}}
{{#formParams}}// form params
if (${{paramName}} !== null) {
- $formParams['{{baseName}}'] = {{#isFile}}'@' . {{/isFile}}$this->apiClient->getSerializer()->toFormValue(${{paramName}});
+ {{#isFile}}
+ // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
+ // See: https://wiki.php.net/rfc/curl-file-upload
+ if (function_exists('curl_file_create')) {
+ $formParams['{{baseName}}'] = curl_file_create($this->apiClient->getSerializer()->toFormValue(${{paramName}}));
+ } else {
+ $formParams['{{baseName}}'] = '@' . $this->apiClient->getSerializer()->toFormValue(${{paramName}});
+ }
+ {{/isFile}}
+ {{^isFile}}
+ $formParams['{{baseName}}'] = $this->apiClient->getSerializer()->toFormValue(${{paramName}});
+ {{/isFile}}
}{{/formParams}}
{{#bodyParams}}// body params
$_tempBody = null;
diff --git a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
index 77b320d07f43..ccf6db4a4fd1 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
@@ -60,14 +60,13 @@ module {{moduleName}}
# return the object in the form of hash
def to_hash
hash = {}
- self.class.attribute_map.each_pair do |key, value|
- if self.send(key).is_a?(Array)
- next if self.send(key).empty?
- hash[value] = self.send(key).select{|v| !v.nil?}.map{ |v| _to_hash v} unless self.send(key).nil?
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+ if value.is_a?(Array)
+ hash[param] = value.compact.map{ |v| _to_hash(v) }
else
- unless (_tmp_value = _to_hash self.send(key)).nil?
- hash[value] = _tmp_value
- end
+ hash[param] = _to_hash(value)
end
end
hash
diff --git a/modules/swagger-codegen/src/main/resources/scala/pom.mustache b/modules/swagger-codegen/src/main/resources/scala/pom.mustache
index 5fc849ea87df..7a2e36c935ab 100644
--- a/modules/swagger-codegen/src/main/resources/scala/pom.mustache
+++ b/modules/swagger-codegen/src/main/resources/scala/pom.mustache
@@ -210,7 +210,7 @@
1.2
2.2
1.19
- 1.5.3
+ 1.5.4
1.0.5
1.0.0
2.4.2
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/api.mustache b/modules/swagger-codegen/src/main/resources/scalatra/api.mustache
index 54710361fe9a..b6749641e545 100644
--- a/modules/swagger-codegen/src/main/resources/scalatra/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/scalatra/api.mustache
@@ -33,57 +33,16 @@ class {{classname}} (implicit val swagger: Swagger) extends ScalatraServlet
val {{nickname}}Operation = (apiOperation[{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}]("{{nickname}}")
summary "{{{summary}}}"
- parameters(
- {{#allParams}}{{#isQueryParam}}queryParam[{{dataType}}]("{{paramName}}").description(""){{^required}}.optional{{/required}}{{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}
- {{/isQueryParam}}
- {{#isPathParam}}pathParam[{{dataType}}]("{{paramName}}").description(""){{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}
- {{/isPathParam}}
- {{#isHeaderParam}}headerParam[{{dataType}}]("{{paramName}}").description(""){{^required}}.optional{{/required}}{{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}
- {{/isHeaderParam}}
- {{#isBodyParam}}bodyParam[{{dataType}}]("{{paramName}}").description(""){{^required}}.optional{{/required}}{{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}
- {{/isBodyParam}}
- {{#isFormParam}}formParam[{{dataType}}]("{{paramName}}").description(""){{^required}}.optional{{/required}}{{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}
- {{/isFormParam}}
- {{#hasMore}},{{/hasMore}}
- {{/allParams}})
+ parameters({{#allParams}}{{>queryParam}}{{>pathParam}}{{>bodyParam}}{{>formParam}}{{#hasMore}},
+ {{/hasMore}}{{/allParams}})
)
{{httpMethod}}("{{path}}",operation({{nickname}}Operation)) {
{{#allParams}}
- {{#isFile}}
- val {{paramName}} = fileParams("{{paramName}}")
- {{/isFile}}
- {{^isFile}}
- {{#isPathParam}}
- val {{paramName}} = params.getOrElse("{{paramName}}", halt(400))
- {{/isPathParam}}
-
- {{#isQueryParam}}
- {{#collectionFormat}}val {{paramName}}String = params.getAs[String]("{{paramName}}")
- val {{paramName}} = if("{{collectionFormat}}".equals("default")) {
- {{paramName}}String match {
- case Some(str) => str.split(",")
- case None => List()
- }
- }
- else
- List()
- {{/collectionFormat}}
- {{^collectionFormat}}val {{paramName}} = params.getAs[{{dataType}}]("{{paramName}}"){{/collectionFormat}}
-
- {{/isQueryParam}}
-
- {{#isHeaderParam}}
- val {{paramName}} = request.getHeader("{{paramName}}")
- {{/isHeaderParam}}
-
- {{#isFormParam}}
- val {{paramName}} = params.getAs[{{dataType}}]("{{paramName}}")
- {{/isFormParam}}
-
- {{#isBodyParam}}
- val {{paramName}} = parsedBody.extract[{{dataType}}]
- {{/isBodyParam}}
+ {{#isFile}}val {{paramName}} = fileParams("{{paramName}}"){{/isFile}}
+ {{^isFile}}{{#isPathParam}}
+ val {{paramName}} = params.getOrElse("{{paramName}}", halt(400)){{/isPathParam}}
+ {{>queryParamOperation}}{{>headerParamOperation}}{{>formParamMustache}}{{>bodyParam}}
{{/isFile}}
println("{{paramName}}: " + {{paramName}})
{{/allParams}}
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/bodyParam.mustache b/modules/swagger-codegen/src/main/resources/scalatra/bodyParam.mustache
new file mode 100644
index 000000000000..07a90aa23cbc
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/bodyParam.mustache
@@ -0,0 +1 @@
+{{#isBodyParam}}bodyParam[{{dataType}}]("{{paramName}}").description(""){{^required}}.optional{{/required}}{{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/bodyParamOperation.mustache b/modules/swagger-codegen/src/main/resources/scalatra/bodyParamOperation.mustache
new file mode 100644
index 000000000000..cfb2bf49d235
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/bodyParamOperation.mustache
@@ -0,0 +1,3 @@
+ {{#isBodyParam}}
+ val {{paramName}} = parsedBody.extract[{{dataType}}]
+ {{/isBodyParam}}
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/formParam.mustache b/modules/swagger-codegen/src/main/resources/scalatra/formParam.mustache
new file mode 100644
index 000000000000..1afcf12ccc6a
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/formParam.mustache
@@ -0,0 +1 @@
+{{#isFormParam}}formParam[{{dataType}}]("{{paramName}}").description(""){{^required}}.optional{{/required}}{{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}{{/isFormParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/formParamMustache.mustache b/modules/swagger-codegen/src/main/resources/scalatra/formParamMustache.mustache
new file mode 100644
index 000000000000..29c571ee2efd
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/formParamMustache.mustache
@@ -0,0 +1,3 @@
+ {{#isFormParam}}
+ val {{paramName}} = params.getAs[{{dataType}}]("{{paramName}}")
+ {{/isFormParam}}
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/headerParam.mustache b/modules/swagger-codegen/src/main/resources/scalatra/headerParam.mustache
new file mode 100644
index 000000000000..798bb0fe6d5d
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/headerParam.mustache
@@ -0,0 +1 @@
+{{#isHeaderParam}}headerParam[{{dataType}}]("{{paramName}}").description(""){{^required}}.optional{{/required}}{{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}{{/isHeaderParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/headerParamOperation.mustache b/modules/swagger-codegen/src/main/resources/scalatra/headerParamOperation.mustache
new file mode 100644
index 000000000000..7f8f5286392d
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/headerParamOperation.mustache
@@ -0,0 +1,3 @@
+ {{#isHeaderParam}}
+ val {{paramName}} = request.getHeader("{{paramName}}")
+ {{/isHeaderParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/pathParam.mustache b/modules/swagger-codegen/src/main/resources/scalatra/pathParam.mustache
new file mode 100644
index 000000000000..ae72aa8ec74f
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/pathParam.mustache
@@ -0,0 +1 @@
+{{#isPathParam}}pathParam[{{dataType}}]("{{paramName}}").description(""){{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}{{/isPathParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/queryParam.mustache b/modules/swagger-codegen/src/main/resources/scalatra/queryParam.mustache
new file mode 100644
index 000000000000..79af702d0f04
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/queryParam.mustache
@@ -0,0 +1 @@
+{{#isQueryParam}}queryParam[{{dataType}}]("{{paramName}}").description(""){{^required}}.optional{{/required}}{{#defaultValue}}.defaultValue({{{defaultValue}}}){{/defaultValue}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/queryParamOperation.mustache b/modules/swagger-codegen/src/main/resources/scalatra/queryParamOperation.mustache
new file mode 100644
index 000000000000..832bbed20300
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/scalatra/queryParamOperation.mustache
@@ -0,0 +1,13 @@
+ {{#isQueryParam}}
+ {{#collectionFormat}}val {{paramName}}String = params.getAs[String]("{{paramName}}")
+ val {{paramName}} = if("{{collectionFormat}}".equals("default")) {
+ {{paramName}}String match {
+ case Some(str) => str.split(",")
+ case None => List()
+ }
+ }
+ else
+ List()
+ {{/collectionFormat}}
+ {{^collectionFormat}}val {{paramName}} = params.getAs[{{dataType}}]("{{paramName}}"){{/collectionFormat}}
+ {{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/swagger-static/assets/css/style.css b/modules/swagger-codegen/src/main/resources/swagger-static/assets/css/style.css
index f14f6bdb62c5..b596c11a535f 100644
--- a/modules/swagger-codegen/src/main/resources/swagger-static/assets/css/style.css
+++ b/modules/swagger-codegen/src/main/resources/swagger-static/assets/css/style.css
@@ -100,6 +100,10 @@
float: left;
}
+.param-enum {
+ margin-left: 20px;
+}
+
.section-header {
border-bottom: 2px;
font-weight: bold;
diff --git a/modules/swagger-codegen/src/main/resources/swagger-static/model.mustache b/modules/swagger-codegen/src/main/resources/swagger-static/model.mustache
index a9a39ab6e91c..e6f85872c766 100644
--- a/modules/swagger-codegen/src/main/resources/swagger-static/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/swagger-static/model.mustache
@@ -5,7 +5,16 @@
{{#vars}}
- {{name}} : {{datatype}}
-
{{description}}
+
{{description}}
+ {{#isEnum}}
+
+ - Enum:
+ {{#_enum}}
+
- {{this}}
+ {{/_enum}}
+
+
+ {{/isEnum}}
{{/vars}}
diff --git a/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache b/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache
index 21791168ab2f..dbc25584886c 100644
--- a/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache
@@ -75,29 +75,26 @@ class AlamofireRequestBuilder: RequestBuilder {
request.authenticate(usingCredential: credential)
}
- request.responseJSON(options: .AllowFragments) { (req, res, result) in
+ request.responseJSON(options: .AllowFragments) { response in
managerStore.removeValueForKey(managerId)
- if result.isFailure {
- completion(response: nil, erorr: result.error)
+ if response.result.isFailure {
+ completion(response: nil, erorr: response.result.error)
return
}
if () is T {
- let response = Response(response: res!, body: () as! T)
- completion(response: response, erorr: nil)
+ completion(response: Response(response: response.response!, body: () as! T), erorr: nil)
return
}
- if let json: AnyObject = result.value {
+ if let json: AnyObject = response.result.value {
let body = Decoders.decode(clazz: T.self, source: json)
- let response = Response(response: res!, body: body)
- completion(response: response, erorr: nil)
+ completion(response: Response(response: response.response!, body: body), erorr: nil)
return
} else if "" is T {
// swagger-parser currently doesn't support void, which will be fixed in future swagger-parser release
// https://github.com/swagger-api/swagger-parser/pull/34
- let response = Response(response: res!, body: "" as! T)
- completion(response: response, erorr: nil)
+ completion(response: Response(response: response.response!, body: "" as! T), erorr: nil)
return
}
@@ -113,4 +110,3 @@ class AlamofireRequestBuilder: RequestBuilder {
return httpHeaders
}
}
-
diff --git a/modules/swagger-codegen/src/main/resources/swift/Cartfile.mustache b/modules/swagger-codegen/src/main/resources/swift/Cartfile.mustache
index e36e0eedabdc..c27fd0c14d12 100644
--- a/modules/swagger-codegen/src/main/resources/swift/Cartfile.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/Cartfile.mustache
@@ -1,2 +1,2 @@
-github "Alamofire/Alamofire" >= 2.0.0{{#usePromiseKit}}
+github "Alamofire/Alamofire" >= 3.0.0{{#usePromiseKit}}
github "mxcl/PromiseKit" >=1.5.3{{/usePromiseKit}}
diff --git a/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache b/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache
index e359edaff671..5cf337ad6f2a 100644
--- a/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
s.documentation_url = '{{podDocumentationURL}}'{{/podDocumentationURL}}
s.source_files = '{{projectName}}/Classes/Swaggers/**/*.swift'{{#usePromiseKit}}
s.dependency 'PromiseKit', '~> 2.1'{{/usePromiseKit}}
- s.dependency 'Alamofire', '~> 2.0.0'
+ s.dependency 'Alamofire', '~> 3.0.0'
end
diff --git a/modules/swagger-codegen/src/main/resources/swift/model.mustache b/modules/swagger-codegen/src/main/resources/swift/model.mustache
index a2510a26dd03..892a3a59f966 100644
--- a/modules/swagger-codegen/src/main/resources/swift/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/model.mustache
@@ -21,6 +21,8 @@ public class {{classname}}: JSONEncodable {
{{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{/isEnum}}
{{/vars}}
+ public init() {}
+
// MARK: JSONEncodable
func encodeToJSON() -> AnyObject {
var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java
new file mode 100644
index 000000000000..8aa497417e91
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java
@@ -0,0 +1,57 @@
+package io.swagger.codegen;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import mockit.FullVerifications;
+import org.apache.commons.lang3.StringUtils;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public abstract class AbstractOptionsTest {
+
+ @Test
+ public void checkOptionsProcessing() {
+ getCodegenConfig().additionalProperties().putAll(getAvaliableOptions());
+ setExpectations();
+
+ getCodegenConfig().processOpts();
+
+ new FullVerifications() {{
+ }};
+ }
+
+ @Test(description = "check if all options described in documentation are presented in test case")
+ public void checkOptionsHelp() {
+ final List cliOptions = Lists.transform(getCodegenConfig().cliOptions(), getCliOptionTransformer());
+ final Set testOptions = getAvaliableOptions().keySet();
+ final Set skipped = new HashSet(cliOptions);
+ skipped.removeAll(testOptions);
+ if (!skipped.isEmpty()) {
+ Assert.fail(String.format("These options weren't checked: %s.", StringUtils.join(skipped, ", ")));
+ }
+ final Set undocumented = new HashSet(testOptions);
+ undocumented.removeAll(cliOptions);
+ if (!undocumented.isEmpty()) {
+ Assert.fail(String.format("These options weren't documented: %s.", StringUtils.join(undocumented, ", ")));
+ }
+ }
+
+ private Function getCliOptionTransformer() {
+ return new Function() {
+ public String apply(CliOption option) {
+ return option.getOpt();
+ }
+ };
+ }
+
+ protected abstract CodegenConfig getCodegenConfig();
+
+ protected abstract void setExpectations();
+
+ protected abstract Map getAvaliableOptions();
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java
index ee70b427bfdf..0fa8953e7bf5 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java
@@ -139,4 +139,52 @@ public class CodegenTest {
Assert.assertTrue(op.bodyParam.isBinary);
Assert.assertTrue(op.responses.get(0).isBinary);
}
+
+ @Test(description = "use operation consumes and produces")
+ public void localConsumesAndProducesTest() {
+ final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
+ final DefaultCodegen codegen = new DefaultCodegen();
+ final String path = "/tests/localConsumesAndProduces";
+ final Operation p = model.getPaths().get(path).getGet();
+ CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model);
+
+ Assert.assertTrue(op.hasConsumes);
+ Assert.assertEquals(op.consumes.size(), 1);
+ Assert.assertEquals(op.consumes.get(0).get("mediaType"), "application/json");
+ Assert.assertTrue(op.hasProduces);
+ Assert.assertEquals(op.produces.size(), 1);
+ Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/json");
+ }
+
+ @Test(description = "use spec consumes and produces")
+ public void globalConsumesAndProducesTest() {
+ final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
+ final DefaultCodegen codegen = new DefaultCodegen();
+ final String path = "/tests/globalConsumesAndProduces";
+ final Operation p = model.getPaths().get(path).getGet();
+ CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model);
+
+ Assert.assertTrue(op.hasConsumes);
+ Assert.assertEquals(op.consumes.size(), 1);
+ Assert.assertEquals(op.consumes.get(0).get("mediaType"), "application/global_consumes");
+ Assert.assertTrue(op.hasProduces);
+ Assert.assertEquals(op.produces.size(), 1);
+ Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/global_produces");
+ }
+
+ @Test(description = "use operation consumes and produces (reset in operation with empty array)")
+ public void localResetConsumesAndProducesTest() {
+ final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
+ final DefaultCodegen codegen = new DefaultCodegen();
+ final String path = "/tests/localResetConsumesAndProduces";
+ final Operation p = model.getPaths().get(path).getGet();
+ CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model);
+
+ Assert.assertNotNull(op);
+ Assert.assertFalse(op.hasConsumes);
+ Assert.assertNull(op.consumes);
+ Assert.assertFalse(op.hasProduces);
+ Assert.assertNull(op.produces);
+
+ }
}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java
new file mode 100644
index 000000000000..fa1bf8bab401
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java
@@ -0,0 +1,301 @@
+package io.swagger.codegen;
+
+
+import io.swagger.models.*;
+import io.swagger.models.parameters.BodyParameter;
+import io.swagger.models.parameters.Parameter;
+import io.swagger.models.properties.*;
+import io.swagger.util.Json;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+
+import static org.testng.AssertJUnit.*;
+
+public class InlineModelResolverTest {
+ @Test
+ public void resolveInlineModelTest() throws Exception {
+ Swagger swagger = new Swagger();
+
+ swagger.addDefinition("User", new ModelImpl()
+ .name("user")
+ .description("a common user")
+ .property("name", new StringProperty())
+ .property("address", new ObjectProperty()
+ .title("title")
+ ._default("default")
+ .access("access")
+ .readOnly(false)
+ .required(true)
+ .description("description")
+ .name("name")
+ .property("street", new StringProperty())
+ .property("city", new StringProperty())));
+
+ new InlineModelResolver().flatten(swagger);
+
+ ModelImpl user = (ModelImpl)swagger.getDefinitions().get("User");
+
+ assertNotNull(user);
+ assertTrue(user.getProperties().get("address") instanceof RefProperty);
+
+ ModelImpl address = (ModelImpl)swagger.getDefinitions().get("User_address");
+ assertNotNull(address);
+ assertNotNull(address.getProperties().get("city"));
+ assertNotNull(address.getProperties().get("street"));
+ }
+
+ @Test
+ public void testInlineResponseModel() throws Exception {
+ Swagger swagger = new Swagger();
+
+ swagger.path("/foo/bar", new Path()
+ .get(new Operation()
+ .response(200, new Response()
+ .description("it works!")
+ .schema(new ObjectProperty()
+ .property("name", new StringProperty())))))
+ .path("/foo/baz", new Path()
+ .get(new Operation()
+ .response(200, new Response()
+ .vendorExtension("x-foo", "bar")
+ .description("it works!")
+ .schema(new ObjectProperty()
+ .property("name", new StringProperty())))));
+ new InlineModelResolver().flatten(swagger);
+
+ Map responses = swagger.getPaths().get("/foo/bar").getGet().getResponses();
+
+ Response response = responses.get("200");
+ assertNotNull(response);
+ assertTrue(response.getSchema() instanceof RefProperty);
+
+ ModelImpl model = (ModelImpl)swagger.getDefinitions().get("inline_response_200");
+ assertTrue(model.getProperties().size() == 1);
+ assertNotNull(model.getProperties().get("name"));
+ }
+
+ @Test
+ public void resolveInlineArrayModel() throws Exception {
+ Swagger swagger = new Swagger();
+
+ swagger.addDefinition("User", new ArrayModel()
+ .items(new ObjectProperty()
+ .title("title")
+ ._default("default")
+ .access("access")
+ .readOnly(false)
+ .required(true)
+ .description("description")
+ .name("name")
+ .property("street", new StringProperty())
+ .property("city", new StringProperty())));
+
+ new InlineModelResolver().flatten(swagger);
+
+ Model model = swagger.getDefinitions().get("User");
+ assertTrue(model instanceof ArrayModel);
+
+ Model user = swagger.getDefinitions().get("User_inner");
+ assertNotNull(user);
+ assertEquals("description", user.getDescription());
+ }
+
+ @Test
+ public void resolveInlineBodyParameter() throws Exception {
+ Swagger swagger = new Swagger();
+
+ swagger.path("/hello", new Path()
+ .get(new Operation()
+ .parameter(new BodyParameter()
+ .name("body")
+ .schema(new ModelImpl()
+ .property("address", new ObjectProperty()
+ .property("street", new StringProperty()))
+ .property("name", new StringProperty())))));
+
+ new InlineModelResolver().flatten(swagger);
+
+ Operation operation = swagger.getPaths().get("/hello").getGet();
+ BodyParameter bp = (BodyParameter)operation.getParameters().get(0);
+ assertTrue(bp.getSchema() instanceof RefModel);
+
+ Model body = swagger.getDefinitions().get("body");
+ assertTrue(body instanceof ModelImpl);
+
+ ModelImpl impl = (ModelImpl) body;
+ assertNotNull(impl.getProperties().get("address"));
+ }
+
+ @Test
+ public void resolveInlineArrayBodyParameter() throws Exception {
+ Swagger swagger = new Swagger();
+
+ swagger.path("/hello", new Path()
+ .get(new Operation()
+ .parameter(new BodyParameter()
+ .name("body")
+ .schema(new ArrayModel()
+ .items(new ObjectProperty()
+ .property("address", new ObjectProperty()
+ .property("street", new StringProperty())))))));
+
+ new InlineModelResolver().flatten(swagger);
+
+ Parameter param = swagger.getPaths().get("/hello").getGet().getParameters().get(0);
+ assertTrue(param instanceof BodyParameter);
+
+ BodyParameter bp = (BodyParameter) param;
+ Model schema = bp.getSchema();
+
+ assertTrue(schema instanceof ArrayModel);
+
+ ArrayModel am = (ArrayModel) schema;
+ Property inner = am.getItems();
+
+ ObjectProperty op = (ObjectProperty) inner;
+ Property name = op.getProperties().get("address");
+ assertTrue(name instanceof RefProperty);
+
+ Model model = swagger.getDefinitions().get("hello_address");
+ assertNotNull(model);
+ }
+
+ @Test
+ public void resolveInlineArrayResponse() throws Exception {
+ Swagger swagger = new Swagger();
+
+ swagger.path("/foo/baz", new Path()
+ .get(new Operation()
+ .response(200, new Response()
+ .vendorExtension("x-foo", "bar")
+ .description("it works!")
+ .schema(new ArrayProperty()
+ .items(
+ new ObjectProperty()
+ .property("name", new StringProperty()))))));
+
+ new InlineModelResolver().flatten(swagger);
+
+ Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200");
+ assertNotNull(response);
+
+ assertNotNull(response.getSchema());
+ Property responseProperty = response.getSchema();
+
+ // no need to flatten more
+ assertTrue(responseProperty instanceof ArrayProperty);
+
+ ArrayProperty ap = (ArrayProperty) responseProperty;
+ Property p = ap.getItems();
+
+ assertNotNull(p);
+
+ ObjectProperty innerModel = (ObjectProperty) p;
+ assertTrue(innerModel.getProperties().size() == 1);
+ assertNotNull(innerModel.getProperties().get("name"));
+ }
+
+ @Test
+ public void testInlineMapResponse() throws Exception {
+ Swagger swagger = new Swagger();
+
+ MapProperty schema = new MapProperty();
+ schema.setAdditionalProperties(new StringProperty());
+
+ swagger.path("/foo/baz", new Path()
+ .get(new Operation()
+ .response(200, new Response()
+ .vendorExtension("x-foo", "bar")
+ .description("it works!")
+ .schema(schema))));
+ new InlineModelResolver().flatten(swagger);
+ Json.prettyPrint(swagger);
+
+ Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200");
+
+ Property property = response.getSchema();
+ assertTrue(property instanceof MapProperty);
+ assertTrue(swagger.getDefinitions().size() == 0);
+ }
+
+ @Test
+ public void testInlineMapResponseWithObjectProperty() throws Exception {
+ Swagger swagger = new Swagger();
+
+ MapProperty schema = new MapProperty();
+ schema.setAdditionalProperties(new ObjectProperty()
+ .property("name", new StringProperty()));
+
+ swagger.path("/foo/baz", new Path()
+ .get(new Operation()
+ .response(200, new Response()
+ .vendorExtension("x-foo", "bar")
+ .description("it works!")
+ .schema(schema))));
+ new InlineModelResolver().flatten(swagger);
+
+ Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200");
+
+ Property property = response.getSchema();
+ assertTrue(property instanceof RefProperty);
+
+ Model inline = swagger.getDefinitions().get("inline_response_200");
+ assertTrue(inline instanceof ModelImpl);
+ ModelImpl impl = (ModelImpl) inline;
+
+ Property innerProperty = impl.getAdditionalProperties();
+ assertTrue(innerProperty instanceof ObjectProperty);
+
+ ObjectProperty obj = (ObjectProperty) innerProperty;
+ Property name = obj.getProperties().get("name");
+ assertTrue(name instanceof StringProperty);
+ }
+
+ @Test
+ public void testArrayResponse() {
+ Swagger swagger = new Swagger();
+
+ ArrayProperty schema = new ArrayProperty();
+ schema.setItems(new ObjectProperty()
+ .property("name", new StringProperty()));
+
+ swagger.path("/foo/baz", new Path()
+ .get(new Operation()
+ .response(200, new Response()
+ .vendorExtension("x-foo", "bar")
+ .description("it works!")
+ .schema(schema))));
+ new InlineModelResolver().flatten(swagger);
+
+ Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200");
+ assertTrue(response.getSchema() instanceof ArrayProperty);
+
+ ArrayProperty am = (ArrayProperty) response.getSchema();
+ Property items = am.getItems();
+ assertTrue(items instanceof ObjectProperty);
+ ObjectProperty op = (ObjectProperty) items;
+ Property name = op.getProperties().get("name");
+ assertTrue(name instanceof StringProperty);
+ }
+
+ @Test
+ public void testBasicInput() {
+ Swagger swagger = new Swagger();
+
+ ModelImpl user = new ModelImpl()
+ .property("name", new StringProperty());
+
+ swagger.path("/foo/baz", new Path()
+ .post(new Operation()
+ .parameter(new BodyParameter()
+ .name("myBody")
+ .schema(new RefModel("User")))));
+
+ swagger.addDefinition("User", user);
+
+ new InlineModelResolver().flatten(swagger);
+
+ Json.prettyPrint(swagger);
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java
new file mode 100644
index 000000000000..4ea24aeca987
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/android/AndroidClientOptionsTest.java
@@ -0,0 +1,71 @@
+package io.swagger.codegen.android;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.AndroidClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class AndroidClientOptionsTest extends AbstractOptionsTest {
+ protected static final String ARTIFACT_ID_VALUE = "swagger-java-client-test";
+ protected static final String MODEL_PACKAGE_VALUE = "package";
+ protected static final String API_PACKAGE_VALUE = "apiPackage";
+ protected static final String INVOKER_PACKAGE_VALUE = "io.swagger.client.test";
+ protected static final String SORT_PARAMS_VALUE = "false";
+ protected static final String GROUP_ID_VALUE = "io.swagger.test";
+ protected static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
+ protected static final String SOURCE_FOLDER_VALUE = "src/main/java/test";
+ protected static final String ANDROID_MAVEN_GRADLE_PLUGIN_VALUE = "true";
+
+ @Tested
+ private AndroidClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setApiPackage(API_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
+ times = 1;
+ clientCodegen.setInvokerPackage(INVOKER_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setGroupId(GROUP_ID_VALUE);
+ times = 1;
+ clientCodegen.setArtifactId(ARTIFACT_ID_VALUE);
+ times = 1;
+ clientCodegen.setArtifactVersion(ARTIFACT_VERSION_VALUE);
+ times = 1;
+ clientCodegen.setSourceFolder(SOURCE_FOLDER_VALUE);
+ times = 1;
+ clientCodegen.setUseAndroidMavenGradlePlugin(Boolean.valueOf(ANDROID_MAVEN_GRADLE_PLUGIN_VALUE));
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
+ .put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
+ .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
+ .put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
+ .put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE)
+ .put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE)
+ .put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
+ .put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
+ .put(AndroidClientCodegen.USE_ANDROID_MAVEN_GRADLE_PLUGIN, ANDROID_MAVEN_GRADLE_PLUGIN_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java
new file mode 100644
index 000000000000..5a64e676dcbe
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java
@@ -0,0 +1,43 @@
+package io.swagger.codegen.csharp;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.CSharpClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class CSharpClientOptionsTest extends AbstractOptionsTest {
+ protected static final String PACKAGE_NAME_VALUE = "swagger_client_csharp";
+ protected static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
+
+ @Tested
+ private CSharpClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setPackageName(PACKAGE_NAME_VALUE);
+ times = 1;
+ clientCodegen.setPackageVersion(PACKAGE_VERSION_VALUE);
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
+ .put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharpdotnettwo/CsharpDotNet2ClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharpdotnettwo/CsharpDotNet2ClientOptionsTest.java
new file mode 100644
index 000000000000..d9455103576c
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharpdotnettwo/CsharpDotNet2ClientOptionsTest.java
@@ -0,0 +1,47 @@
+package io.swagger.codegen.csharpdotnettwo;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.CsharpDotNet2ClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class CsharpDotNet2ClientOptionsTest extends AbstractOptionsTest {
+ protected static final String PACKAGE_NAME_VALUE = "swagger_client_csharp_dotnet";
+ protected static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
+ protected static final String CLIENT_PACKAGE_VALUE = "IO.Swagger.Client.Test";
+
+ @Tested
+ private CsharpDotNet2ClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setPackageName(PACKAGE_NAME_VALUE);
+ times = 1;
+ clientCodegen.setPackageVersion(PACKAGE_VERSION_VALUE);
+ times = 1;
+ clientCodegen.setClientPackage(CLIENT_PACKAGE_VALUE);
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
+ .put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
+ .put(CsharpDotNet2ClientCodegen.CLIENT_PACKAGE, CLIENT_PACKAGE_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientOptionsTest.java
new file mode 100644
index 000000000000..6a63754d6465
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientOptionsTest.java
@@ -0,0 +1,68 @@
+package io.swagger.codegen.dart;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.DartClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class DartClientOptionsTest extends AbstractOptionsTest {
+ protected static final String MODEL_PACKAGE_VALUE = "packagedart";
+ protected static final String API_PACKAGE_VALUE = "apiPackageDart";
+ protected static final String SORT_PARAMS_VALUE = "false";
+ protected static final String BROWSER_CLIENT_VALUE = "true";
+ protected static final String PUB_NAME_VALUE = "swagger";
+ protected static final String PUB_VERSION_VALUE = "1.0.0-SNAPSHOT";
+ protected static final String PUB_DESCRIPTION_VALUE = "Swagger API client dart";
+ protected static final String SOURCE_FOLDER_VALUE = "src";
+
+ @Tested
+ private DartClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setApiPackage(API_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
+ times = 1;
+ clientCodegen.setBrowserClient(Boolean.valueOf(BROWSER_CLIENT_VALUE));
+ times = 1;
+ clientCodegen.setPubName(PUB_NAME_VALUE);
+ times = 1;
+ clientCodegen.setPubVersion(PUB_VERSION_VALUE);
+ times = 1;
+ clientCodegen.setPubDescription(PUB_DESCRIPTION_VALUE);
+ times = 1;
+ clientCodegen.setSourceFolder(SOURCE_FOLDER_VALUE);
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
+ .put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
+ .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
+ .put(DartClientCodegen.BROWSER_CLIENT, BROWSER_CLIENT_VALUE)
+ .put(DartClientCodegen.PUB_NAME, PUB_NAME_VALUE)
+ .put(DartClientCodegen.PUB_VERSION, PUB_VERSION_VALUE)
+ .put(DartClientCodegen.PUB_DESCRIPTION, PUB_DESCRIPTION_VALUE)
+ .put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
+ .build();
+ }
+}
+
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java
new file mode 100644
index 000000000000..75a9df65e405
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java
@@ -0,0 +1,51 @@
+package io.swagger.codegen.flash;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.FlashClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class FlashClienOptionsTest extends AbstractOptionsTest {
+ protected static final String PACKAGE_NAME_VALUE = "io.swagger.flash";
+ protected static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
+ protected static final String INVOKER_PACKAGE_VALUE = "io.swagger.flash";
+ protected static final String SOURCE_FOLDER_VALUE = "src/main/flex/test";
+
+ @Tested
+ private FlashClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setPackageName(PACKAGE_NAME_VALUE);
+ times = 1;
+ clientCodegen.setPackageVersion(PACKAGE_VERSION_VALUE);
+ times = 1;
+ clientCodegen.setInvokerPackage(INVOKER_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setSourceFolder(SOURCE_FOLDER_VALUE);
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
+ .put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
+ .put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
+ .put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java
new file mode 100644
index 000000000000..9cdac7d394bf
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java
@@ -0,0 +1,84 @@
+package io.swagger.codegen.java;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.JavaClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class JavaClientOptionsTest extends AbstractOptionsTest {
+
+ protected static final String ARTIFACT_ID_VALUE = "swagger-java-client-test";
+ protected static final String MODEL_PACKAGE_VALUE = "package";
+ protected static final String API_PACKAGE_VALUE = "apiPackage";
+ protected static final String INVOKER_PACKAGE_VALUE = "io.swagger.client.test";
+ protected static final String SORT_PARAMS_VALUE = "false";
+ protected static final String GROUP_ID_VALUE = "io.swagger.test";
+ protected static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
+ protected static final String SOURCE_FOLDER_VALUE = "src/main/java/test";
+ protected static final String LOCAL_PREFIX_VALUE = "tst";
+ protected static final String LIBRARY_VALUE = "jersey2";
+ protected static final String SERIALIZABLE_MODEL_VALUE = "false";
+ protected static final String FULL_JAVA_UTIL_VALUE = "true";
+
+ @Tested
+ private JavaClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setApiPackage(API_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
+ times = 1;
+ clientCodegen.setInvokerPackage(INVOKER_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setGroupId(GROUP_ID_VALUE);
+ times = 1;
+ clientCodegen.setArtifactId(ARTIFACT_ID_VALUE);
+ times = 1;
+ clientCodegen.setArtifactVersion(ARTIFACT_VERSION_VALUE);
+ times = 1;
+ clientCodegen.setSourceFolder(SOURCE_FOLDER_VALUE);
+ times = 1;
+ clientCodegen.setLocalVariablePrefix(LOCAL_PREFIX_VALUE);
+ times = 1;
+ clientCodegen.setSerializableModel(Boolean.valueOf(SERIALIZABLE_MODEL_VALUE));
+ times = 1;
+ clientCodegen.setLibrary(LIBRARY_VALUE);
+ times = 1;
+ clientCodegen.setFullJavaUtil(Boolean.valueOf(FULL_JAVA_UTIL_VALUE));
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
+ .put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
+ .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
+ .put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
+ .put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE)
+ .put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE)
+ .put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
+ .put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
+ .put(CodegenConstants.LOCAL_VARIABLE_PREFIX, LOCAL_PREFIX_VALUE)
+ .put(CodegenConstants.SERIALIZABLE_MODEL, SERIALIZABLE_MODEL_VALUE)
+ .put(JavaClientCodegen.FULL_JAVA_UTIL, FULL_JAVA_UTIL_VALUE)
+ .put(CodegenConstants.LIBRARY, LIBRARY_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/jaxrs/AllowableValuesTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/jaxrs/AllowableValuesTest.java
new file mode 100644
index 000000000000..ef24287b0051
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/jaxrs/AllowableValuesTest.java
@@ -0,0 +1,64 @@
+package io.swagger.codegen.java.jaxrs;
+
+import io.swagger.codegen.CodegenParameter;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.samskivert.mustache.Mustache;
+import com.samskivert.mustache.Template;
+import org.apache.commons.io.IOUtils;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+
+public class AllowableValuesTest {
+
+ private static final String TEMPLATE_FILE = "JavaJaxRS/allowableValues.mustache";
+ private static final String PROVIDER_NAME = "operations";
+
+ private static String loadClassResource(Class> cls, String name) throws IOException {
+ InputStream in = null;
+ try {
+ in = cls.getClassLoader().getResourceAsStream(name);
+ return IOUtils.toString(in, StandardCharsets.UTF_8);
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+ }
+
+ @DataProvider(name = PROVIDER_NAME)
+ private Object[][] resource() {
+ final CodegenParameter param1 = new CodegenParameter();
+ final CodegenParameter param2 = new CodegenParameter() {{
+ allowableValues = ImmutableMap.of("values", ImmutableList.of("item1", "item2", "item3"));
+ }};
+ final CodegenParameter param3 = new CodegenParameter() {{
+ allowableValues = ImmutableMap.of("min", 1, "max", 10);
+ }};
+ final CodegenParameter param4 = new CodegenParameter() {{
+ allowableValues = ImmutableMap.of("min", 1);
+ }};
+ final CodegenParameter param5 = new CodegenParameter() {{
+ allowableValues = ImmutableMap.of("max", 10);
+ }};
+
+ return new Object[][]{
+ {param1, ""},
+ {param2, "allowableValues=\"item1, item2, item3\""},
+ {param3, "allowableValues=\"range=[1, 10]\""},
+ {param4, "allowableValues=\"range=[1, infinity]\""},
+ {param5, "allowableValues=\"range=[-infinity, 10]\""},
+ };
+ }
+
+ @Test(dataProvider = PROVIDER_NAME)
+ public void annotationsTest(CodegenParameter parameter, String expected) throws IOException {
+ final Template template = Mustache.compiler().compile(loadClassResource(this.getClass(), TEMPLATE_FILE));
+
+ Assert.assertEquals(template.execute(parameter), expected);
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java
new file mode 100644
index 000000000000..00f09ad036bc
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java
@@ -0,0 +1,49 @@
+package io.swagger.codegen.jaxrs;
+
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.java.JavaClientOptionsTest;
+import io.swagger.codegen.languages.JaxRSServerCodegen;
+
+import mockit.Expectations;
+import mockit.Tested;
+
+public class JaxRSServerOptionsTest extends JavaClientOptionsTest {
+
+ @Tested
+ private JaxRSServerCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setApiPackage(API_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
+ times = 1;
+ clientCodegen.setInvokerPackage(INVOKER_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setGroupId(GROUP_ID_VALUE);
+ times = 1;
+ clientCodegen.setArtifactId(ARTIFACT_ID_VALUE);
+ times = 1;
+ clientCodegen.setArtifactVersion(ARTIFACT_VERSION_VALUE);
+ times = 1;
+ clientCodegen.setSourceFolder(SOURCE_FOLDER_VALUE);
+ times = 1;
+ clientCodegen.setLocalVariablePrefix(LOCAL_PREFIX_VALUE);
+ times = 1;
+ clientCodegen.setSerializableModel(Boolean.valueOf(SERIALIZABLE_MODEL_VALUE));
+ times = 1;
+ clientCodegen.setLibrary(LIBRARY_VALUE);
+ times = 1;
+ clientCodegen.setFullJavaUtil(Boolean.valueOf(FULL_JAVA_UTIL_VALUE));
+ times = 1;
+ }};
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/SwiftCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/SwiftCodegenTest.java
new file mode 100644
index 000000000000..acede31f7361
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/SwiftCodegenTest.java
@@ -0,0 +1,45 @@
+package io.swagger.codegen.languages;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class SwiftCodegenTest {
+
+ SwiftCodegen swiftCodegen = new SwiftCodegen();
+
+ @Test
+ public void shouldNotBreakCorrectName() throws Exception {
+ Assert.assertEquals(swiftCodegen.toSwiftyEnumName("EntryName"), "EntryName");
+ }
+
+ @Test
+ public void testSingleWordAllCaps() throws Exception {
+ Assert.assertEquals(swiftCodegen.toSwiftyEnumName("VALUE"), "Value");
+ }
+
+ @Test
+ public void testSingleWordLowercase() throws Exception {
+ Assert.assertEquals(swiftCodegen.toSwiftyEnumName("value"), "Value");
+ }
+
+ @Test
+ public void testCapitalsWithUnderscore() throws Exception {
+ Assert.assertEquals(swiftCodegen.toSwiftyEnumName("ENTRY_NAME"), "EntryName");
+ }
+
+ @Test
+ public void testCapitalsWithDash() throws Exception {
+ Assert.assertEquals(swiftCodegen.toSwiftyEnumName("ENTRY-NAME"), "EntryName");
+ }
+
+ @Test
+ public void testCapitalsWithSpace() throws Exception {
+ Assert.assertEquals(swiftCodegen.toSwiftyEnumName("ENTRY NAME"), "EntryName");
+ }
+
+ @Test
+ public void testLowercaseWithUnderscore() throws Exception {
+ Assert.assertEquals(swiftCodegen.toSwiftyEnumName("entry_name"), "EntryName");
+ }
+
+}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/nodejs/NodeJSServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/nodejs/NodeJSServerOptionsTest.java
new file mode 100644
index 000000000000..5ad3eb33f2a0
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/nodejs/NodeJSServerOptionsTest.java
@@ -0,0 +1,48 @@
+package io.swagger.codegen.nodejs;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.JavaClientCodegen;
+import io.swagger.codegen.languages.NodeJSServerCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class NodeJSServerOptionsTest extends AbstractOptionsTest {
+ private static final String MODEL_PACKAGE_VALUE = "package";
+ private static final String API_PACKAGE_VALUE = "apiPackage";
+ private static final String SORT_PARAMS_VALUE = "false";
+
+ @Tested
+ private NodeJSServerCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setApiPackage(API_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
+ .put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
+ .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java
new file mode 100644
index 000000000000..413ee5380537
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientOptionsTest.java
@@ -0,0 +1,75 @@
+package io.swagger.codegen.php;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.PhpClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class PhpClientOptionsTest extends AbstractOptionsTest {
+ protected static final String MODEL_PACKAGE_VALUE = "package";
+ protected static final String API_PACKAGE_VALUE = "apiPackage";
+ protected static final String SORT_PARAMS_VALUE = "false";
+ protected static final String VARIABLE_NAMING_CONVENTION_VALUE = "snake_case";
+ protected static final String INVOKER_PACKAGE_VALUE = "Swagger\\Client\\Php";
+ protected static final String PACKAGE_PATH_VALUE = "SwaggerClient-php";
+ protected static final String SRC_BASE_PATH_VALUE = "libPhp";
+ protected static final String COMPOSER_VENDOR_NAME_VALUE = "swaggerPhp";
+ protected static final String COMPOSER_PROJECT_NAME_VALUE = "swagger-client-php";
+ protected static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
+
+ @Tested
+ private PhpClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setModelPackage(MODEL_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setApiPackage(API_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(SORT_PARAMS_VALUE));
+ times = 1;
+ clientCodegen.setParameterNamingConvention(VARIABLE_NAMING_CONVENTION_VALUE);
+ times = 1;
+ clientCodegen.setInvokerPackage(INVOKER_PACKAGE_VALUE);
+ times = 1;
+ clientCodegen.setPackagePath(PACKAGE_PATH_VALUE);
+ times = 1;
+ clientCodegen.setSrcBasePath(SRC_BASE_PATH_VALUE);
+ times = 1;
+ clientCodegen.setComposerVendorName(COMPOSER_VENDOR_NAME_VALUE);
+ times = 1;
+ clientCodegen.setComposerProjectName(COMPOSER_PROJECT_NAME_VALUE);
+ times = 1;
+ clientCodegen.setArtifactVersion(ARTIFACT_VERSION_VALUE);
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
+ .put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
+ .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
+ .put(PhpClientCodegen.VARIABLE_NAMING_CONVENTION, VARIABLE_NAMING_CONVENTION_VALUE)
+ .put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
+ .put(PhpClientCodegen.PACKAGE_PATH, PACKAGE_PATH_VALUE)
+ .put(PhpClientCodegen.SRC_BASE_PATH, SRC_BASE_PATH_VALUE)
+ .put(PhpClientCodegen.COMPOSER_VENDOR_NAME, COMPOSER_VENDOR_NAME_VALUE)
+ .put(PhpClientCodegen.COMPOSER_PROJECT_NAME, COMPOSER_PROJECT_NAME_VALUE)
+ .put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientOptionsTest.java
new file mode 100644
index 000000000000..645471789e81
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientOptionsTest.java
@@ -0,0 +1,43 @@
+package io.swagger.codegen.python;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.PythonClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class PythonClientOptionsTest extends AbstractOptionsTest {
+ protected static final String PACKAGE_NAME_VALUE = "swagger_client_python";
+ protected static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
+
+ @Tested
+ private PythonClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setPackageName(PACKAGE_NAME_VALUE);
+ times = 1;
+ clientCodegen.setPackageVersion(PACKAGE_VERSION_VALUE);
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
+ .put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientOptionsTest.java
new file mode 100644
index 000000000000..ca2ea19a2d9e
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientOptionsTest.java
@@ -0,0 +1,46 @@
+package io.swagger.codegen.ruby;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.languages.RubyClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+import mockit.Expectations;
+import mockit.Tested;
+
+import java.util.Map;
+
+public class RubyClientOptionsTest extends AbstractOptionsTest {
+ private static final String GEM_NAME_VALUE = "swagger_client_ruby";
+ private static final String MODULE_NAME_VALUE = "SwaggerClientRuby";
+ private static final String GEM_VERSION_VALUE = "1.0.0-SNAPSHOT";
+
+ @Tested
+ private RubyClientCodegen clientCodegen;
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setGemName(GEM_NAME_VALUE);
+ times = 1;
+ clientCodegen.setModuleName(MODULE_NAME_VALUE);
+ times = 1;
+ clientCodegen.setGemVersion(GEM_VERSION_VALUE);
+ times = 1;
+ }};
+ }
+
+ @Override
+ protected Map getAvaliableOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put(RubyClientCodegen.GEM_NAME, GEM_NAME_VALUE)
+ .put(RubyClientCodegen.MODULE_NAME, MODULE_NAME_VALUE)
+ .put(RubyClientCodegen.GEM_VERSION, GEM_VERSION_VALUE)
+ .build();
+ }
+}
diff --git a/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json b/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json
new file mode 100644
index 000000000000..520218ed707e
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json
@@ -0,0 +1,130 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "description": "Spec for testing global consumes and produces",
+ "version": "1.0.0",
+ "title": "Swagger Petstore",
+ "termsOfService": "http://swagger.io/terms/",
+ "contact": {
+ "email": "apiteam@swagger.io"
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
+ }
+ },
+ "host": "petstore.swagger.io",
+ "basePath": "/v2",
+ "consumes": ["application/global_consumes"],
+ "produces": ["application/global_produces"],
+ "schemes": [
+ "http"
+ ],
+ "paths": {
+ "/tests/localConsumesAndProduces": {
+ "get": {
+ "tags": [
+ "tests"
+ ],
+ "summary": "Operation with local consumes and produces",
+ "description": "",
+ "operationId": "localConsumesAndProduces",
+ "produces": [
+ "application/json"
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "parameters": [
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation. Returning a simple int.",
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ }
+ }
+ }
+ },
+ "/tests/globalConsumesAndProduces": {
+ "get": {
+ "tags": [
+ "tests"
+ ],
+ "summary": "Operation with global consumes and produces",
+ "description": "",
+ "operationId": "globalConsumesAndProduces",
+ "parameters": [
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation. Returning a simple int.",
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ }
+ }
+ }
+ },
+ "/tests/localResetConsumesAndProduces": {
+ "get": {
+ "tags": [
+ "tests"
+ ],
+ "summary": "Operation with local consumes and produces set to empty (reset)",
+ "description": "",
+ "operationId": "localResetConsumesAndProduces",
+ "parameters": [
+ ],
+ "consumes": [],
+ "produces": [],
+ "responses": {
+ "200": {
+ "description": "successful operation. Returning a simple int.",
+ "schema": {
+ "type": "integer",
+ "format": "int64"
+ }
+ }
+ }
+ }
+ }
+
+ },
+ "securityDefinitions": {
+ "api_key": {
+ "type": "apiKey",
+ "name": "api_key",
+ "in": "header"
+ },
+ "petstore_auth": {
+ "type": "oauth2",
+ "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog",
+ "flow": "implicit",
+ "scopes": {
+ "write:pets": "modify pets in your account",
+ "read:pets": "read your pets"
+ }
+ }
+ },
+ "definitions": {
+ "CustomModel": {
+ "required": [
+ "id"
+ ],
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "name": {
+ "type": "string",
+ "example": "doggie"
+ }
+ }
+ }
+ }
+}
diff --git a/modules/swagger-codegen/src/test/resources/2_0/wordnik.yaml b/modules/swagger-codegen/src/test/resources/2_0/wordnik.yaml
new file mode 100644
index 000000000000..5d46e5a8b7e0
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/2_0/wordnik.yaml
@@ -0,0 +1,1643 @@
+swagger: '2.0'
+
+info:
+ version: 4.0.1
+ title: The Wordnik Public API
+ description: "**Wordnik has an API, and you're invited.**\nThe Wordnik API lets you request definitions, example sentences, spelling suggestions, \nrelated words like synonyms and antonyms, phrases containing a given word, word \nautocompletion, random words, words of the day, and much more\n"
+ contact:
+ url: 'http://developer.wordnik.com/'
+ email: apiteam@wordnik.com
+ name: Wordnik API Team
+
+schemes:
+ - https
+host: api.wordnik.com
+basePath: /v4
+
+securityDefinitions:
+ apiKey:
+ type: apiKey
+ in: header
+ name: api_key
+security:
+ - apiKey: []
+paths:
+ /words.json/randomWord:
+ get:
+ tags:
+ - words
+ summary: Returns a single random WordObject
+ operationId: getRandomWord
+ parameters:
+ - name: hasDictionaryDef
+ in: query
+ description: Only return words with dictionary definitions
+ required: false
+ type: string
+ - name: includePartOfSpeech
+ in: query
+ description: CSV part-of-speech values to include
+ required: false
+ type: string
+ - name: excludePartOfSpeech
+ in: query
+ description: CSV part-of-speech values to exclude
+ required: false
+ type: string
+ - name: minCorpusCount
+ in: query
+ description: Minimum corpus frequency for terms
+ required: false
+ type: integer
+ format: int32
+ - name: maxCorpusCount
+ in: query
+ description: Maximum corpus frequency for terms
+ required: false
+ type: integer
+ format: int32
+ - name: minDictionaryCount
+ in: query
+ description: Minimum dictionary count
+ required: false
+ type: integer
+ format: int32
+ - name: maxDictionaryCount
+ in: query
+ description: Maximum dictionary count
+ required: false
+ type: integer
+ format: int32
+ - name: minLength
+ in: query
+ description: Minimum word length
+ required: false
+ type: integer
+ format: int32
+ - name: maxLength
+ in: query
+ description: Maximum word length
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/WordObject'
+ '404':
+ description: No word found.
+ /account.json/user:
+ get:
+ tags:
+ - account
+ summary: Returns the logged-in User
+ description: Requires a valid auth_token to be set.
+ operationId: getLoggedInUser
+ parameters:
+ - name: auth_token
+ in: header
+ description: 'The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)'
+ required: true
+ type: string
+ responses:
+ '200':
+ description: The logged-in user
+ schema:
+ $ref: '#/definitions/User'
+ '403':
+ description: Not logged in.
+ '404':
+ description: User not found.
+ '/word.json/{word}/pronunciations':
+ get:
+ tags:
+ - word
+ summary: Returns text pronunciations for a given word
+ operationId: getTextPronunciations
+ parameters:
+ - name: word
+ in: path
+ description: Word to get pronunciations for
+ required: true
+ type: string
+ - name: useCanonical
+ in: query
+ description: "If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ - name: sourceDictionary
+ in: query
+ description: Get from a single dictionary
+ required: false
+ type: string
+ - name: typeFormat
+ in: query
+ description: Text pronunciation type
+ required: false
+ type: string
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/TextPron'
+ '400':
+ description: Invalid word supplied.
+ '/word.json/{word}/relatedWords':
+ get:
+ tags:
+ - word
+ summary: 'Given a word as a string, returns relationships from the Word Graph'
+ operationId: getRelatedWords
+ parameters:
+ - name: word
+ in: path
+ description: Word to fetch relationships for
+ required: true
+ type: string
+ - name: useCanonical
+ in: query
+ description: "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ - name: relationshipTypes
+ in: query
+ description: Limits the total results per type of relationship type
+ required: false
+ type: string
+ - name: limitPerRelationshipType
+ in: query
+ description: Restrict to the supplied relationship types
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/Related'
+ '400':
+ description: Invalid word supplied.
+ /words.json/reverseDictionary:
+ get:
+ tags:
+ - words
+ summary: Reverse dictionary search
+ operationId: reverseDictionary
+ parameters:
+ - name: query
+ in: query
+ description: Search term
+ required: true
+ type: string
+ - name: findSenseForWord
+ in: query
+ description: Restricts words and finds closest sense
+ required: false
+ type: string
+ - name: includeSourceDictionaries
+ in: query
+ description: Only include these comma-delimited source dictionaries
+ required: false
+ type: string
+ - name: excludeSourceDictionaries
+ in: query
+ description: Exclude these comma-delimited source dictionaries
+ required: false
+ type: string
+ - name: includePartOfSpeech
+ in: query
+ description: Only include these comma-delimited parts of speech
+ required: false
+ type: string
+ - name: excludePartOfSpeech
+ in: query
+ description: Exclude these comma-delimited parts of speech
+ required: false
+ type: string
+ - name: minCorpusCount
+ in: query
+ description: Minimum corpus frequency for terms
+ required: false
+ type: integer
+ format: int32
+ - name: maxCorpusCount
+ in: query
+ description: Maximum corpus frequency for terms
+ required: false
+ type: integer
+ format: int32
+ - name: minLength
+ in: query
+ description: Minimum word length
+ required: false
+ type: integer
+ format: int32
+ - name: maxLength
+ in: query
+ description: Maximum word length
+ required: false
+ type: integer
+ format: int32
+ - name: expandTerms
+ in: query
+ description: Expand terms
+ required: false
+ type: string
+ - name: includeTags
+ in: query
+ description: Return a closed set of XML tags in response
+ required: false
+ type: string
+ - name: sortBy
+ in: query
+ description: Attribute to sort by
+ required: false
+ type: string
+ - name: sortOrder
+ in: query
+ description: Sort direction
+ required: false
+ type: string
+ - name: skip
+ in: query
+ description: Results to skip
+ required: false
+ type: string
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/DefinitionSearchResults'
+ '400':
+ description: Invalid term supplied.
+ /account.json/apiTokenStatus:
+ get:
+ tags:
+ - account
+ summary: Returns usage statistics for the API account.
+ operationId: getApiTokenStatus
+ parameters:
+ - name: api_key
+ in: header
+ description: Wordnik authentication token
+ required: false
+ type: string
+ responses:
+ '200':
+ description: Usage statistics for the supplied API key
+ schema:
+ $ref: '#/definitions/ApiTokenStatus'
+ '400':
+ description: No token supplied.
+ '404':
+ description: No API account with supplied token.
+ '/word.json/{word}':
+ get:
+ tags:
+ - word
+ summary: 'Given a word as a string, returns the WordObject that represents it'
+ operationId: getWord
+ parameters:
+ - name: word
+ in: path
+ description: String value of WordObject to return
+ required: true
+ type: string
+ - name: useCanonical
+ in: query
+ description: "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ - name: includeSuggestions
+ in: query
+ description: 'Return suggestions (for correct spelling, case variants, etc.)'
+ required: false
+ type: string
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/WordObject'
+ '400':
+ description: Invalid word supplied.
+ '/wordList.json/{permalink}/deleteWords':
+ post:
+ tags:
+ - wordList
+ summary: Removes words from a WordList
+ operationId: deleteWordsFromWordList
+ parameters:
+ - name: permalink
+ in: path
+ description: permalink of WordList to use
+ required: true
+ type: string
+ - in: body
+ name: body
+ description: Words to remove from WordList
+ required: false
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/StringValue'
+ - name: auth_token
+ in: header
+ description: 'The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)'
+ required: true
+ type: string
+ responses:
+ '200':
+ description: success
+ '400':
+ description: Invalid permalink supplied
+ '403':
+ description: Not Authorized to modify WordList
+ '404':
+ description: WordList not found
+ '/word.json/{word}/examples':
+ get:
+ tags:
+ - word
+ summary: Returns examples for a word
+ operationId: getExamples
+ parameters:
+ - name: word
+ in: path
+ description: Word to return examples for
+ required: true
+ type: string
+ - name: includeDuplicates
+ in: query
+ description: Show duplicate examples from different sources
+ required: false
+ type: string
+ - name: useCanonical
+ in: query
+ description: "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ - name: skip
+ in: query
+ description: Results to skip
+ required: false
+ type: integer
+ format: int32
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/ExampleSearchResults'
+ '400':
+ description: Invalid word supplied.
+ '400':
+ description: Invalid word supplied.
+ '/account.json/authenticate/{username}':
+ get:
+ tags:
+ - account
+ summary: Authenticates a User
+ operationId: authenticate
+ parameters:
+ - name: username
+ in: path
+ description: A confirmed Wordnik username
+ required: true
+ type: string
+ - name: password
+ in: query
+ description: "The user's password"
+ required: true
+ type: string
+ responses:
+ '200':
+ description: A valid authentication token
+ schema:
+ $ref: '#/definitions/AuthenticationToken'
+ '403':
+ description: Account not available.
+ '404':
+ description: User not found.
+ post:
+ tags:
+ - account
+ summary: Authenticates a user
+ operationId: authenticatePost
+ parameters:
+ - name: username
+ in: path
+ description: A confirmed Wordnik username
+ required: true
+ type: string
+ - in: body
+ name: body
+ schema:
+ type: string
+ description: "The user's password"
+ required: true
+ responses:
+ '200':
+ description: A valid authentication token
+ schema:
+ $ref: '#/definitions/AuthenticationToken'
+ '403':
+ description: Account not available.
+ '404':
+ description: User not found.
+ '/word.json/{word}/audio':
+ get:
+ tags:
+ - word
+ summary: Fetches audio metadata for a word.
+ description: The metadata includes a time-expiring fileUrl which allows reading the audio file directly from the API. Currently only audio pronunciations from the American Heritage Dictionary in mp3 format are supported.
+ operationId: getAudio
+ parameters:
+ - name: word
+ in: path
+ description: Word to get audio for.
+ required: true
+ type: string
+ - name: useCanonical
+ in: query
+ description: Use the canonical form of the word
+ required: false
+ type: string
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/AudioFile'
+ '400':
+ description: Invalid word supplied.
+ /words.json/randomWords:
+ get:
+ tags:
+ - words
+ summary: Returns an array of random WordObjects
+ operationId: getRandomWords
+ parameters:
+ - name: hasDictionaryDef
+ in: query
+ description: Only return words with dictionary definitions
+ required: false
+ type: string
+ - name: includePartOfSpeech
+ in: query
+ description: CSV part-of-speech values to include
+ required: false
+ type: string
+ - name: excludePartOfSpeech
+ in: query
+ description: CSV part-of-speech values to exclude
+ required: false
+ type: string
+ - name: minCorpusCount
+ in: query
+ description: Minimum corpus frequency for terms
+ required: false
+ type: integer
+ format: int32
+ - name: maxCorpusCount
+ in: query
+ description: Maximum corpus frequency for terms
+ required: false
+ type: integer
+ format: int32
+ - name: minDictionaryCount
+ in: query
+ description: Minimum dictionary count
+ required: false
+ type: integer
+ format: int32
+ - name: maxDictionaryCount
+ in: query
+ description: Maximum dictionary count
+ required: false
+ type: integer
+ format: int32
+ - name: minLength
+ in: query
+ description: Minimum word length
+ required: false
+ type: integer
+ format: int32
+ - name: maxLength
+ in: query
+ description: Maximum word length
+ required: false
+ type: integer
+ format: int32
+ - name: sortBy
+ in: query
+ description: Attribute to sort by
+ required: false
+ type: string
+ - name: sortOrder
+ in: query
+ description: Sort direction
+ required: false
+ type: string
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/WordObject'
+ '400':
+ description: Invalid term supplied.
+ '404':
+ description: No results.
+ /account.json/wordLists:
+ get:
+ tags:
+ - account
+ summary: Fetches WordList objects for the logged-in user.
+ operationId: getWordListsForLoggedInUser
+ parameters:
+ - name: auth_token
+ in: header
+ description: auth_token of logged-in user
+ required: true
+ type: string
+ - name: skip
+ in: query
+ description: Results to skip
+ required: false
+ type: integer
+ format: int32
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/WordList'
+ '403':
+ description: Not authenticated.
+ '404':
+ description: User account not found.
+ '/word.json/{word}/phrases':
+ get:
+ tags:
+ - word
+ summary: Fetches bi-gram phrases for a word
+ operationId: getPhrases
+ parameters:
+ - name: word
+ in: path
+ description: Word to fetch phrases for
+ required: true
+ type: string
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ - name: wlmi
+ in: query
+ description: Minimum WLMI for the phrase
+ required: false
+ type: integer
+ format: int32
+ - name: useCanonical
+ in: query
+ description: "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/Bigram'
+ '400':
+ description: Invalid word supplied.
+ '/word.json/{word}/frequency':
+ get:
+ tags:
+ - word
+ summary: Returns word usage over time
+ operationId: getWordFrequency
+ parameters:
+ - name: word
+ in: path
+ description: Word to return
+ required: true
+ type: string
+ - name: useCanonical
+ in: query
+ description: "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ - name: startYear
+ in: query
+ description: Starting Year
+ required: false
+ type: integer
+ format: int32
+ - name: endYear
+ in: query
+ description: Ending Year
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/FrequencySummary'
+ '400':
+ description: Invalid word supplied.
+ '404':
+ description: No results.
+ '/wordList.json/{permalink}/words':
+ get:
+ tags:
+ - wordList
+ summary: Fetches words in a WordList
+ operationId: getWordListWords
+ parameters:
+ - name: permalink
+ in: path
+ description: ID of WordList to use
+ required: true
+ type: string
+ - name: sortBy
+ in: query
+ description: Field to sort by
+ required: false
+ type: string
+ - name: sortOrder
+ in: query
+ description: Direction to sort
+ required: false
+ type: string
+ - name: skip
+ in: query
+ description: Results to skip
+ required: false
+ type: integer
+ format: int32
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ - name: auth_token
+ in: header
+ description: 'The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)'
+ required: true
+ type: string
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/WordListWord'
+ $ref: '#/definitions/WordListWord'
+ '400':
+ description: Invalid ID supplied
+ '403':
+ description: Not Authorized to access WordList
+ '404':
+ description: WordList not found
+ post:
+ tags:
+ - wordList
+ summary: Adds words to a WordList
+ operationId: addWordsToWordList
+ parameters:
+ - name: permalink
+ in: path
+ description: permalink of WordList to user
+ required: true
+ type: string
+ - in: body
+ name: body
+ description: Array of words to add to WordList
+ required: false
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/StringValue'
+ - name: auth_token
+ in: header
+ description: 'The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)'
+ required: true
+ type: string
+ responses:
+ '200':
+ description: success
+ '400':
+ description: Invalid permalink supplied
+ '403':
+ description: Not Authorized to access WordList
+ '404':
+ description: WordList not found
+ /wordLists.json:
+ post:
+ tags:
+ - wordLists
+ summary: Creates a WordList.
+ operationId: createWordList
+ parameters:
+ - in: body
+ name: body
+ description: WordList to create
+ required: false
+ schema:
+ $ref: '#/definitions/WordList'
+ - name: auth_token
+ in: header
+ description: 'The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)'
+ required: true
+ type: string
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/WordList'
+ '400':
+ description: Invalid WordList supplied or mandatory fields are missing
+ '403':
+ description: Not authenticated
+ '404':
+ description: WordList owner not found
+ '/word.json/{word}/etymologies':
+ get:
+ tags:
+ - word
+ summary: Fetches etymology data
+ operationId: getEtymologies
+ parameters:
+ - name: word
+ in: path
+ description: Word to return
+ required: true
+ type: string
+ - name: useCanonical
+ in: query
+ description: "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ type: string
+ '400':
+ description: Invalid word supplied.
+ '404':
+ description: No definitions found.
+ '/word.json/{word}/topExample':
+ get:
+ tags:
+ - word
+ summary: Returns a top example for a word
+ operationId: getTopExample
+ parameters:
+ - name: word
+ in: path
+ description: Word to fetch examples for
+ required: true
+ type: string
+ - name: useCanonical
+ in: query
+ description: "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/Example'
+ '400':
+ description: Invalid word supplied.
+ '/word.json/{word}/definitions':
+ get:
+ tags:
+ - word
+ summary: Return definitions for a word
+ operationId: getDefinitions
+ parameters:
+ - name: word
+ in: path
+ description: Word to return definitions for
+ required: true
+ type: string
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ - name: partOfSpeech
+ in: query
+ description: CSV list of part-of-speech types
+ required: false
+ type: string
+ - name: includeRelated
+ in: query
+ description: Return related words with definitions
+ required: false
+ type: string
+ - name: sourceDictionaries
+ in: query
+ description: "Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet"
+ required: false
+ type: array
+ items:
+ type: string
+ collectionFormat: csv
+ - name: useCanonical
+ in: query
+ description: "If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ - name: includeTags
+ in: query
+ description: Return a closed set of XML tags in response
+ required: false
+ type: string
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/Definition'
+ '400':
+ description: Invalid word supplied.
+ '404':
+ description: No definitions found.
+ '/words.json/search/{query}':
+ get:
+ tags:
+ - words
+ summary: Searches words
+ operationId: searchWords
+ parameters:
+ - name: query
+ in: path
+ description: Search query
+ required: true
+ type: string
+ - name: caseSensitive
+ in: query
+ description: Search case sensitive
+ required: false
+ type: string
+ - name: includePartOfSpeech
+ in: query
+ description: Only include these comma-delimited parts of speech
+ required: false
+ type: string
+ - name: excludePartOfSpeech
+ in: query
+ description: Exclude these comma-delimited parts of speech
+ required: false
+ type: string
+ - name: minCorpusCount
+ in: query
+ description: Minimum corpus frequency for terms
+ required: false
+ type: integer
+ format: int32
+ - name: maxCorpusCount
+ in: query
+ description: Maximum corpus frequency for terms
+ required: false
+ type: integer
+ format: int32
+ - name: minDictionaryCount
+ in: query
+ description: Minimum number of dictionary entries for words returned
+ required: false
+ type: integer
+ format: int32
+ - name: maxDictionaryCount
+ in: query
+ description: Maximum dictionary definition count
+ required: false
+ type: integer
+ format: int32
+ - name: minLength
+ in: query
+ description: Minimum word length
+ required: false
+ type: integer
+ format: int32
+ - name: maxLength
+ in: query
+ description: Maximum word length
+ required: false
+ type: integer
+ format: int32
+ - name: skip
+ in: query
+ description: Results to skip
+ required: false
+ type: integer
+ format: int32
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/WordSearchResults'
+ '400':
+ description: Invalid query supplied.
+ '/wordList.json/{permalink}':
+ get:
+ tags:
+ - wordList
+ summary: Fetches a WordList by ID
+ operationId: getWordListByPermalink
+ parameters:
+ - name: permalink
+ in: path
+ description: permalink of WordList to fetch
+ required: true
+ type: string
+ - name: auth_token
+ in: header
+ description: 'The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)'
+ required: true
+ type: string
+ responses:
+ '200':
+ description: success
+ schema:
+ $ref: '#/definitions/WordList'
+ '400':
+ description: Invalid ID supplied
+ '403':
+ description: Not Authorized to access WordList
+ '404':
+ description: WordList not found
+ put:
+ tags:
+ - wordList
+ summary: Updates an existing WordList
+ operationId: updateWordList
+ parameters:
+ - name: permalink
+ in: path
+ description: permalink of WordList to update
+ required: true
+ type: string
+ - in: body
+ name: body
+ description: Updated WordList
+ required: false
+ schema:
+ $ref: '#/definitions/WordList'
+ - name: auth_token
+ in: header
+ description: 'The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)'
+ required: true
+ type: string
+ responses:
+ '200':
+ description: success
+ '400':
+ description: Invalid ID supplied
+ '403':
+ description: Not Authorized to update WordList
+ '404':
+ description: WordList not found
+ delete:
+ tags:
+ - wordList
+ summary: Deletes an existing WordList
+ operationId: deleteWordList
+ parameters:
+ - name: permalink
+ in: path
+ description: ID of WordList to delete
+ required: true
+ type: string
+ - name: auth_token
+ in: header
+ description: 'The auth token of the logged-in user, obtained by calling /account.json/authenticate/{username} (described above)'
+ required: true
+ type: string
+ responses:
+ '200':
+ description: success
+ '400':
+ description: Invalid ID supplied
+ '403':
+ description: Not Authorized to delete WordList
+ '404':
+ description: WordList not found
+ '/word.json/{word}/hyphenation':
+ get:
+ tags:
+ - word
+ summary: Returns syllable information for a word
+ operationId: getHyphenation
+ parameters:
+ - name: word
+ in: path
+ description: Word to get syllables for
+ required: true
+ type: string
+ - name: useCanonical
+ in: query
+ description: "If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested."
+ required: false
+ type: string
+ - name: sourceDictionary
+ in: query
+ description: 'Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet.'
+ required: false
+ type: string
+ - name: limit
+ in: query
+ description: Maximum number of results to return
+ required: false
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: success
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/Syllable'
+ '400':
+ description: Invalid word supplied.
+ /words.json/wordOfTheDay:
+ get:
+ tags:
+ - words
+ summary: Returns a specific WordOfTheDay
+ operationId: getWordOfTheDay
+ parameters:
+ - name: date
+ in: query
+ description: Fetches by date in yyyy-MM-dd
+ required: false
+ type: string
+ responses:
+ default:
+ description: success
+ schema:
+ $ref: '#/definitions/WordOfTheDay'
+definitions:
+ Syllable:
+ properties:
+ text:
+ type: string
+ seq:
+ type: integer
+ format: int32
+ type:
+ type: string
+ StringValue:
+ properties:
+ word:
+ type: string
+ AuthenticationToken:
+ properties:
+ token:
+ type: string
+ userId:
+ type: integer
+ format: int64
+ userSignature:
+ type: string
+ Sentence:
+ properties:
+ hasScoredWords:
+ type: boolean
+ id:
+ type: integer
+ format: int64
+ scoredWords:
+ type: array
+ items:
+ $ref: '#/definitions/ScoredWord'
+ display:
+ type: string
+ rating:
+ type: integer
+ format: int32
+ documentMetadataId:
+ type: integer
+ format: int64
+ ExampleSearchResults:
+ properties:
+ facets:
+ type: array
+ items:
+ $ref: '#/definitions/Facet'
+ examples:
+ type: array
+ items:
+ $ref: '#/definitions/Example'
+ WordSearchResults:
+ properties:
+ searchResults:
+ type: array
+ items:
+ $ref: '#/definitions/WordSearchResult'
+ totalResults:
+ type: integer
+ format: int32
+ SimpleDefinition:
+ properties:
+ text:
+ type: string
+ source:
+ type: string
+ note:
+ type: string
+ partOfSpeech:
+ type: string
+ Citation:
+ properties:
+ cite:
+ type: string
+ source:
+ type: string
+ WordList:
+ properties:
+ numberWordsInList:
+ type: integer
+ format: int64
+ userId:
+ type: integer
+ format: int64
+ name:
+ type: string
+ permalink:
+ type: string
+ updatedAt:
+ type: string
+ format: date-time
+ username:
+ type: string
+ lastActivityAt:
+ type: string
+ format: date-time
+ type:
+ type: string
+ id:
+ type: integer
+ format: int64
+ createdAt:
+ type: string
+ format: date-time
+ description:
+ type: string
+ WordObject:
+ properties:
+ id:
+ type: integer
+ format: int64
+ word:
+ type: string
+ originalWord:
+ type: string
+ suggestions:
+ type: array
+ items:
+ type: string
+ canonicalForm:
+ type: string
+ vulgar:
+ type: string
+ Example:
+ properties:
+ sentence:
+ $ref: '#/definitions/Sentence'
+ exampleId:
+ type: integer
+ format: int64
+ word:
+ type: string
+ text:
+ type: string
+ url:
+ type: string
+ provider:
+ $ref: '#/definitions/ContentProvider'
+ score:
+ $ref: '#/definitions/ScoredWord'
+ documentId:
+ type: integer
+ format: int64
+ title:
+ type: string
+ id:
+ type: integer
+ format: int64
+ year:
+ type: integer
+ format: int32
+ rating:
+ type: number
+ format: float
+ ContentProvider:
+ properties:
+ id:
+ type: integer
+ format: int32
+ name:
+ type: string
+ FrequencySummary:
+ properties:
+ unknownYearCount:
+ type: integer
+ format: int32
+ totalCount:
+ type: integer
+ format: int64
+ frequencyString:
+ type: string
+ word:
+ type: string
+ frequency:
+ type: array
+ items:
+ $ref: '#/definitions/Frequency'
+ Related:
+ properties:
+ label1:
+ type: string
+ relationshipType:
+ type: string
+ label2:
+ type: string
+ label3:
+ type: string
+ words:
+ type: array
+ items:
+ type: string
+ gram:
+ type: string
+ label4:
+ type: string
+ User:
+ properties:
+ id:
+ type: integer
+ format: int64
+ username:
+ type: string
+ email:
+ type: string
+ status:
+ type: integer
+ format: int32
+ faceBookId:
+ type: string
+ userName:
+ type: string
+ displayName:
+ type: string
+ password:
+ type: string
+ WordOfTheDay:
+ properties:
+ definitions:
+ type: array
+ items:
+ $ref: '#/definitions/SimpleDefinition'
+ htmlExtra:
+ type: string
+ parentId:
+ type: string
+ examples:
+ type: array
+ items:
+ $ref: '#/definitions/SimpleExample'
+ contentProvider:
+ $ref: '#/definitions/ContentProvider'
+ word:
+ type: string
+ note:
+ type: string
+ id:
+ type: integer
+ format: int64
+ createdAt:
+ type: string
+ format: date-time
+ publishDate:
+ type: string
+ format: date-time
+ category:
+ type: string
+ createdBy:
+ type: string
+ TextPron:
+ properties:
+ raw:
+ type: string
+ seq:
+ type: integer
+ format: int32
+ rawType:
+ type: string
+ WordSearchResult:
+ properties:
+ count:
+ type: integer
+ format: int64
+ lexicality:
+ type: number
+ format: double
+ word:
+ type: string
+ ApiTokenStatus:
+ properties:
+ valid:
+ type: boolean
+ token:
+ type: string
+ resetsInMillis:
+ type: integer
+ format: int64
+ remainingCalls:
+ type: integer
+ format: int64
+ expiresInMillis:
+ type: integer
+ format: int64
+ totalRequests:
+ type: integer
+ format: int64
+ Note:
+ properties:
+ noteType:
+ type: string
+ appliesTo:
+ type: array
+ items:
+ type: string
+ value:
+ type: string
+ pos:
+ type: integer
+ format: int32
+ WordListWord:
+ properties:
+ id:
+ type: integer
+ format: int64
+ word:
+ type: string
+ username:
+ type: string
+ userId:
+ type: integer
+ format: int64
+ createdAt:
+ type: string
+ format: date-time
+ numberCommentsOnWord:
+ type: integer
+ format: int64
+ numberLists:
+ type: integer
+ format: int64
+ AudioFile:
+ properties:
+ voteCount:
+ type: integer
+ format: int32
+ word:
+ type: string
+ attributionText:
+ type: string
+ audioType:
+ type: string
+ attributionUrl:
+ type: string
+ commentCount:
+ type: integer
+ format: int32
+ fileUrl:
+ type: string
+ voteAverage:
+ type: number
+ format: float
+ duration:
+ type: number
+ format: double
+ id:
+ type: integer
+ format: int64
+ createdAt:
+ type: string
+ format: date-time
+ voteWeightedAverage:
+ type: number
+ format: float
+ description:
+ type: string
+ createdBy:
+ type: string
+ Definition:
+ properties:
+ notes:
+ type: array
+ items:
+ $ref: '#/definitions/Note'
+ sequence:
+ type: string
+ textProns:
+ type: array
+ items:
+ $ref: '#/definitions/TextPron'
+ extendedText:
+ type: string
+ word:
+ type: string
+ attributionText:
+ type: string
+ citations:
+ type: array
+ items:
+ $ref: '#/definitions/Citation'
+ partOfSpeech:
+ type: string
+ text:
+ type: string
+ attributionUrl:
+ type: string
+ seqString:
+ type: string
+ sourceDictionary:
+ type: string
+ score:
+ type: number
+ format: float
+ exampleUses:
+ type: array
+ items:
+ $ref: '#/definitions/ExampleUsage'
+ relatedWords:
+ type: array
+ items:
+ $ref: '#/definitions/Related'
+ labels:
+ type: array
+ items:
+ $ref: '#/definitions/Label'
+ Label:
+ properties:
+ text:
+ type: string
+ type:
+ type: string
+ Facet:
+ properties:
+ facetValues:
+ type: array
+ items:
+ $ref: '#/definitions/FacetValue'
+ name:
+ type: string
+ ExampleUsage:
+ properties:
+ text:
+ type: string
+ SimpleExample:
+ properties:
+ id:
+ type: integer
+ format: int64
+ title:
+ type: string
+ text:
+ type: string
+ url:
+ type: string
+ FacetValue:
+ properties:
+ count:
+ type: integer
+ format: int64
+ value:
+ type: string
+ DefinitionSearchResults:
+ properties:
+ results:
+ type: array
+ items:
+ $ref: '#/definitions/Definition'
+ totalResults:
+ type: integer
+ format: int32
+ Frequency:
+ properties:
+ count:
+ type: integer
+ format: int64
+ year:
+ type: integer
+ format: int32
+ ScoredWord:
+ properties:
+ wordType:
+ type: string
+ lemma:
+ type: string
+ position:
+ type: integer
+ format: int32
+ word:
+ type: string
+ docTermCount:
+ type: integer
+ format: int32
+ stopword:
+ type: boolean
+ partOfSpeech:
+ type: string
+ score:
+ type: number
+ format: float
+ baseWordScore:
+ type: number
+ format: double
+ id:
+ type: integer
+ format: int64
+ sentenceId:
+ type: integer
+ format: int64
+ Bigram:
+ properties:
+ count:
+ type: integer
+ format: int64
+ gram2:
+ type: string
+ gram1:
+ type: string
+ wlmi:
+ type: number
+ format: double
+ mi:
+ type: number
+ format: double
\ No newline at end of file
diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml
index b42a51a86af0..4f8794c331b4 100644
--- a/modules/swagger-generator/pom.xml
+++ b/modules/swagger-generator/pom.xml
@@ -4,7 +4,7 @@
io.swagger
swagger-codegen-project
- 2.1.4-SNAPSHOT
+ 2.1.5-SNAPSHOT
../..
swagger-generator
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java b/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java
index a81113ab76a1..a13995505c7c 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java
@@ -49,6 +49,8 @@ public class Bootstrap extends HttpServlet {
bc.setVersion("0.0.0");
}
}
+
+ bc.setSchemes(new String[]{"https"});
bc.setHost("generator.swagger.io");
bc.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
bc.setResourcePackage("io.swagger.generator.resource");
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
index 775c96cda2ea..18e883effbf0 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
@@ -17,22 +17,44 @@ import io.swagger.util.Json;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.commons.lang3.StringUtils.isNotEmpty;
-
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
public class Generator {
static Logger LOGGER = LoggerFactory.getLogger(Generator.class);
+ public enum Type {
+ CLIENT("client"),
+ SERVER("server");
+
+ private String name;
+
+ Type(String name) {
+ this.name = name;
+ }
+
+ String getTypeName() {
+ return name;
+ }
+ }
+
public static String generateClient(String language, GeneratorInput opts) throws ApiException {
- Swagger swagger;
- LOGGER.debug("generate client for " + language);
+ return generate(language, opts, Type.CLIENT);
+ }
+
+ public static String generateServer(String language, GeneratorInput opts) throws ApiException {
+ return generate(language, opts, Type.SERVER);
+ }
+
+ private static String generate(String language, GeneratorInput opts, Type type) throws ApiException {
+ LOGGER.debug(String.format("generate %s for %s", type.getTypeName(), language));
if (opts == null) {
throw new BadRequestException(400, "No options were supplied");
}
JsonNode node = opts.getSpec();
+ Swagger swagger;
if (node == null) {
if (opts.getSwaggerUrl() != null) {
swagger = new SwaggerParser().read(opts.getSwaggerUrl());
@@ -48,7 +70,8 @@ public class Generator {
ClientOptInput clientOptInput = new ClientOptInput();
ClientOpts clientOpts = new ClientOpts();
- String outputFolder = getTmpFolder().getAbsolutePath() + File.separator + language + "-client";
+ String outputFolder = getTmpFolder().getAbsolutePath() + File.separator + language + "-"
+ + type.getTypeName();
String outputFilename = outputFolder + "-bundle.zip";
clientOptInput
@@ -61,17 +84,9 @@ public class Generator {
} catch(RuntimeException e) {
throw new BadRequestException(400, "Unsupported target " + language + " supplied");
}
-
+
if (opts.getOptions() != null) {
- for(String key : new String[]{"apiPackage", "modelPackage", "invokerPackage", "groupId", "artifactId", "artifactVersion"}) {
- if(isNotEmpty(opts.getOptions().get(key))) {
- codegenConfig.additionalProperties().put(key , opts.getOptions().get(key));
- }
- }
-
- if (isNotEmpty(opts.getOptions().get("library"))) {
- codegenConfig.setLibrary(opts.getOptions().get("library"));
- }
+ codegenConfig.additionalProperties().putAll(opts.getOptions());
}
codegenConfig.setOutputDir(outputFolder);
@@ -97,65 +112,6 @@ public class Generator {
return outputFilename;
}
- public static String generateServer(String language, GeneratorInput opts) throws ApiException {
- LOGGER.debug("generate server for " + language);
- Swagger swagger;
- if (opts == null) {
- throw new BadRequestException(400, "No options were supplied");
- }
- if (opts == null) {
- throw new BadRequestException(400, "No options were supplied");
- }
- JsonNode node = opts.getSpec();
- if (node == null) {
- if (opts.getSwaggerUrl() != null) {
- swagger = new SwaggerParser().read(opts.getSwaggerUrl());
- } else {
- throw new BadRequestException(400, "No swagger specification was supplied");
- }
- } else {
- swagger = new SwaggerParser().read(node, true);
- }
- if (swagger == null) {
- throw new BadRequestException(400, "The swagger specification supplied was not valid");
- }
-
- ClientOptInput clientOptInput = new ClientOptInput();
- ClientOpts clientOpts = new ClientOpts();
- String outputFolder = getTmpFolder().getAbsolutePath() + File.separator + language + "-server";
- String outputFilename = outputFolder + "-bundle.zip";
-
- clientOptInput
- .opts(clientOpts)
- .swagger(swagger);
-
- CodegenConfig codegenConfig = Codegen.getConfig(language);
- if (codegenConfig == null) {
- throw new BadRequestException(400, "Unsupported target " + language + " supplied");
- }
-
- codegenConfig.setOutputDir(outputFolder);
-
- Json.prettyPrint(clientOpts);
-
- clientOptInput.setConfig(codegenConfig);
-
- try {
- List files = new Codegen().opts(clientOptInput).generate();
- if (files.size() > 0) {
- List filesToAdd = new ArrayList();
- filesToAdd.add(new File(outputFolder));
- ZipUtil zip = new ZipUtil();
- zip.compressFiles(filesToAdd, outputFilename);
- } else {
- throw new BadRequestException(400, "A target generation was attempted, but no files were created!");
- }
- } catch (Exception e) {
- throw new BadRequestException(500, "Unable to build target: " + e.getMessage());
- }
- return outputFilename;
- }
-
public static InputOption clientOptions(String language) {
return null;
}
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java b/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
index ddfd6fa39502..fa6a4785c5b9 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java
@@ -21,10 +21,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@Path("/gen")
@Api(value = "/gen", description = "Resource for generating swagger components")
@@ -68,8 +65,17 @@ public class SwaggerResource {
@ApiParam(value = "Configuration for building the client library", required = true) GeneratorInput opts) throws Exception {
String filename = Generator.generateClient(language, opts);
+ String scheme = request.getHeader("X-SSL");
+ String port = "";
+ if("1".equals(scheme)) {
+ scheme = "https";
+ }
+ else {
+ scheme = request.getScheme();
+ port = ":" + request.getServerPort();
+ }
- String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
+ String host = scheme + "://" + request.getServerName() + port;
if (filename != null) {
String code = String.valueOf(System.currentTimeMillis());
Generated g = new Generated();
diff --git a/modules/swagger-generator/src/main/webapp/index.html b/modules/swagger-generator/src/main/webapp/index.html
index 021310d9dec8..5a19fbffa431 100644
--- a/modules/swagger-generator/src/main/webapp/index.html
+++ b/modules/swagger-generator/src/main/webapp/index.html
@@ -27,7 +27,7 @@
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
- url = "http://generator.swagger.io/api/swagger.json";
+ url = "https://generator.swagger.io/api/swagger.json";
}
window.swaggerUi = new SwaggerUi({
url: url,
diff --git a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java
new file mode 100644
index 000000000000..e6eb42abb355
--- /dev/null
+++ b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java
@@ -0,0 +1,97 @@
+package io.swagger.generator.online;
+
+import static org.testng.Assert.assertNotEquals;
+
+import io.swagger.generator.exception.ApiException;
+import io.swagger.generator.model.GeneratorInput;
+import io.swagger.generator.online.Generator;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Maps;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class OnlineGeneratorOptionsTest {
+ private final boolean isServer;
+ private final String language;
+
+ protected OnlineGeneratorOptionsTest(String language, boolean isServer) {
+ this.language = language;
+ this.isServer = isServer;
+ }
+
+ @Test
+ public void optionsTest() throws ApiException, IOException {
+ final GeneratorInput input = new GeneratorInput();
+ final HashMap options = convertOptions();
+
+ final Maps.EntryTransformer transformer =
+ new Maps.EntryTransformer() {
+ public String transformEntry(String key, InvocationCounter value) {
+ return value.getValue();
+ }
+ };
+
+ input.setOptions(Maps.transformEntries(options, transformer));
+ final ObjectMapper mapper = new ObjectMapper();
+ input.setSpec(mapper.readTree(loadClassResource(getClass(), "petstore.json")));
+ String outputFilename;
+ if (isServer) {
+ outputFilename = Generator.generateServer(language, input);
+ } else {
+ outputFilename = Generator.generateClient(language, input);
+ }
+ final File dir = new File(new File(outputFilename).getParent());
+ FileUtils.deleteDirectory(dir);
+ for (InvocationCounter option : options.values()) {
+ assertNotEquals(option.getCounter(), 0, String.format("Option \"%s\" wasn't processed.",
+ option.getValue()));
+ }
+ }
+
+ protected abstract Map getOptions();
+
+ private HashMap convertOptions() {
+ HashMap options = new HashMap();
+ for (Map.Entry entry : getOptions().entrySet()) {
+ options.put(entry.getKey(), new InvocationCounter(entry.getValue()));
+ }
+ return options;
+ }
+
+ private static String loadClassResource(Class> cls, String name) throws IOException {
+ InputStream in = null;
+ try {
+ in = cls.getClassLoader().getResourceAsStream(name);
+ return IOUtils.toString(in, StandardCharsets.UTF_8);
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+ }
+
+ private static class InvocationCounter {
+ private String value;
+ private int counter;
+
+ public InvocationCounter(String value) {
+ this.value = value;
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+
+ public String getValue() {
+ ++counter;
+ return value;
+ }
+ }
+}
diff --git a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJavaClientOptionsTest.java b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJavaClientOptionsTest.java
new file mode 100644
index 000000000000..50605cff1109
--- /dev/null
+++ b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJavaClientOptionsTest.java
@@ -0,0 +1,34 @@
+package io.swagger.generator.online;
+
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+
+public class OnlineJavaClientOptionsTest extends OnlineGeneratorOptionsTest {
+
+ public OnlineJavaClientOptionsTest() {
+ super("java", false);
+ }
+
+ protected OnlineJavaClientOptionsTest(String language, boolean isServer) {
+ super(language, isServer);
+ }
+
+ @Override
+ protected Map getOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder.put("modelPackage", "package")
+ .put("apiPackage", "apiPackage")
+ .put("sortParamsByRequiredFlag", "false")
+ .put("invokerPackage", "io.swagger.client.test")
+ .put("groupId", "io.swagger.test")
+ .put("artifactId", "swagger-java-client-test")
+ .put("artifactVersion", "1.0.0-SNAPSHOT")
+ .put("sourceFolder", "src/main/java/test")
+ .put("localVariablePrefix", "tst")
+ .put("serializableModel", "false")
+ .put("fullJavaUtil", "true")
+ .put("library", "jersey2")
+ .build();
+ }
+}
diff --git a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJaxRSServerOptionsTest.java b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJaxRSServerOptionsTest.java
new file mode 100644
index 000000000000..c64466fe696e
--- /dev/null
+++ b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineJaxRSServerOptionsTest.java
@@ -0,0 +1,9 @@
+package io.swagger.generator.online;
+
+public class OnlineJaxRSServerOptionsTest extends OnlineJavaClientOptionsTest{
+
+ public OnlineJaxRSServerOptionsTest() {
+ super("jaxrs", true);
+ }
+
+}
diff --git a/modules/swagger-generator/src/test/resources/petstore.json b/modules/swagger-generator/src/test/resources/petstore.json
new file mode 100644
index 000000000000..67c4d47292da
--- /dev/null
+++ b/modules/swagger-generator/src/test/resources/petstore.json
@@ -0,0 +1,1030 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
+ "version": "1.0.0",
+ "title": "Swagger Petstore",
+ "termsOfService": "http://swagger.io/terms/",
+ "contact": {
+ "email": "apiteam@swagger.io"
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
+ }
+ },
+ "host": "petstore.swagger.io",
+ "basePath": "/v2",
+ "tags": [
+ {
+ "name": "pet",
+ "description": "Everything about your Pets",
+ "externalDocs": {
+ "description": "Find out more",
+ "url": "http://swagger.io"
+ }
+ },
+ {
+ "name": "store",
+ "description": "Access to Petstore orders"
+ },
+ {
+ "name": "user",
+ "description": "Operations about user",
+ "externalDocs": {
+ "description": "Find out more about our store",
+ "url": "http://swagger.io"
+ }
+ }
+ ],
+ "schemes": [
+ "http"
+ ],
+ "paths": {
+ "/pet": {
+ "post": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Add a new pet to the store",
+ "description": "",
+ "operationId": "addPet",
+ "consumes": [
+ "application/json",
+ "application/xml"
+ ],
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Pet object that needs to be added to the store",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/Pet"
+ }
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Invalid input"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ },
+ "put": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Update an existing pet",
+ "description": "",
+ "operationId": "updatePet",
+ "consumes": [
+ "application/json",
+ "application/xml"
+ ],
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Pet object that needs to be added to the store",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/Pet"
+ }
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Pet not found"
+ },
+ "405": {
+ "description": "Validation exception"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ }
+ },
+ "/pet/findByStatus": {
+ "get": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Finds Pets by status",
+ "description": "Multiple status values can be provided with comma seperated strings",
+ "operationId": "findPetsByStatus",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "status",
+ "in": "query",
+ "description": "Status values that need to be considered for filter",
+ "required": true,
+ "type": "array",
+ "items": {
+ "type": "string",
+ "enum": [
+ "available",
+ "pending",
+ "sold"
+ ],
+ "default": "available"
+ },
+ "collectionFormat": "csv"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Pet"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid status value"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ }
+ },
+ "/pet/findByTags": {
+ "get": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Finds Pets by tags",
+ "description": "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
+ "operationId": "findPetsByTags",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "tags",
+ "in": "query",
+ "description": "Tags to filter by",
+ "required": true,
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "collectionFormat": "csv"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Pet"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid tag value"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ }
+ },
+ "/pet/{petId}": {
+ "get": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Find pet by ID",
+ "description": "Returns a single pet",
+ "operationId": "getPetById",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "petId",
+ "in": "path",
+ "description": "ID of pet to return",
+ "required": true,
+ "type": "integer",
+ "format": "int64"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/Pet"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Pet not found"
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ }
+ ]
+ },
+ "post": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Updates a pet in the store with form data",
+ "description": "",
+ "operationId": "updatePetWithForm",
+ "consumes": [
+ "application/x-www-form-urlencoded"
+ ],
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "petId",
+ "in": "path",
+ "description": "ID of pet that needs to be updated",
+ "required": true,
+ "type": "integer",
+ "format": "int64"
+ },
+ {
+ "name": "name",
+ "in": "formData",
+ "description": "Updated name of the pet",
+ "required": false,
+ "type": "string"
+ },
+ {
+ "name": "status",
+ "in": "formData",
+ "description": "Updated status of the pet",
+ "required": false,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Invalid input"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ },
+ "delete": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "Deletes a pet",
+ "description": "",
+ "operationId": "deletePet",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "api_key",
+ "in": "header",
+ "required": false,
+ "type": "string"
+ },
+ {
+ "name": "petId",
+ "in": "path",
+ "description": "Pet id to delete",
+ "required": true,
+ "type": "integer",
+ "format": "int64"
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid pet value"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ }
+ },
+ "/pet/{petId}/uploadImage": {
+ "post": {
+ "tags": [
+ "pet"
+ ],
+ "summary": "uploads an image",
+ "description": "",
+ "operationId": "uploadFile",
+ "consumes": [
+ "multipart/form-data"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "petId",
+ "in": "path",
+ "description": "ID of pet to update",
+ "required": true,
+ "type": "integer",
+ "format": "int64"
+ },
+ {
+ "name": "additionalMetadata",
+ "in": "formData",
+ "description": "Additional data to pass to server",
+ "required": false,
+ "type": "string"
+ },
+ {
+ "name": "file",
+ "in": "formData",
+ "description": "file to upload",
+ "required": false,
+ "type": "file"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/ApiResponse"
+ }
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ]
+ }
+ },
+ "/store/inventory": {
+ "get": {
+ "tags": [
+ "store"
+ ],
+ "summary": "Returns pet inventories by status",
+ "description": "Returns a map of status codes to quantities",
+ "operationId": "getInventory",
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "integer",
+ "format": "int32"
+ }
+ }
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ }
+ ]
+ }
+ },
+ "/store/order": {
+ "post": {
+ "tags": [
+ "store"
+ ],
+ "summary": "Place an order for a pet",
+ "description": "",
+ "operationId": "placeOrder",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "order placed for purchasing the pet",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/Order"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/Order"
+ }
+ },
+ "400": {
+ "description": "Invalid Order"
+ }
+ }
+ }
+ },
+ "/store/order/{orderId}": {
+ "get": {
+ "tags": [
+ "store"
+ ],
+ "summary": "Find purchase order by ID",
+ "description": "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
+ "operationId": "getOrderById",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "orderId",
+ "in": "path",
+ "description": "ID of pet that needs to be fetched",
+ "required": true,
+ "type": "integer",
+ "maximum": 5.0,
+ "minimum": 1.0,
+ "format": "int64"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/Order"
+ }
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Order not found"
+ }
+ }
+ },
+ "delete": {
+ "tags": [
+ "store"
+ ],
+ "summary": "Delete purchase order by ID",
+ "description": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
+ "operationId": "deleteOrder",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "orderId",
+ "in": "path",
+ "description": "ID of the order that needs to be deleted",
+ "required": true,
+ "type": "string",
+ "minimum": 1.0
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Order not found"
+ }
+ }
+ }
+ },
+ "/user": {
+ "post": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Create user",
+ "description": "This can only be done by the logged in user.",
+ "operationId": "createUser",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Created user object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ ],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ }
+ }
+ },
+ "/user/createWithArray": {
+ "post": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Creates list of users with given input array",
+ "description": "",
+ "operationId": "createUsersWithArrayInput",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "List of user object",
+ "required": true,
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ }
+ ],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ }
+ }
+ },
+ "/user/createWithList": {
+ "post": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Creates list of users with given input array",
+ "description": "",
+ "operationId": "createUsersWithListInput",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "List of user object",
+ "required": true,
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ }
+ ],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ }
+ }
+ },
+ "/user/login": {
+ "get": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Logs user into the system",
+ "description": "",
+ "operationId": "loginUser",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "username",
+ "in": "query",
+ "description": "The user name for login",
+ "required": true,
+ "type": "string"
+ },
+ {
+ "name": "password",
+ "in": "query",
+ "description": "The password for login in clear text",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "type": "string"
+ },
+ "headers": {
+ "X-Rate-Limit": {
+ "type": "integer",
+ "format": "int32",
+ "description": "calls per hour allowed by the user"
+ },
+ "X-Expires-After": {
+ "type": "string",
+ "format": "date-time",
+ "description": "date in UTC when toekn expires"
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid username/password supplied"
+ }
+ }
+ }
+ },
+ "/user/logout": {
+ "get": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Logs out current logged in user session",
+ "description": "",
+ "operationId": "logoutUser",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ }
+ }
+ },
+ "/user/{username}": {
+ "get": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Get user by user name",
+ "description": "",
+ "operationId": "getUserByName",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "username",
+ "in": "path",
+ "description": "The name that needs to be fetched. Use user1 for testing. ",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "successful operation",
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ },
+ "400": {
+ "description": "Invalid username supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ }
+ },
+ "put": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Updated user",
+ "description": "This can only be done by the logged in user.",
+ "operationId": "updateUser",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "username",
+ "in": "path",
+ "description": "name that need to be deleted",
+ "required": true,
+ "type": "string"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Updated user object",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/User"
+ }
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid user supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ }
+ },
+ "delete": {
+ "tags": [
+ "user"
+ ],
+ "summary": "Delete user",
+ "description": "This can only be done by the logged in user.",
+ "operationId": "deleteUser",
+ "produces": [
+ "application/xml",
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "username",
+ "in": "path",
+ "description": "The name that needs to be deleted",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid username supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ }
+ }
+ }
+ },
+ "securityDefinitions": {
+ "petstore_auth": {
+ "type": "oauth2",
+ "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog",
+ "flow": "implicit",
+ "scopes": {
+ "write:pets": "modify pets in your account",
+ "read:pets": "read your pets"
+ }
+ },
+ "api_key": {
+ "type": "apiKey",
+ "name": "api_key",
+ "in": "header"
+ }
+ },
+ "definitions": {
+ "Order": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "petId": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "quantity": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "shipDate": {
+ "type": "string",
+ "format": "date-time"
+ },
+ "status": {
+ "type": "string",
+ "description": "Order Status",
+ "enum": [
+ "placed",
+ "approved",
+ "delivered"
+ ]
+ },
+ "complete": {
+ "type": "boolean",
+ "default": false
+ }
+ },
+ "xml": {
+ "name": "Order"
+ }
+ },
+ "User": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "username": {
+ "type": "string"
+ },
+ "firstName": {
+ "type": "string"
+ },
+ "lastName": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ },
+ "phone": {
+ "type": "string"
+ },
+ "userStatus": {
+ "type": "integer",
+ "format": "int32",
+ "description": "User Status"
+ }
+ },
+ "xml": {
+ "name": "User"
+ }
+ },
+ "Category": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "name": {
+ "type": "string"
+ }
+ },
+ "xml": {
+ "name": "Category"
+ }
+ },
+ "Tag": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "name": {
+ "type": "string"
+ }
+ },
+ "xml": {
+ "name": "Tag"
+ }
+ },
+ "ApiResponse": {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "type": {
+ "type": "string"
+ },
+ "message": {
+ "type": "string"
+ }
+ }
+ },
+ "Pet": {
+ "type": "object",
+ "required": [
+ "name",
+ "photoUrls"
+ ],
+ "properties": {
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "category": {
+ "$ref": "#/definitions/Category"
+ },
+ "name": {
+ "type": "string",
+ "example": "doggie"
+ },
+ "photoUrls": {
+ "type": "array",
+ "xml": {
+ "name": "photoUrl",
+ "wrapped": true
+ },
+ "items": {
+ "type": "string"
+ }
+ },
+ "tags": {
+ "type": "array",
+ "xml": {
+ "name": "tag",
+ "wrapped": true
+ },
+ "items": {
+ "$ref": "#/definitions/Tag"
+ }
+ },
+ "status": {
+ "type": "string",
+ "description": "pet status in the store",
+ "enum": [
+ "available",
+ "pending",
+ "sold"
+ ]
+ }
+ },
+ "xml": {
+ "name": "Pet"
+ }
+ }
+ },
+ "externalDocs": {
+ "description": "Find out more about Swagger",
+ "url": "http://swagger.io"
+ }
+}
diff --git a/pom.xml b/pom.xml
index 27ce57442785..466b8f300b8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
swagger-codegen-project
pom
swagger-codegen-project
- 2.1.4-SNAPSHOT
+ 2.1.5-SNAPSHOT
https://github.com/swagger-api/swagger-codegen
scm:git:git@github.com:swagger-api/swagger-codegen.git
@@ -517,11 +517,11 @@
- 1.0.11-SNAPSHOT
+ 1.0.11
2.11.1
2.3.4
- 1.5.4-SNAPSHOT
- 2.1.4
+ 1.5.4
+ 2.1.5-SNAPSHOT
2.3
1.2
4.8.1
diff --git a/samples/client/petstore/akka-scala/pom.xml b/samples/client/petstore/akka-scala/pom.xml
index a047ad86cc01..a6e81fb75f4f 100644
--- a/samples/client/petstore/akka-scala/pom.xml
+++ b/samples/client/petstore/akka-scala/pom.xml
@@ -217,7 +217,7 @@
2.3.9
1.2
2.2
- 1.5.0
+ 1.5.4
1.0.0
4.8.1
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala
index 591d055dad6b..7decd51b03c0 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala
@@ -11,18 +11,18 @@ object PetApi {
/**
*
* Expected answers:
- * code 405 : (Validation exception)
- * code 404 : (Pet not found)
* code 400 : (Invalid ID supplied)
+ * code 404 : (Pet not found)
+ * code 405 : (Validation exception)
*
* @param body Pet object that needs to be added to the store
*/
def updatePet(body: Option[Pet] = None): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/pet", "application/json")
.withBody(body)
- .withErrorResponse[Unit](405)
- .withErrorResponse[Unit](404)
.withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+ .withErrorResponse[Unit](405)
/**
*
@@ -70,9 +70,9 @@ object PetApi {
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
*
* Expected answers:
- * code 404 : (Pet not found)
* code 200 : Pet (successful operation)
* code 400 : (Invalid ID supplied)
+ * code 404 : (Pet not found)
*
* Available security schemes:
* api_key (apiKey)
@@ -83,9 +83,9 @@ object PetApi {
ApiRequest[Pet](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json")
.withApiKey(apiKey, "api_key", HEADER)
.withPathParam("petId", petId)
- .withErrorResponse[Unit](404)
.withSuccessResponse[Pet](200)
.withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
/**
*
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala
index 686e85e105dc..f3ab28da05f2 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala
@@ -39,33 +39,33 @@ object StoreApi {
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
*
* Expected answers:
- * code 404 : (Order not found)
* code 200 : Order (successful operation)
* code 400 : (Invalid ID supplied)
+ * code 404 : (Order not found)
*
* @param orderId ID of pet that needs to be fetched
*/
def getOrderById(orderId: String): ApiRequest[Order] =
ApiRequest[Order](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json")
.withPathParam("orderId", orderId)
- .withErrorResponse[Unit](404)
.withSuccessResponse[Order](200)
.withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
/**
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
*
* Expected answers:
- * code 404 : (Order not found)
* code 400 : (Invalid ID supplied)
+ * code 404 : (Order not found)
*
* @param orderId ID of the order that needs to be deleted
*/
def deleteOrder(orderId: String): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json")
.withPathParam("orderId", orderId)
- .withErrorResponse[Unit](404)
.withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala
index 4c2ab10e9e7b..b759a799e3dc 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala
@@ -72,25 +72,25 @@ object UserApi {
/**
*
* Expected answers:
- * code 404 : (User not found)
* code 200 : User (successful operation)
* code 400 : (Invalid username supplied)
+ * code 404 : (User not found)
*
- * @param username The name that needs to be fetched. Use user1 for testing.
+ * @param username The name that needs to be fetched. Use user1 for testing.
*/
def getUserByName(username: String): ApiRequest[User] =
ApiRequest[User](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
.withPathParam("username", username)
- .withErrorResponse[Unit](404)
.withSuccessResponse[User](200)
.withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
/**
* This can only be done by the logged in user.
*
* Expected answers:
- * code 404 : (User not found)
* code 400 : (Invalid user supplied)
+ * code 404 : (User not found)
*
* @param username name that need to be deleted
* @param body Updated user object
@@ -99,23 +99,23 @@ object UserApi {
ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
.withBody(body)
.withPathParam("username", username)
- .withErrorResponse[Unit](404)
.withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
/**
* This can only be done by the logged in user.
*
* Expected answers:
- * code 404 : (User not found)
* code 400 : (Invalid username supplied)
+ * code 404 : (User not found)
*
* @param username The name that needs to be deleted
*/
def deleteUser(username: String): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
.withPathParam("username", username)
- .withErrorResponse[Unit](404)
.withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
diff --git a/samples/client/petstore/android-java/pom.xml b/samples/client/petstore/android-java/pom.xml
index 639000ecc6d9..f9c620b7528e 100644
--- a/samples/client/petstore/android-java/pom.xml
+++ b/samples/client/petstore/android-java/pom.xml
@@ -145,7 +145,7 @@
- 1.5.0
+ 1.5.4
2.3.1
4.8.1
1.0.0
diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java
index a16a745c7f8a..4c1bf7b1a3dd 100644
--- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java
+++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java
@@ -316,7 +316,7 @@ public class UserApi {
/**
* Get user by user name
*
- * @param username The name that needs to be fetched. Use user1 for testing.
+ * @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
public User getUserByName (String username) throws ApiException {
diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java
index 90a840e6e422..20865ad54340 100644
--- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java
+++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java
@@ -18,9 +18,9 @@ public class Pet {
@SerializedName("name")
private String name = null;
@SerializedName("photoUrls")
- private List photoUrls = new ArrayList() ;
+ private List photoUrls = null;
@SerializedName("tags")
- private List tags = new ArrayList() ;
+ private List tags = null;
public enum StatusEnum {
available, pending, sold,
};
diff --git a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala
index 4b6a2b155d9a..84b6ba4c7ead 100644
--- a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala
+++ b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala
@@ -145,8 +145,9 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c
}
- def deletePet(apiKey: Option[String] = None,
- petId: Long)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
+ def deletePet(petId: Long,
+ apiKey: Option[String] = None
+ )(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
// create path and map variables
val path = (addFmt("/pet/{petId}")
replaceAll ("\\{" + "petId" + "\\}",petId.toString))
diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
index 4e7e84fb7251..00bd7a5e9f2e 100644
--- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
+++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs
@@ -248,7 +248,7 @@ namespace IO.Swagger.Api
{
- var path = "/pet";
+ var path_ = "/pet";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -279,7 +279,7 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
@@ -298,7 +298,7 @@ namespace IO.Swagger.Api
{
- var path = "/pet";
+ var path_ = "/pet";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -329,7 +329,7 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
@@ -346,7 +346,7 @@ namespace IO.Swagger.Api
{
- var path = "/pet";
+ var path_ = "/pet";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -377,7 +377,7 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
@@ -396,7 +396,7 @@ namespace IO.Swagger.Api
{
- var path = "/pet";
+ var path_ = "/pet";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -427,7 +427,7 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
@@ -444,7 +444,7 @@ namespace IO.Swagger.Api
{
- var path = "/pet/findByStatus";
+ var path_ = "/pet/findByStatus";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -475,14 +475,14 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage);
- return (List) ApiClient.Deserialize(response.Content, typeof(List), response.Headers);
+ return (List) ApiClient.Deserialize(response, typeof(List));
}
///
@@ -494,7 +494,7 @@ namespace IO.Swagger.Api
{
- var path = "/pet/findByStatus";
+ var path_ = "/pet/findByStatus";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -525,11 +525,11 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
- return (List) ApiClient.Deserialize(response.Content, typeof(List), response.Headers);
+ return (List) ApiClient.Deserialize(response, typeof(List));
}
///
@@ -541,7 +541,7 @@ namespace IO.Swagger.Api
{
- var path = "/pet/findByTags";
+ var path_ = "/pet/findByTags";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -572,14 +572,14 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage);
- return (List) ApiClient.Deserialize(response.Content, typeof(List), response.Headers);
+ return (List) ApiClient.Deserialize(response, typeof(List));
}
///
@@ -591,7 +591,7 @@ namespace IO.Swagger.Api
{
- var path = "/pet/findByTags";
+ var path_ = "/pet/findByTags";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -622,11 +622,11 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
- return (List) ApiClient.Deserialize(response.Content, typeof(List), response.Headers);
+ return (List) ApiClient.Deserialize(response, typeof(List));
}
///
@@ -641,7 +641,7 @@ namespace IO.Swagger.Api
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById");
- var path = "/pet/{petId}";
+ var path_ = "/pet/{petId}";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -669,17 +669,17 @@ namespace IO.Swagger.Api
// authentication setting, if any
- String[] authSettings = new String[] { "api_key", "petstore_auth" };
+ String[] authSettings = new String[] { "api_key" };
// make the HTTP request
- IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage);
- return (Pet) ApiClient.Deserialize(response.Content, typeof(Pet), response.Headers);
+ return (Pet) ApiClient.Deserialize(response, typeof(Pet));
}
///
@@ -693,7 +693,7 @@ namespace IO.Swagger.Api
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById");
- var path = "/pet/{petId}";
+ var path_ = "/pet/{petId}";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -721,14 +721,14 @@ namespace IO.Swagger.Api
// authentication setting, if any
- String[] authSettings = new String[] { "api_key", "petstore_auth" };
+ String[] authSettings = new String[] { "api_key" };
// make the HTTP request
- IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
- return (Pet) ApiClient.Deserialize(response.Content, typeof(Pet), response.Headers);
+ return (Pet) ApiClient.Deserialize(response, typeof(Pet));
}
///
@@ -745,7 +745,7 @@ namespace IO.Swagger.Api
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
- var path = "/pet/{petId}";
+ var path_ = "/pet/{petId}";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -778,7 +778,7 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
@@ -801,7 +801,7 @@ namespace IO.Swagger.Api
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
- var path = "/pet/{petId}";
+ var path_ = "/pet/{petId}";
var pathParams = new Dictionary();
var queryParams = new Dictionary();
@@ -834,7 +834,7 @@ namespace IO.Swagger.Api
String[] authSettings = new String[] { "petstore_auth" };
// make the HTTP request
- IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
@@ -855,7 +855,7 @@ namespace IO.Swagger.Api
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet");
- var path = "/pet/{petId}";
+ var path_ = "/pet/{petId}";
var pathParams = new Dictionary();
var queryParams = new Dictionary