Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions example/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ exports[`Example > Client > Should perform the request with a positive response
{
"features": [
{
"features": [],
"title": "Above 180cm",
},
],
"title": "Tall",
},
{
"features": [],
"title": "Young",
},
{
"features": [
{
"features": [
{
"features": [],
"title": "About Typescript",
},
],
Expand Down Expand Up @@ -100,6 +103,45 @@ exports[`Example > Positive > Should accept raw data 1 1`] = `
}
`;

exports[`Example > Positive > Should handle valid GET request 1`] = `
{
"data": {
"features": [
{
"features": [
{
"features": [],
"title": "Above 180cm",
},
],
"title": "Tall",
},
{
"features": [],
"title": "Young",
},
{
"features": [
{
"features": [
{
"features": [],
"title": "About Typescript",
},
],
"title": "Tells funny jokes",
},
],
"title": "Cute",
},
],
"id": 50,
"name": "John Doe",
},
"status": "success",
}
`;

exports[`Example > Positive > Should send an image with a correct header 1`] = `"f39beeff92379dc935586d726211c2620be6f879"`;

exports[`Example > Positive > Should serve static files 1`] = `"f39beeff92379dc935586d726211c2620be6f879"`;
Expand Down
8 changes: 4 additions & 4 deletions example/endpoints/retrieve-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { methodProviderMiddleware } from "../middlewares";
const feature = z.object({
title: z.string(),
get features() {
return z.array(feature).optional();
return z.array(feature);
},
});

Expand Down Expand Up @@ -39,14 +39,14 @@ export const retrieveUserEndpoint = defaultEndpointsFactory
id,
name,
features: [
{ title: "Tall", features: [{ title: "Above 180cm" }] },
{ title: "Young" },
{ title: "Tall", features: [{ title: "Above 180cm", features: [] }] },
{ title: "Young", features: [] },
{
title: "Cute",
features: [
{
title: "Tells funny jokes",
features: [{ title: "About Typescript" }],
features: [{ title: "About Typescript", features: [] }],
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion example/example.client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type Type1 = {
title: string;
features?: Type1[] | undefined;
features: Type1[];
};

type SomeOf<T> = T[keyof T];
Expand Down
1 change: 1 addition & 0 deletions example/example.documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ components:
$ref: "#/components/schemas/Schema1"
required:
- title
- features
additionalProperties: false
responses: {}
parameters: {}
Expand Down
24 changes: 1 addition & 23 deletions example/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,7 @@ describe("Example", async () => {
);
expect(response.status).toBe(200);
const json = await response.json();
expect(json).toEqual({
status: "success",
data: {
id: 50,
name: "John Doe",
features: [
{
title: "Tall",
features: [{ title: "Above 180cm" }],
},
{ title: "Young" },
{
title: "Cute",
features: [
{
title: "Tells funny jokes",
features: [{ title: "About Typescript" }],
},
],
},
],
},
});
expect(json).toMatchSnapshot();
await vi.waitFor(() =>
assert([/v1\/user\/retrieve/, /50, method get/].every(matchOut)),
);
Expand Down
Loading