Skip to content

Commit 8283b70

Browse files
committed
fix java property with the name "class"
1 parent 514255c commit 8283b70

File tree

45 files changed

+272
-65
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+272
-65
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ public String toVarName(String name) {
471471
// sanitize name
472472
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
473473

474+
if ("class".equals(name.toLowerCase())) {
475+
return "PropertyClass";
476+
}
477+
474478
if("_".equals(name)) {
475479
name = "_u";
476480
}

modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,8 @@ definitions:
834834
name:
835835
type: integer
836836
format: int32
837+
class:
838+
type: string
837839
xml:
838840
name: Name
839841
Dog:

samples/client/petstore/java/default/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313

1414
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1515
hs_err_pid*
16+
17+
# build files
18+
**/target
19+
target
20+
.gradle
21+
build

samples/client/petstore/java/default/.swagger-codegen-ignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
1616
#foo/**/qux
17-
# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
1818

1919
# You can also negate patterns with an exclamation (!).
2020
# For example, you can ignore all files in a docs folder with the file extension .md:

samples/client/petstore/java/default/docs/Model200Response.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**name** | **Integer** | | [optional]
8+
**PropertyClass** | **String** | | [optional]
89

910

1011

samples/client/petstore/java/default/hello.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Model200Response.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
public class Model200Response {
1616

1717
private Integer name = null;
18+
private String PropertyClass = null;
1819

1920

2021
/**
@@ -34,6 +35,23 @@ public void setName(Integer name) {
3435
}
3536

3637

38+
/**
39+
**/
40+
public Model200Response PropertyClass(String PropertyClass) {
41+
this.PropertyClass = PropertyClass;
42+
return this;
43+
}
44+
45+
@ApiModelProperty(example = "null", value = "")
46+
@JsonProperty("class")
47+
public String getPropertyClass() {
48+
return PropertyClass;
49+
}
50+
public void setPropertyClass(String PropertyClass) {
51+
this.PropertyClass = PropertyClass;
52+
}
53+
54+
3755
@Override
3856
public boolean equals(java.lang.Object o) {
3957
if (this == o) {
@@ -43,12 +61,13 @@ public boolean equals(java.lang.Object o) {
4361
return false;
4462
}
4563
Model200Response _200Response = (Model200Response) o;
46-
return Objects.equals(this.name, _200Response.name);
64+
return Objects.equals(this.name, _200Response.name) &&
65+
Objects.equals(this.PropertyClass, _200Response.PropertyClass);
4766
}
4867

4968
@Override
5069
public int hashCode() {
51-
return Objects.hash(name);
70+
return Objects.hash(name, PropertyClass);
5271
}
5372

5473
@Override
@@ -57,6 +76,7 @@ public String toString() {
5776
sb.append("class Model200Response {\n");
5877

5978
sb.append(" name: ").append(toIndentedString(name)).append("\n");
79+
sb.append(" PropertyClass: ").append(toIndentedString(PropertyClass)).append("\n");
6080
sb.append("}");
6181
return sb.toString();
6282
}

samples/client/petstore/java/feign/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313

1414
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1515
hs_err_pid*
16+
17+
# build files
18+
**/target
19+
target
20+
.gradle
21+
build

samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public ApiClient(String[] authNames) {
4141
this();
4242
for(String authName : authNames) {
4343
RequestInterceptor auth;
44-
if (authName == "petstore_auth") {
45-
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
46-
} else if (authName == "api_key") {
44+
if (authName == "api_key") {
4745
auth = new ApiKeyAuth("header", "api_key");
46+
} else if (authName == "petstore_auth") {
47+
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
4848
} else {
4949
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
5050
}

samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
/**
2+
* Swagger Petstore
3+
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
*
5+
* OpenAPI spec version: 1.0.0
6+
* Contact: [email protected]
7+
*
8+
* NOTE: This class is auto generated by the swagger code generator program.
9+
* https://github.com/swagger-api/swagger-codegen.git
10+
* Do not edit the class manually.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*/
24+
25+
126
package io.swagger.client;
227

328

0 commit comments

Comments
 (0)