Skip to content

Commit d0d0b5e

Browse files
committed
updated java retrofit sample
1 parent a3589cd commit d0d0b5e

Some content is hidden

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

46 files changed

+1156
-770
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.6-SNAPSHOT
1+
3.0.11-SNAPSHOT

samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import retrofit.http.*;
77
import retrofit.mime.*;
88

9+
import io.swagger.client.model.AllPetsResponse;
910
import java.io.File;
1011
import io.swagger.client.model.ModelApiResponse;
1112
import io.swagger.client.model.Pet;
13+
import io.swagger.client.model.SinglePetResponse;
1214
import java.util.ArrayList;
1315
import java.util.HashMap;
1416
import java.util.List;
@@ -105,6 +107,25 @@ List<Pet> findPetsByTags(
105107
void findPetsByTags(
106108
@retrofit.http.Query("tags") List<String> tags, Callback<List<Pet>> cb
107109
);
110+
/**
111+
*
112+
* Sync method
113+
*
114+
* @return AllPetsResponse
115+
*/
116+
@GET("/allPets")
117+
AllPetsResponse getAllPets();
118+
119+
120+
/**
121+
*
122+
* Async method
123+
* @param cb callback method
124+
*/
125+
@GET("/allPets")
126+
void getAllPets(
127+
Callback<AllPetsResponse> cb
128+
);
108129
/**
109130
* Find pet by ID
110131
* Sync method
@@ -127,6 +148,25 @@ Pet getPetById(
127148
void getPetById(
128149
@retrofit.http.Path("petId") Long petId, Callback<Pet> cb
129150
);
151+
/**
152+
*
153+
* Sync method
154+
*
155+
* @return SinglePetResponse
156+
*/
157+
@GET("/randomPet")
158+
SinglePetResponse getRandomPet();
159+
160+
161+
/**
162+
*
163+
* Async method
164+
* @param cb callback method
165+
*/
166+
@GET("/randomPet")
167+
void getRandomPet(
168+
Callback<SinglePetResponse> cb
169+
);
130170
/**
131171
* Update an existing pet
132172
* Sync method
@@ -189,7 +229,7 @@ void updatePetWithForm(
189229
@retrofit.http.Multipart
190230
@POST("/pet/{petId}/uploadImage")
191231
ModelApiResponse uploadFile(
192-
@retrofit.http.Path("petId") Long petId, @retrofit.http.Part("additionalMetadata") String additionalMetadata, @retrofit.http.Part("file") File file
232+
@retrofit.http.Path("petId") Long petId, @retrofit.http.Part("additionalMetadata") String additionalMetadata, @retrofit.http.Part("file") TypedFile file
193233
);
194234

195235
/**
@@ -203,6 +243,6 @@ ModelApiResponse uploadFile(
203243
@retrofit.http.Multipart
204244
@POST("/pet/{petId}/uploadImage")
205245
void uploadFile(
206-
@retrofit.http.Path("petId") Long petId, @retrofit.http.Part("additionalMetadata") String additionalMetadata, @retrofit.http.Part("file") File file, Callback<ModelApiResponse> cb
246+
@retrofit.http.Path("petId") Long petId, @retrofit.http.Part("additionalMetadata") String additionalMetadata, @retrofit.http.Part("file") TypedFile file, Callback<ModelApiResponse> cb
207247
);
208248
}

samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package io.swagger.client.model;
1414

1515
import java.util.Objects;
16+
import java.util.Arrays;
1617
import com.google.gson.TypeAdapter;
1718
import com.google.gson.annotations.JsonAdapter;
1819
import com.google.gson.annotations.SerializedName;
@@ -23,66 +24,71 @@
2324
import java.util.HashMap;
2425
import java.util.List;
2526
import java.util.Map;
26-
2727
/**
2828
* AdditionalPropertiesClass
2929
*/
3030

31-
public class AdditionalPropertiesClass {
3231

32+
public class AdditionalPropertiesClass {
3333
@SerializedName("map_property")
3434
private Map<String, String> mapProperty = null;
3535

3636
@SerializedName("map_of_map_property")
3737
private Map<String, Map<String, String>> mapOfMapProperty = null;
38+
3839
public AdditionalPropertiesClass mapProperty(Map<String, String> mapProperty) {
3940
this.mapProperty = mapProperty;
4041
return this;
4142
}
4243

43-
4444
public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) {
4545
if (this.mapProperty == null) {
4646
this.mapProperty = new HashMap<String, String>();
4747
}
4848
this.mapProperty.put(key, mapPropertyItem);
4949
return this;
5050
}
51-
/**
52-
* Get mapProperty
53-
* @return mapProperty
51+
52+
/**
53+
* Get mapProperty
54+
* @return mapProperty
5455
**/
5556
@Schema(description = "")
5657
public Map<String, String> getMapProperty() {
5758
return mapProperty;
5859
}
60+
5961
public void setMapProperty(Map<String, String> mapProperty) {
6062
this.mapProperty = mapProperty;
6163
}
64+
6265
public AdditionalPropertiesClass mapOfMapProperty(Map<String, Map<String, String>> mapOfMapProperty) {
6366
this.mapOfMapProperty = mapOfMapProperty;
6467
return this;
6568
}
6669

67-
6870
public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map<String, String> mapOfMapPropertyItem) {
6971
if (this.mapOfMapProperty == null) {
7072
this.mapOfMapProperty = new HashMap<String, Map<String, String>>();
7173
}
7274
this.mapOfMapProperty.put(key, mapOfMapPropertyItem);
7375
return this;
7476
}
75-
/**
76-
* Get mapOfMapProperty
77-
* @return mapOfMapProperty
77+
78+
/**
79+
* Get mapOfMapProperty
80+
* @return mapOfMapProperty
7881
**/
7982
@Schema(description = "")
8083
public Map<String, Map<String, String>> getMapOfMapProperty() {
8184
return mapOfMapProperty;
8285
}
86+
8387
public void setMapOfMapProperty(Map<String, Map<String, String>> mapOfMapProperty) {
8488
this.mapOfMapProperty = mapOfMapProperty;
8589
}
90+
91+
8692
@Override
8793
public boolean equals(java.lang.Object o) {
8894
if (this == o) {
@@ -98,9 +104,10 @@ public boolean equals(java.lang.Object o) {
98104

99105
@Override
100106
public int hashCode() {
101-
return java.util.Objects.hash(mapProperty, mapOfMapProperty);
107+
return Objects.hash(mapProperty, mapOfMapProperty);
102108
}
103109

110+
104111
@Override
105112
public String toString() {
106113
StringBuilder sb = new StringBuilder();
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
13+
package io.swagger.client.model;
14+
15+
import java.util.Objects;
16+
import java.util.Arrays;
17+
import io.swagger.client.model.OneOfAllPetsResponseItems;
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
/**
21+
* AllPetsResponse
22+
*/
23+
24+
25+
public class AllPetsResponse extends ArrayList<OneOfAllPetsResponseItems> {
26+
27+
@Override
28+
public boolean equals(java.lang.Object o) {
29+
if (this == o) {
30+
return true;
31+
}
32+
if (o == null || getClass() != o.getClass()) {
33+
return false;
34+
}
35+
return super.equals(o);
36+
}
37+
38+
@Override
39+
public int hashCode() {
40+
return Objects.hash(super.hashCode());
41+
}
42+
43+
44+
@Override
45+
public String toString() {
46+
StringBuilder sb = new StringBuilder();
47+
sb.append("class AllPetsResponse {\n");
48+
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
49+
sb.append("}");
50+
return sb.toString();
51+
}
52+
53+
/**
54+
* Convert the given object to string with each line indented by 4 spaces
55+
* (except the first line).
56+
*/
57+
private String toIndentedString(java.lang.Object o) {
58+
if (o == null) {
59+
return "null";
60+
}
61+
return o.toString().replace("\n", "\n ");
62+
}
63+
64+
}

samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Animal.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,67 @@
1313
package io.swagger.client.model;
1414

1515
import java.util.Objects;
16+
import java.util.Arrays;
1617
import com.google.gson.TypeAdapter;
1718
import com.google.gson.annotations.JsonAdapter;
1819
import com.google.gson.annotations.SerializedName;
1920
import com.google.gson.stream.JsonReader;
2021
import com.google.gson.stream.JsonWriter;
2122
import io.swagger.v3.oas.annotations.media.Schema;
2223
import java.io.IOException;
23-
2424
/**
2525
* Animal
2626
*/
2727

2828

29-
public class Animal {
3029

30+
public class Animal {
3131
@SerializedName("className")
3232
private String className = null;
3333

3434
@SerializedName("color")
3535
private String color = "red";
36+
37+
public Animal() {
38+
this.className = this.getClass().getSimpleName();
39+
}
3640
public Animal className(String className) {
3741
this.className = className;
3842
return this;
3943
}
4044

41-
42-
43-
/**
44-
* Get className
45-
* @return className
45+
/**
46+
* Get className
47+
* @return className
4648
**/
4749
@Schema(required = true, description = "")
4850
public String getClassName() {
4951
return className;
5052
}
53+
5154
public void setClassName(String className) {
5255
this.className = className;
5356
}
57+
5458
public Animal color(String color) {
5559
this.color = color;
5660
return this;
5761
}
5862

59-
60-
61-
/**
62-
* Get color
63-
* @return color
63+
/**
64+
* Get color
65+
* @return color
6466
**/
6567
@Schema(description = "")
6668
public String getColor() {
6769
return color;
6870
}
71+
6972
public void setColor(String color) {
7073
this.color = color;
7174
}
75+
76+
7277
@Override
7378
public boolean equals(java.lang.Object o) {
7479
if (this == o) {
@@ -84,9 +89,10 @@ public boolean equals(java.lang.Object o) {
8489

8590
@Override
8691
public int hashCode() {
87-
return java.util.Objects.hash(className, color);
92+
return Objects.hash(className, color);
8893
}
8994

95+
9096
@Override
9197
public String toString() {
9298
StringBuilder sb = new StringBuilder();

samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/AnimalFarm.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
package io.swagger.client.model;
1414

1515
import java.util.Objects;
16+
import java.util.Arrays;
1617
import io.swagger.client.model.Animal;
1718
import java.util.ArrayList;
1819
import java.util.List;
19-
2020
/**
2121
* AnimalFarm
2222
*/
2323

24+
2425
public class AnimalFarm extends ArrayList<Animal> {
26+
2527
@Override
2628
public boolean equals(java.lang.Object o) {
2729
if (this == o) {
@@ -35,9 +37,10 @@ public boolean equals(java.lang.Object o) {
3537

3638
@Override
3739
public int hashCode() {
38-
return java.util.Objects.hash(super.hashCode());
40+
return Objects.hash(super.hashCode());
3941
}
4042

43+
4144
@Override
4245
public String toString() {
4346
StringBuilder sb = new StringBuilder();

0 commit comments

Comments
 (0)