Skip to content

Commit 9a357b6

Browse files
committed
chore: latest petstore fixtures
1 parent 904def8 commit 9a357b6

4 files changed

Lines changed: 170 additions & 73 deletions

File tree

__tests__/fixtures/petstore.json

Lines changed: 111 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,46 @@
33
"info": {
44
"version": "1.0.0",
55
"title": "Swagger Petstore",
6+
"description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification",
7+
"termsOfService": "http://swagger.io/terms/",
8+
"contact": {
9+
"name": "Swagger API Team",
10+
"email": "apiteam@swagger.io",
11+
"url": "http://swagger.io"
12+
},
613
"license": {
7-
"name": "MIT"
14+
"name": "Apache 2.0",
15+
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
816
}
917
},
1018
"servers": [
1119
{
12-
"url": "http://petstore.swagger.io/v1"
20+
"url": "http://petstore.swagger.io/api"
1321
}
1422
],
1523
"paths": {
1624
"/pets": {
1725
"get": {
18-
"summary": "List all pets",
19-
"operationId": "listPets",
20-
"tags": [
21-
"pets"
22-
],
26+
"description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n",
27+
"operationId": "findPets",
2328
"parameters": [
29+
{
30+
"name": "tags",
31+
"in": "query",
32+
"description": "tags to filter by",
33+
"required": false,
34+
"style": "form",
35+
"schema": {
36+
"type": "array",
37+
"items": {
38+
"type": "string"
39+
}
40+
}
41+
},
2442
{
2543
"name": "limit",
2644
"in": "query",
27-
"description": "How many items to return at one time (max 100)",
45+
"description": "maximum number of results to return",
2846
"required": false,
2947
"schema": {
3048
"type": "integer",
@@ -34,19 +52,14 @@
3452
],
3553
"responses": {
3654
"200": {
37-
"description": "A paged array of pets",
38-
"headers": {
39-
"x-next": {
40-
"description": "A link to the next page of responses",
41-
"schema": {
42-
"type": "string"
43-
}
44-
}
45-
},
55+
"description": "pet response",
4656
"content": {
4757
"application/json": {
4858
"schema": {
49-
"$ref": "#/components/schemas/Pets"
59+
"type": "array",
60+
"items": {
61+
"$ref": "#/components/schemas/Pet"
62+
}
5063
}
5164
}
5265
}
@@ -64,14 +77,29 @@
6477
}
6578
},
6679
"post": {
67-
"summary": "Create a pet",
68-
"operationId": "createPets",
69-
"tags": [
70-
"pets"
71-
],
80+
"description": "Creates a new pet in the store. Duplicates are allowed",
81+
"operationId": "addPet",
82+
"requestBody": {
83+
"description": "Pet to add to the store",
84+
"required": true,
85+
"content": {
86+
"application/json": {
87+
"schema": {
88+
"$ref": "#/components/schemas/NewPet"
89+
}
90+
}
91+
}
92+
},
7293
"responses": {
73-
"201": {
74-
"description": "Null response"
94+
"200": {
95+
"description": "pet response",
96+
"content": {
97+
"application/json": {
98+
"schema": {
99+
"$ref": "#/components/schemas/Pet"
100+
}
101+
}
102+
}
75103
},
76104
"default": {
77105
"description": "unexpected error",
@@ -86,27 +114,25 @@
86114
}
87115
}
88116
},
89-
"/pets/{petId}": {
117+
"/pets/{id}": {
90118
"get": {
91-
"summary": "Info for a specific pet",
92-
"operationId": "showPetById",
93-
"tags": [
94-
"pets"
95-
],
119+
"description": "Returns a user based on a single ID, if the user does not have access to the pet",
120+
"operationId": "find pet by id",
96121
"parameters": [
97122
{
98-
"name": "petId",
123+
"name": "id",
99124
"in": "path",
125+
"description": "ID of pet to fetch",
100126
"required": true,
101-
"description": "The id of the pet to retrieve",
102127
"schema": {
103-
"type": "string"
128+
"type": "integer",
129+
"format": "int64"
104130
}
105131
}
106132
],
107133
"responses": {
108134
"200": {
109-
"description": "Expected response to a valid request",
135+
"description": "pet response",
110136
"content": {
111137
"application/json": {
112138
"schema": {
@@ -126,22 +152,67 @@
126152
}
127153
}
128154
}
155+
},
156+
"delete": {
157+
"description": "deletes a single pet based on the ID supplied",
158+
"operationId": "deletePet",
159+
"parameters": [
160+
{
161+
"name": "id",
162+
"in": "path",
163+
"description": "ID of pet to delete",
164+
"required": true,
165+
"schema": {
166+
"type": "integer",
167+
"format": "int64"
168+
}
169+
}
170+
],
171+
"responses": {
172+
"204": {
173+
"description": "pet deleted"
174+
},
175+
"default": {
176+
"description": "unexpected error",
177+
"content": {
178+
"application/json": {
179+
"schema": {
180+
"$ref": "#/components/schemas/Error"
181+
}
182+
}
183+
}
184+
}
185+
}
129186
}
130187
}
131188
},
132189
"components": {
133190
"schemas": {
134191
"Pet": {
192+
"allOf": [
193+
{
194+
"$ref": "#/components/schemas/NewPet"
195+
},
196+
{
197+
"type": "object",
198+
"required": [
199+
"id"
200+
],
201+
"properties": {
202+
"id": {
203+
"type": "integer",
204+
"format": "int64"
205+
}
206+
}
207+
}
208+
]
209+
},
210+
"NewPet": {
135211
"type": "object",
136212
"required": [
137-
"id",
138213
"name"
139214
],
140215
"properties": {
141-
"id": {
142-
"type": "integer",
143-
"format": "int64"
144-
},
145216
"name": {
146217
"type": "string"
147218
},
@@ -150,12 +221,6 @@
150221
}
151222
}
152223
},
153-
"Pets": {
154-
"type": "array",
155-
"items": {
156-
"$ref": "#/components/schemas/Pet"
157-
}
158-
},
159224
"Error": {
160225
"type": "object",
161226
"required": [

__tests__/fixtures/petstore/methods.ts

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,81 @@
33
*
44
* WARN: Do not edit directly.
55
*
6-
* Generated on 2022-09-07T12:10:34.214Z
6+
* Generated on 2022-10-29T10:44:17.417Z
77
*
88
*/
9-
import type { Error, ListPetsQuery, RequestMethodCaller } from './models.js';
9+
import type {
10+
RequestMethodCaller,
11+
FindPetsQuery,
12+
Pet,
13+
Error,
14+
NewPet,
15+
} from './models.js';
16+
import type { Simplify } from 'type-fest';
1017

1118
/**
12-
* listPets
13-
* @param params.query.limit? {String} How many items to return at one time (max 100)
14-
* @returns {RequestMethodCaller<Pets>} HTTP 200
19+
* Returns all pets from the system that the user has access to
20+
* Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.
21+
*
22+
* Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.
23+
* @param parameters.query.tags? {String} tags to filter by
24+
* @param parameters.query.limit? {String} maximum number of results to return
25+
* @returns {RequestMethodCaller<Pet[]>} HTTP 200
1526
* @returns {RequestMethodCaller<Error>} HTTP default
1627
*/
17-
export function listPets(params?: {
18-
query?: ListPetsQuery;
28+
export function findPets(parameters?: {
29+
query?: FindPetsQuery;
1930
}): RequestMethodCaller<Error> {
2031
const req = {
2132
method: 'get' as const,
2233
pathname: `/pets`,
23-
query: params?.query,
34+
query: parameters?.query,
2435
};
2536
return (requestMethod, options) => requestMethod(req, options);
2637
}
2738

2839
/**
29-
* createPets
30-
* @returns {RequestMethodCaller<void>} HTTP 201
40+
* Creates a new pet in the store. Duplicates are allowed
41+
*
42+
* @param parameters.body {NewPet}
43+
* @returns {RequestMethodCaller<Pet>} HTTP 200
3144
* @returns {RequestMethodCaller<Error>} HTTP default
3245
*/
33-
export function createPets(): RequestMethodCaller<Error> {
46+
export function addPet(parameters: {
47+
body: Simplify<NewPet>;
48+
}): RequestMethodCaller<Error> {
3449
const req = {
3550
method: 'post' as const,
3651
pathname: `/pets`,
52+
body: parameters.body,
3753
};
3854
return (requestMethod, options) => requestMethod(req, options);
3955
}
4056

4157
/**
42-
* showPetById
43-
* @param petId {String} The id of the pet to retrieve
58+
* Returns a user based on a single ID, if the user does not have access to the pet
59+
* @param id {String} ID of pet to fetch
4460
* @returns {RequestMethodCaller<Pet>} HTTP 200
4561
* @returns {RequestMethodCaller<Error>} HTTP default
4662
*/
47-
export function showPetById(petId: string): RequestMethodCaller<Error> {
63+
export function findPetById(id: string): RequestMethodCaller<Error> {
4864
const req = {
4965
method: 'get' as const,
50-
pathname: `/pets/${petId}`,
66+
pathname: `/pets/${id}`,
67+
};
68+
return (requestMethod, options) => requestMethod(req, options);
69+
}
70+
71+
/**
72+
* deletes a single pet based on the ID supplied
73+
* @param id {String} ID of pet to delete
74+
* @returns {RequestMethodCaller<void>} HTTP 204
75+
* @returns {RequestMethodCaller<Error>} HTTP default
76+
*/
77+
export function deletePet(id: string): RequestMethodCaller<Error> {
78+
const req = {
79+
method: 'delete' as const,
80+
pathname: `/pets/${id}`,
5181
};
5282
return (requestMethod, options) => requestMethod(req, options);
5383
}

__tests__/fixtures/petstore/models.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,40 @@
33
*
44
* WARN: Do not edit directly.
55
*
6-
* Generated on 2022-09-07T12:10:34.214Z
6+
* Generated on 2022-10-29T10:44:17.417Z
77
*
88
*/
99
export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'head';
10-
export type RequestParams = {
10+
export type RequestParameters = {
1111
pathname: string;
1212
method: HttpMethod;
13-
query?: Record<string, string | number> | undefined;
13+
query?: Record<string, string | number | string[] | number[]> | undefined;
1414
body?: unknown;
1515
headers?: Record<string, string>;
1616
};
1717
export type RuntimeOptions = {
1818
signal?: AbortSignal;
1919
};
2020
export type RequestMethod<T = any> = (
21-
params: RequestParams,
21+
params: RequestParameters,
2222
options?: RuntimeOptions,
2323
) => Promise<T>;
2424
export type RequestMethodCaller<T = unknown> = (
2525
requestMethod: RequestMethod<T>,
2626
options?: RuntimeOptions,
2727
) => Promise<T>;
28-
export type Pet = {
29-
id: number;
28+
export type NewPet = {
3029
name: string;
3130
tag?: string;
3231
};
33-
export type Pets = Pet[];
3432
export type Error = {
3533
code: number;
3634
message: string;
3735
};
38-
export type ListPetsQuery = {
39-
limit?: never;
36+
export type Pet = NewPet & {
37+
id: number;
38+
};
39+
export type FindPetsQuery = {
40+
tags?: string[];
41+
limit?: number;
4042
};

0 commit comments

Comments
 (0)