add queryParams, headerParams, cookieParams and pathParams; optional APIDateFormat rendering
This commit is contained in:
parent
d6ba75e788
commit
407a1f211b
2
pom.xml
2
pom.xml
|
|
@ -5,7 +5,7 @@
|
|||
<artifactId>TINetworking-swagger-codegen</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>TINetworking-swagger-codegen</name>
|
||||
<version>1.0.0</version>
|
||||
<version>1.1.0</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
|||
|
|
@ -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<SupportingFile> supportingFiles() {
|
||||
List<SupportingFile> 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
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import TIFoundationUtils
|
||||
|
||||
{{#description}}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue