diff --git a/pom.xml b/pom.xml
index 805fe76..cf05766 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
TINetworking-swagger-codegen
jar
TINetworking-swagger-codegen
- 1.0.0
+ 1.1.0
diff --git a/src/main/java/ru/touchin/codegen/TINetworkingCodegen.java b/src/main/java/ru/touchin/codegen/TINetworkingCodegen.java
index 03c8749..a53e295 100644
--- a/src/main/java/ru/touchin/codegen/TINetworkingCodegen.java
+++ b/src/main/java/ru/touchin/codegen/TINetworkingCodegen.java
@@ -131,7 +131,7 @@ public class TINetworkingCodegen extends DefaultCodegenConfig {
"Array", "Dictionary", "Set", "OptionSet", "CountableRange", "CountableClosedRange",
// The following are commonly-used Foundation types
- "URL", "Data", "Codable", "Encodable", "Decodable",
+ "URL", "Data", "Date", "Codable", "Encodable", "Decodable",
// The following are other words we want to reserve
"Void", "AnyObject", "Class", "dynamicType", "COLUMN", "FILE", "FUNCTION", "LINE"
@@ -208,10 +208,6 @@ public class TINetworkingCodegen extends DefaultCodegenConfig {
sourceFolder,
projectName + "+Servers.swift"));
- supportingFiles.add(new SupportingFile("APIDateFormat.mustache",
- sourceFolder,
- "APIDateFormat.swift"));
-
supportingFiles.add(new SupportingFile("Plugins.mustache",
sourceFolder,
"Plugins.swift"));
@@ -219,6 +215,19 @@ public class TINetworkingCodegen extends DefaultCodegenConfig {
copyFistAllOfProperties = true;
}
+ @Override
+ public List supportingFiles() {
+ List supportingFiles = super.supportingFiles();
+
+ if (!allCustomDateFormats.isEmpty()) {
+ supportingFiles.add(new SupportingFile("APIDateFormat.mustache",
+ sourceFolder,
+ "APIDateFormat.swift"));
+ }
+
+ return supportingFiles;
+ }
+
@Override
protected boolean isReservedWord(String word) {
return word != null && reservedWords.contains(word); //don't lowercase as super does
diff --git a/src/main/resources/handlebars/TINetworking/api.mustache b/src/main/resources/handlebars/TINetworking/api.mustache
index f91c3a5..f8493fa 100644
--- a/src/main/resources/handlebars/TINetworking/api.mustache
+++ b/src/main/resources/handlebars/TINetworking/api.mustache
@@ -36,12 +36,39 @@ public extension EndpointRequest {
- parameter {{paramName}}: {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/parameters}}
*/
- static func {{operationId}}({{#parameters}}{{paramName}}: {{#isEnum}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/parameters}}{{#hasParams}}, {{/hasParams}}server: Server? = nil) -> EndpointRequest<{{#parameters}}{{#isBodyParam}}{{{dataType}}}{{/isBodyParam}}{{/parameters}}{{^hasBodyParam}}EmptyBody{{/hasBodyParam}}, {{{returnType}}}> {
+ static func {{operationId}}({{#parameters}}{{paramName}}: {{#isEnum}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/parameters}}{{#hasParams}}, {{/hasParams}}server: Server? = nil) -> EndpointRequest<{{#parameters}}{{#isBodyParam}}{{{dataType}}}{{/isBodyParam}}{{/parameters}}{{^hasBodyParam}}Nothing{{/hasBodyParam}}, {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Nothing{{/returnType}}> {
.init(templatePath: "{{{path}}}",
- method: .init(rawValue: "{{httpMethod}}"),
- body: {{#hasBodyParam}}body{{/hasBodyParam}}{{^hasBodyParam}}EmptyBody(){{/hasBodyParam}},
- acceptableStatusCodes: [{{contentExtensions.x-codegen-acceptable-status-codes}}],
- server: server)
+ method: .init(rawValue: "{{httpMethod}}"),
+ body: {{#hasBodyParam}}body{{/hasBodyParam}}{{^hasBodyParam}}nil{{/hasBodyParam}},
+ {{#hasQueryParams}}
+ queryParameters: [
+ {{#each queryParams}}
+ "{{{this.paramName}}}": .init(value: {{{this.paramName}}}, allowEmptyValue: {{#this.required}}false{{/this.required}}{{^this.required}}true{{/this.required}}),
+ {{/each}}],
+ {{/hasQueryParams}}
+ {{#hasPathParams}}
+ pathParameters: [
+ {{#each pathParams}}
+ "{{{this.paramName}}}": .init(value: {{{this.paramName}}}, allowEmptyValue: {{#this.required}}false{{/this.required}}{{^this.required}}true{{/this.required}}),
+ {{/each}}],
+ {{/hasPathParams}}
+ {{#hasHeaderParams}}
+ headerParameters: [
+ {{#each headerParams}}
+ "{{{this.paramName}}}": .init(value: {{{this.paramName}}}, allowEmptyValue: {{#this.required}}false{{/this.required}}{{^this.required}}true{{/this.required}}),
+ {{/each}}],
+ {{/hasHeaderParams}}
+ {{^hasHeaderParams}}
+ headerParameters: nil,
+ {{/hasHeaderParams}}
+ {{#hasCookieParams}}
+ cookieParameters: [
+ {{#each cookieParams}}
+ "{{{this.paramName}}}": .init(value: {{{this.paramName}}}, allowEmptyValue: {{#this.required}}false{{/this.required}}{{^this.required}}true{{/this.required}}),
+ {{/each}}],
+ {{/hasCookieParams}}
+ acceptableStatusCodes: [{{contentExtensions.x-codegen-acceptable-status-codes}}],
+ server: server)
}
{{/contents}}
{{/operation}}
diff --git a/src/main/resources/handlebars/TINetworking/model.mustache b/src/main/resources/handlebars/TINetworking/model.mustache
index c929246..88554d0 100644
--- a/src/main/resources/handlebars/TINetworking/model.mustache
+++ b/src/main/resources/handlebars/TINetworking/model.mustache
@@ -6,6 +6,7 @@
//
import Foundation
+import TIFoundationUtils
{{#description}}