Skip to content

Commit 42002d5

Browse files
authored
Merge pull request #9647 from swagger-api/samples_update
Samples update
2 parents d4704e5 + 1e28a45 commit 42002d5

File tree

689 files changed

+17641
-10843
lines changed

Some content is hidden

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

689 files changed

+17641
-10843
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,31 @@ paths:
290290
- petstore_auth:
291291
- write:pets
292292
- read:pets
293+
/randomPet:
294+
get:
295+
tags:
296+
- pet
297+
operationId: getRandomPet
298+
responses:
299+
'200':
300+
description: "a single random pet"
301+
content:
302+
application/json:
303+
schema:
304+
$ref: '#/components/schemas/SinglePetResponse'
305+
/allPets:
306+
get:
307+
tags:
308+
- pet
309+
operationId: getAllPets
310+
responses:
311+
'200':
312+
description: "a single random pet"
313+
content:
314+
application/json:
315+
schema:
316+
$ref: '#/components/schemas/AllPetsResponse'
317+
293318
/store/inventory:
294319
get:
295320
tags:
@@ -1787,6 +1812,25 @@ components:
17871812
- name: "name"
17881813
id: 1
17891814
status: "available"
1815+
1816+
SinglePetResponse:
1817+
type: object
1818+
properties:
1819+
pet:
1820+
oneOf:
1821+
- $ref: "#/components/schemas/Dog"
1822+
- $ref: "#/components/schemas/Cat"
1823+
discriminator:
1824+
propertyName: pet_type
1825+
AllPetsResponse:
1826+
type: array
1827+
items:
1828+
oneOf:
1829+
- $ref: "#/components/schemas/Dog"
1830+
- $ref: "#/components/schemas/Cat"
1831+
discriminator:
1832+
propertyName: pet_type
1833+
17901834
hasOnlyReadOnly:
17911835
type: object
17921836
properties:

modules/swagger-codegen/src/test/resources/3_0_0/petstore.yaml

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,30 @@ paths:
264264
schema:
265265
type: string
266266
format: binary
267+
/randomPet:
268+
get:
269+
tags:
270+
- pet
271+
operationId: getRandomPet
272+
responses:
273+
'200':
274+
description: "a single random pet"
275+
content:
276+
application/json:
277+
schema:
278+
$ref: '#/components/schemas/SinglePetResponse'
279+
/allPets:
280+
get:
281+
tags:
282+
- pet
283+
operationId: getAllPets
284+
responses:
285+
'200':
286+
description: "a single random pet"
287+
content:
288+
application/json:
289+
schema:
290+
$ref: '#/components/schemas/AllPetsResponse'
267291
/store/inventory:
268292
get:
269293
tags:
@@ -649,6 +673,45 @@ components:
649673
- sold
650674
xml:
651675
name: Pet
676+
677+
SinglePetResponse:
678+
type: object
679+
properties:
680+
pet:
681+
oneOf:
682+
- $ref: "#/components/schemas/Dog"
683+
- $ref: "#/components/schemas/Cat"
684+
discriminator:
685+
propertyName: pet_type
686+
AllPetsResponse:
687+
type: array
688+
items:
689+
oneOf:
690+
- $ref: "#/components/schemas/Dog"
691+
- $ref: "#/components/schemas/Cat"
692+
discriminator:
693+
propertyName: pet_type
694+
695+
Dog:
696+
allOf:
697+
- $ref: '#/components/schemas/Pet'
698+
- type: object
699+
properties:
700+
bark:
701+
type: boolean
702+
breed:
703+
type: string
704+
enum: [Dingo, Husky, Retriever, Shepherd]
705+
Cat:
706+
allOf:
707+
- $ref: '#/components/schemas/Pet'
708+
- type: object
709+
properties:
710+
hunts:
711+
type: boolean
712+
age:
713+
type: integer
714+
652715
ApiResponse:
653716
type: object
654717
properties:
@@ -697,4 +760,4 @@ components:
697760
api_key:
698761
type: apiKey
699762
name: api_key
700-
in: header
763+
in: header

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import io.swagger.client.ApiClient;
44
import io.swagger.client.EncodingUtils;
55

6+
import io.swagger.client.model.AllPetsResponse;
67
import java.io.File;
78
import io.swagger.client.model.ModelApiResponse;
89
import io.swagger.client.model.Pet;
10+
import io.swagger.client.model.SinglePetResponse;
911

1012
import java.util.ArrayList;
1113
import java.util.HashMap;
@@ -129,6 +131,16 @@ public FindPetsByTagsQueryParams tags(final List<String> value) {
129131
return this;
130132
}
131133
}
134+
/**
135+
*
136+
*
137+
* @return AllPetsResponse
138+
*/
139+
@RequestLine("GET /allPets")
140+
@Headers({
141+
"Accept: application/json",
142+
})
143+
AllPetsResponse getAllPets();
132144
/**
133145
* Find pet by ID
134146
* Returns a single pet
@@ -140,6 +152,16 @@ public FindPetsByTagsQueryParams tags(final List<String> value) {
140152
"Accept: application/json",
141153
})
142154
Pet getPetById(@Param("petId") Long petId);
155+
/**
156+
*
157+
*
158+
* @return SinglePetResponse
159+
*/
160+
@RequestLine("GET /randomPet")
161+
@Headers({
162+
"Accept: application/json",
163+
})
164+
SinglePetResponse getRandomPet();
143165
/**
144166
* Update an existing pet
145167
*
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/feign/src/main/java/io/swagger/client/model/Cat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626

27-
public class Cat extends Animal {
27+
public class Cat extends Animal implements OneOfAllPetsResponseItems, OneOfSinglePetResponsePet {
2828
@JsonProperty("declawed")
2929
private Boolean declawed = null;
3030

samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626

27-
public class Dog extends Animal {
27+
public class Dog extends Animal implements OneOfAllPetsResponseItems, OneOfSinglePetResponsePet {
2828
@JsonProperty("breed")
2929
private String breed = null;
3030

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
/**
16+
* OneOfAllPetsResponseItems
17+
*/
18+
public interface OneOfAllPetsResponseItems {
19+
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
/**
16+
* OneOfSinglePetResponsePet
17+
*/
18+
public interface OneOfSinglePetResponsePet {
19+
20+
}

0 commit comments

Comments
 (0)