Skip to content

Commit 67fce61

Browse files
committed
Testing the QUERY method operation on example endpoint.
1 parent d7c355e commit 67fce61

4 files changed

Lines changed: 35 additions & 78 deletions

File tree

example/endpoints/list-users.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const users = [
2020
* */
2121
export const listUsersEndpoint = arrayRespondingFactory.build({
2222
tag: "users",
23+
method: "query",
2324
input: z.object({
2425
roles: z.array(roleSchema).optional(),
2526
}),

example/example.client.ts

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -160,49 +160,28 @@ interface PostV1UserCreateNegativeResponseVariants {
160160
500: PostV1UserCreateNegativeVariant2;
161161
}
162162

163-
/** get /v1/user/list */
164-
type GetV1UserListInput = {
163+
/** query /v1/user/list */
164+
type QueryV1UserListInput = {
165165
roles?: ("manager" | "operator" | "admin")[] | undefined;
166166
};
167167

168-
/** get /v1/user/list */
169-
type GetV1UserListPositiveVariant1 = {
168+
/** query /v1/user/list */
169+
type QueryV1UserListPositiveVariant1 = {
170170
name: string;
171171
role: "manager" | "operator" | "admin";
172172
}[];
173173

174-
/** get /v1/user/list */
175-
interface GetV1UserListPositiveResponseVariants {
176-
200: GetV1UserListPositiveVariant1;
174+
/** query /v1/user/list */
175+
interface QueryV1UserListPositiveResponseVariants {
176+
200: QueryV1UserListPositiveVariant1;
177177
}
178178

179-
/** get /v1/user/list */
180-
type GetV1UserListNegativeVariant1 = string;
179+
/** query /v1/user/list */
180+
type QueryV1UserListNegativeVariant1 = string;
181181

182-
/** get /v1/user/list */
183-
interface GetV1UserListNegativeResponseVariants {
184-
400: GetV1UserListNegativeVariant1;
185-
}
186-
187-
/** head /v1/user/list */
188-
type HeadV1UserListInput = {
189-
roles?: ("manager" | "operator" | "admin")[] | undefined;
190-
};
191-
192-
/** head /v1/user/list */
193-
type HeadV1UserListPositiveVariant1 = undefined;
194-
195-
/** head /v1/user/list */
196-
interface HeadV1UserListPositiveResponseVariants {
197-
200: HeadV1UserListPositiveVariant1;
198-
}
199-
200-
/** head /v1/user/list */
201-
type HeadV1UserListNegativeVariant1 = undefined;
202-
203-
/** head /v1/user/list */
204-
interface HeadV1UserListNegativeResponseVariants {
205-
400: HeadV1UserListNegativeVariant1;
182+
/** query /v1/user/list */
183+
interface QueryV1UserListNegativeResponseVariants {
184+
400: QueryV1UserListNegativeVariant1;
206185
}
207186

208187
/** post /v1/login */
@@ -572,8 +551,7 @@ export interface Input {
572551
"delete /v1/user/:id/remove": DeleteV1UserIdRemoveInput;
573552
"patch /v1/user/:id": PatchV1UserIdInput;
574553
"post /v1/user/create": PostV1UserCreateInput;
575-
"get /v1/user/list": GetV1UserListInput;
576-
"head /v1/user/list": HeadV1UserListInput;
554+
"query /v1/user/list": QueryV1UserListInput;
577555
"post /v1/login": PostV1LoginInput;
578556
/** @deprecated */
579557
"get /v1/avatar/send": GetV1AvatarSendInput;
@@ -596,8 +574,7 @@ export interface PositiveResponse {
596574
"delete /v1/user/:id/remove": SomeOf<DeleteV1UserIdRemovePositiveResponseVariants>;
597575
"patch /v1/user/:id": SomeOf<PatchV1UserIdPositiveResponseVariants>;
598576
"post /v1/user/create": SomeOf<PostV1UserCreatePositiveResponseVariants>;
599-
"get /v1/user/list": SomeOf<GetV1UserListPositiveResponseVariants>;
600-
"head /v1/user/list": SomeOf<HeadV1UserListPositiveResponseVariants>;
577+
"query /v1/user/list": SomeOf<QueryV1UserListPositiveResponseVariants>;
601578
"post /v1/login": SomeOf<PostV1LoginPositiveResponseVariants>;
602579
/** @deprecated */
603580
"get /v1/avatar/send": SomeOf<GetV1AvatarSendPositiveResponseVariants>;
@@ -620,8 +597,7 @@ export interface NegativeResponse {
620597
"delete /v1/user/:id/remove": SomeOf<DeleteV1UserIdRemoveNegativeResponseVariants>;
621598
"patch /v1/user/:id": SomeOf<PatchV1UserIdNegativeResponseVariants>;
622599
"post /v1/user/create": SomeOf<PostV1UserCreateNegativeResponseVariants>;
623-
"get /v1/user/list": SomeOf<GetV1UserListNegativeResponseVariants>;
624-
"head /v1/user/list": SomeOf<HeadV1UserListNegativeResponseVariants>;
600+
"query /v1/user/list": SomeOf<QueryV1UserListNegativeResponseVariants>;
625601
"post /v1/login": SomeOf<PostV1LoginNegativeResponseVariants>;
626602
/** @deprecated */
627603
"get /v1/avatar/send": SomeOf<GetV1AvatarSendNegativeResponseVariants>;
@@ -649,10 +625,8 @@ export interface EncodedResponse {
649625
PatchV1UserIdNegativeResponseVariants;
650626
"post /v1/user/create": PostV1UserCreatePositiveResponseVariants &
651627
PostV1UserCreateNegativeResponseVariants;
652-
"get /v1/user/list": GetV1UserListPositiveResponseVariants &
653-
GetV1UserListNegativeResponseVariants;
654-
"head /v1/user/list": HeadV1UserListPositiveResponseVariants &
655-
HeadV1UserListNegativeResponseVariants;
628+
"query /v1/user/list": QueryV1UserListPositiveResponseVariants &
629+
QueryV1UserListNegativeResponseVariants;
656630
"post /v1/login": PostV1LoginPositiveResponseVariants &
657631
PostV1LoginNegativeResponseVariants;
658632
/** @deprecated */
@@ -697,12 +671,9 @@ export interface Response {
697671
"post /v1/user/create":
698672
| PositiveResponse["post /v1/user/create"]
699673
| NegativeResponse["post /v1/user/create"];
700-
"get /v1/user/list":
701-
| PositiveResponse["get /v1/user/list"]
702-
| NegativeResponse["get /v1/user/list"];
703-
"head /v1/user/list":
704-
| PositiveResponse["head /v1/user/list"]
705-
| NegativeResponse["head /v1/user/list"];
674+
"query /v1/user/list":
675+
| PositiveResponse["query /v1/user/list"]
676+
| NegativeResponse["query /v1/user/list"];
706677
"post /v1/login":
707678
| PositiveResponse["post /v1/login"]
708679
| NegativeResponse["post /v1/login"];
@@ -751,8 +722,7 @@ export const endpointTags = {
751722
"delete /v1/user/:id/remove": ["users"],
752723
"patch /v1/user/:id": ["users"],
753724
"post /v1/user/create": ["users"],
754-
"get /v1/user/list": ["users"],
755-
"head /v1/user/list": ["users"],
725+
"query /v1/user/list": ["users"],
756726
"post /v1/login": ["cookies"],
757727
"get /v1/avatar/send": ["files", "users"],
758728
"head /v1/avatar/send": ["files", "users"],

example/example.documentation.yaml

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,15 @@ paths:
388388
- reason
389389
additionalProperties: false
390390
/v1/user/list:
391-
get:
392-
operationId: GetV1UserList
391+
query:
392+
operationId: QueryV1UserList
393393
tags:
394394
- users
395395
parameters:
396396
- name: roles
397397
in: query
398398
required: false
399-
description: GET /v1/user/list Parameter
399+
description: QUERY /v1/user/list Parameter
400400
schema:
401401
type: array
402402
items:
@@ -405,9 +405,16 @@ paths:
405405
- manager
406406
- operator
407407
- admin
408+
requestBody:
409+
description: QUERY /v1/user/list Request body
410+
content:
411+
application/json:
412+
schema:
413+
type: object
414+
properties: {}
408415
responses:
409416
"200":
410-
description: GET /v1/user/list Positive response
417+
description: QUERY /v1/user/list Positive response
411418
content:
412419
application/json:
413420
schema:
@@ -437,36 +444,14 @@ paths:
437444
- name: Patti Harrison
438445
role: admin
439446
"400":
440-
description: GET /v1/user/list Negative response
447+
description: QUERY /v1/user/list Negative response
441448
content:
442449
text/plain:
443450
schema:
444451
type: string
445452
examples:
446453
example1:
447454
value: Sample error message
448-
head:
449-
operationId: HeadV1UserList
450-
tags:
451-
- users
452-
parameters:
453-
- name: roles
454-
in: query
455-
required: false
456-
description: HEAD /v1/user/list Parameter
457-
schema:
458-
type: array
459-
items:
460-
type: string
461-
enum:
462-
- manager
463-
- operator
464-
- admin
465-
responses:
466-
"200":
467-
description: HEAD /v1/user/list Positive response
468-
"400":
469-
description: HEAD /v1/user/list Negative response
470455
/v1/login:
471456
post:
472457
operationId: PostV1Login

example/index.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ describe("Example", async () => {
117117
signal,
118118
}) => {
119119
const response = await fetch(`http://localhost:${port}/v1/user/list`, {
120+
method: "QUERY",
120121
signal,
121122
});
122123
expect(response.status).toBe(200);

0 commit comments

Comments
 (0)