Skip to content

Commit

Permalink
[Go] Fix operation files clobbering model files. [2.4.0] (#7337)
Browse files Browse the repository at this point in the history
* Prevent operation files clobbering model files.

* Update Tests
  • Loading branch information
antihax authored and wing328 committed Jan 14, 2018
1 parent 3930b5b commit 72abb20
Show file tree
Hide file tree
Showing 60 changed files with 458 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,15 @@ public String toParamName(String name) {
public String toModelName(String name) {
// camelize the model name
// phone_number => PhoneNumber
return camelize(toModelFilename(name));
return camelize(toModel(name));
}

@Override
public String toModelFilename(String name) {
return toModel("model_" + name);
}

public String toModel(String name) {
if (!StringUtils.isEmpty(modelNamePrefix)) {
name = modelNamePrefix + "_" + name;
}
Expand Down Expand Up @@ -188,7 +192,7 @@ public String toApiFilename(String name) {
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.

// e.g. PetApi.go => pet_api.go
return underscore(name) + "_api";
return "api_" + underscore(name);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.go"));
supportingFiles.add(new SupportingFile("api_client.mustache", "", "api_client.go"));
supportingFiles.add(new SupportingFile("api_response.mustache", "", "api_response.go"));
supportingFiles.add(new SupportingFile("client.mustache", "", "client.go"));
supportingFiles.add(new SupportingFile("response.mustache", "", "response.go"));
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.4.0-SNAPSHOT
8 changes: 4 additions & 4 deletions samples/client/petstore/go/go-petstore/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ paths:
type: "array"
items:
type: "string"
default: "available"
enum:
- "available"
- "pending"
- "sold"
default: "available"
collectionFormat: "csv"
x-exportParamName: "Status"
responses:
Expand Down Expand Up @@ -634,10 +634,10 @@ paths:
type: "array"
items:
type: "string"
default: "$"
enum:
- ">"
- "$"
default: "$"
x-exportParamName: "EnumFormStringArray"
- name: "enum_form_string"
in: "formData"
Expand All @@ -657,10 +657,10 @@ paths:
type: "array"
items:
type: "string"
default: "$"
enum:
- ">"
- "$"
default: "$"
x-exportParamName: "EnumHeaderStringArray"
- name: "enum_header_string"
in: "header"
Expand All @@ -680,10 +680,10 @@ paths:
type: "array"
items:
type: "string"
default: "$"
enum:
- ">"
- "$"
default: "$"
x-exportParamName: "EnumQueryStringArray"
- name: "enum_query_string"
in: "query"
Expand Down

0 comments on commit 72abb20

Please sign in to comment.