Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
protected boolean swiftUseApiNamespace;
protected String[] responseAs = new String[0];
protected String sourceFolder = "Classes" + File.separator + "Swaggers";
private static final Pattern PATH_PARAM_PATTERN = Pattern.compile("\\{[a-zA-Z_]+\\}");

@Override
public CodegenType getTag() {
Expand Down Expand Up @@ -455,40 +454,6 @@ public CodegenModel fromModel(String name, Model model, Map<String, Model> allDe
return codegenModel;
}

@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
path = normalizePath(path); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// issue 3914 - removed logic designed to remove any parameter of type HeaderParameter
return super.fromOperation(path, httpMethod, operation, definitions, swagger);
}

private static String normalizePath(String path) {
StringBuilder builder = new StringBuilder();

int cursor = 0;
Matcher matcher = PATH_PARAM_PATTERN.matcher(path);
boolean found = matcher.find();
while (found) {
String stringBeforeMatch = path.substring(cursor, matcher.start());
builder.append(stringBeforeMatch);

String group = matcher.group().substring(1, matcher.group().length() - 1);
group = camelize(group, true);
builder
.append("{")
.append(group)
.append("}");

cursor = matcher.end();
found = matcher.find();
}

String stringAfterMatch = path.substring(cursor);
builder.append(stringAfterMatch);

return builder.toString();
}

public void setProjectName(String projectName) {
this.projectName = projectName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}.rawValue{{/isContainer}}{{/isEnum}}{{#isDate}}{{^required}}?{{/required}}.encodeToJSON(){{/isDate}}{{#isDateTime}}{{^required}}?{{/required}}.encodeToJSON(){{/isDateTime}}
"{{baseName}}": {{paramName}}{{^isEnum}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{/isEnum}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}.rawValue{{/isContainer}}{{/isEnum}}{{#isDate}}{{^required}}?{{/required}}.encodeToJSON(){{/isDate}}{{#isDateTime}}{{^required}}?{{/required}}.encodeToJSON(){{/isDateTime}}
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ paths:
$ref: '#/definitions/Order'
'400':
description: Invalid Order
'/store/order/{orderId}':
'/store/order/{order_id}':
get:
tags:
- store
Expand All @@ -335,7 +335,7 @@ paths:
- application/xml
- application/json
parameters:
- name: orderId
- name: order_id
in: path
description: ID of pet that needs to be fetched
required: true
Expand All @@ -362,7 +362,7 @@ paths:
- application/xml
- application/json
parameters:
- name: orderId
- name: order_id
in: path
description: ID of the order that needs to be deleted
required: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ open class FakeAPI: APIBase {
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
"enum_query_string_array": enumQueryStringArray,
"enum_query_string": enumQueryString?.rawValue,
"enum_query_integer": enumQueryInteger?.encodeToJSON()?.rawValue
"enum_query_integer": enumQueryInteger?.rawValue
])

let nillableHeaders: [String: Any?] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class StoreAPI: APIBase {
*/
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
var path = "/store/order/{orderId}"
path = path.replacingOccurrences(of: "{orderId}", with: "\(orderId)", options: .literal, range: nil)
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil

Expand Down Expand Up @@ -138,7 +138,7 @@ open class StoreAPI: APIBase {
*/
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
var path = "/store/order/{orderId}"
path = path.replacingOccurrences(of: "{orderId}", with: "\(orderId)", options: .literal, range: nil)
path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Alamofire: fef59f00388f267e52d9b432aa5d93dc97190f14
PetstoreClient: bbde3383c51466fdda24ec28153ce2847ae5456f
PetstoreClient: 0f65d85b2a09becd32938348b3783a9394a07346

PODFILE CHECKSUM: da9f5a7ad6086f2c7abb73cf2c35cefce04a9a30

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading