Skip to content

Commit 09560d2

Browse files
the-ultclaude
andcommitted
test: cover runtimeValidation both strategy across clients
Add a dedicated `runtime-validation` generation config exercising `{ strategy: 'both' }` on the fetch, angular HttpClient, and angular httpResource clients (the rxjs-map, clone-expression, fetch-assign and parse-fn emit contexts), plus its generated snapshots. All existing throw/boolean snapshots regenerate byte-identically. Add angular-app sample runtime tests that feed an invalid payload to a `both`-configured HttpClient service and assert the raw ZodError is logged via console.error AND surfaces through the RxJS error channel, while a valid payload passes through (with Zod output defaults applied) without logging. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ee96e7b commit 09560d2

74 files changed

Lines changed: 6012 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { getPetsMock } from './pets/pets.msw';
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
import { z as zod } from 'zod';
8+
9+
export const createPetsBodyNameMax = 100;
10+
11+
export const createPetsBodyTagMax = 50;
12+
13+
export const createPetsBodyStatusDefault = `available`;
14+
export const CreatePetsBody = zod.object({
15+
name: zod
16+
.string()
17+
.min(1)
18+
.max(createPetsBodyNameMax)
19+
.describe('Name of the pet'),
20+
tag: zod
21+
.string()
22+
.min(1)
23+
.max(createPetsBodyTagMax)
24+
.describe('Classification tag'),
25+
email: zod.email().optional().describe('Owner contact email'),
26+
status: zod
27+
.enum(['available', 'pending', 'sold'])
28+
.default(createPetsBodyStatusDefault)
29+
.describe('Initial adoption status'),
30+
});
31+
32+
export type CreatePetsBody = zod.input<typeof CreatePetsBody>;
33+
export type CreatePetsBodyOutput = zod.output<typeof CreatePetsBody>;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
import { z as zod } from 'zod';
8+
9+
export const errorCodeMin = 100;
10+
export const errorCodeMax = 600;
11+
12+
export const Error = zod.object({
13+
code: zod
14+
.number()
15+
.min(errorCodeMin)
16+
.max(errorCodeMax)
17+
.describe('HTTP-like error code'),
18+
message: zod.string().min(1).describe('Human-readable error message'),
19+
});
20+
21+
export type Error = zod.input<typeof Error>;
22+
export type ErrorOutput = zod.output<typeof Error>;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
8+
export * from './createPetsBody.zod';
9+
export * from './error.zod';
10+
export * from './listPetsParams.zod';
11+
export * from './patchPetByIdBody.zod';
12+
export * from './pet.zod';
13+
export * from './pets.zod';
14+
export * from './searchPetsParams.zod';
15+
export * from './updatePetByIdBody.zod';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
import { z as zod } from 'zod';
8+
9+
export const ListPetsParams = zod.object({
10+
limit: zod.string().optional(),
11+
});
12+
13+
export type ListPetsParams = zod.input<typeof ListPetsParams>;
14+
export type ListPetsParamsOutput = zod.output<typeof ListPetsParams>;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
import { z as zod } from 'zod';
8+
9+
export const patchPetByIdBodyNameMax = 100;
10+
11+
export const patchPetByIdBodyTagMax = 50;
12+
13+
export const patchPetByIdBodyStatusDefault = `available`;
14+
export const patchPetByIdBodyAgeMin = 0;
15+
export const patchPetByIdBodyAgeMax = 30;
16+
17+
export const patchPetByIdBodyRatingMin = 0;
18+
export const patchPetByIdBodyRatingMax = 5;
19+
export const patchPetByIdBodyRatingMultipleOf = 0.5;
20+
21+
export const patchPetByIdBodyPhoneRegExp = new RegExp('^\\+?[1-9]\\d{1,14}$');
22+
23+
export const PatchPetByIdBody = zod.object({
24+
id: zod.number().min(1).describe('Unique identifier for the pet'),
25+
name: zod
26+
.string()
27+
.min(1)
28+
.max(patchPetByIdBodyNameMax)
29+
.describe('Name of the pet'),
30+
tag: zod
31+
.string()
32+
.min(1)
33+
.max(patchPetByIdBodyTagMax)
34+
.optional()
35+
.describe('Optional classification tag'),
36+
email: zod.email().optional().describe('Owner contact email'),
37+
status: zod
38+
.enum(['available', 'pending', 'sold'])
39+
.default(patchPetByIdBodyStatusDefault)
40+
.describe('Current adoption status'),
41+
age: zod
42+
.number()
43+
.min(patchPetByIdBodyAgeMin)
44+
.max(patchPetByIdBodyAgeMax)
45+
.optional()
46+
.describe('Age of the pet in years'),
47+
rating: zod
48+
.number()
49+
.min(patchPetByIdBodyRatingMin)
50+
.max(patchPetByIdBodyRatingMax)
51+
.multipleOf(patchPetByIdBodyRatingMultipleOf)
52+
.optional()
53+
.describe('Average customer rating'),
54+
phone: zod
55+
.string()
56+
.regex(patchPetByIdBodyPhoneRegExp)
57+
.optional()
58+
.describe('Contact phone in E.164 format'),
59+
requiredNullableString: zod.string().nullable(),
60+
optionalNullableString: zod.string().nullish(),
61+
});
62+
63+
export type PatchPetByIdBody = zod.input<typeof PatchPetByIdBody>;
64+
export type PatchPetByIdBodyOutput = zod.output<typeof PatchPetByIdBody>;
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
import { z as zod } from 'zod';
8+
9+
export const petNameMax = 100;
10+
11+
export const petTagMax = 50;
12+
13+
export const petStatusDefault = `available`;
14+
export const petAgeMin = 0;
15+
export const petAgeMax = 30;
16+
17+
export const petRatingMin = 0;
18+
export const petRatingMax = 5;
19+
export const petRatingMultipleOf = 0.5;
20+
21+
export const petPhoneRegExp = new RegExp('^\\+?[1-9]\\d{1,14}$');
22+
23+
export const Pet = zod.object({
24+
id: zod.number().min(1).describe('Unique identifier for the pet'),
25+
name: zod.string().min(1).max(petNameMax).describe('Name of the pet'),
26+
tag: zod
27+
.string()
28+
.min(1)
29+
.max(petTagMax)
30+
.optional()
31+
.describe('Optional classification tag'),
32+
email: zod.email().optional().describe('Owner contact email'),
33+
status: zod
34+
.enum(['available', 'pending', 'sold'])
35+
.default(petStatusDefault)
36+
.describe('Current adoption status'),
37+
age: zod
38+
.number()
39+
.min(petAgeMin)
40+
.max(petAgeMax)
41+
.optional()
42+
.describe('Age of the pet in years'),
43+
rating: zod
44+
.number()
45+
.min(petRatingMin)
46+
.max(petRatingMax)
47+
.multipleOf(petRatingMultipleOf)
48+
.optional()
49+
.describe('Average customer rating'),
50+
phone: zod
51+
.string()
52+
.regex(petPhoneRegExp)
53+
.optional()
54+
.describe('Contact phone in E.164 format'),
55+
requiredNullableString: zod.string().nullable(),
56+
optionalNullableString: zod.string().nullish(),
57+
});
58+
59+
export type Pet = zod.input<typeof Pet>;
60+
export type PetOutput = zod.output<typeof Pet>;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
import { z as zod } from 'zod';
8+
9+
export const PetsMax = 100;
10+
11+
export const petsItemNameMax = 100;
12+
13+
export const petsItemTagMax = 50;
14+
15+
export const petsItemStatusDefault = `available`;
16+
export const petsItemAgeMin = 0;
17+
export const petsItemAgeMax = 30;
18+
19+
export const petsItemRatingMin = 0;
20+
export const petsItemRatingMax = 5;
21+
export const petsItemRatingMultipleOf = 0.5;
22+
23+
export const petsItemPhoneRegExp = new RegExp('^\\+?[1-9]\\d{1,14}$');
24+
25+
export const Pets = zod
26+
.array(
27+
zod.object({
28+
id: zod.number().min(1).describe('Unique identifier for the pet'),
29+
name: zod
30+
.string()
31+
.min(1)
32+
.max(petsItemNameMax)
33+
.describe('Name of the pet'),
34+
tag: zod
35+
.string()
36+
.min(1)
37+
.max(petsItemTagMax)
38+
.optional()
39+
.describe('Optional classification tag'),
40+
email: zod.email().optional().describe('Owner contact email'),
41+
status: zod
42+
.enum(['available', 'pending', 'sold'])
43+
.default(petsItemStatusDefault)
44+
.describe('Current adoption status'),
45+
age: zod
46+
.number()
47+
.min(petsItemAgeMin)
48+
.max(petsItemAgeMax)
49+
.optional()
50+
.describe('Age of the pet in years'),
51+
rating: zod
52+
.number()
53+
.min(petsItemRatingMin)
54+
.max(petsItemRatingMax)
55+
.multipleOf(petsItemRatingMultipleOf)
56+
.optional()
57+
.describe('Average customer rating'),
58+
phone: zod
59+
.string()
60+
.regex(petsItemPhoneRegExp)
61+
.optional()
62+
.describe('Contact phone in E.164 format'),
63+
requiredNullableString: zod.string().nullable(),
64+
optionalNullableString: zod.string().nullish(),
65+
}),
66+
)
67+
.max(PetsMax);
68+
69+
export type Pets = zod.input<typeof Pets>;
70+
export type PetsOutput = zod.output<typeof Pets>;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
import { z as zod } from 'zod';
8+
9+
export const searchPetsParamsLimitMax = 100;
10+
11+
export const SearchPetsParams = zod.object({
12+
requirednullableString: zod.string().nullable(),
13+
requirednullableStringTwo: zod.string().nullable(),
14+
nonRequirednullableString: zod.string().nullish(),
15+
status: zod.enum(['available', 'pending', 'sold']).optional(),
16+
limit: zod.number().min(1).max(searchPetsParamsLimitMax).optional(),
17+
});
18+
19+
export type SearchPetsParams = zod.input<typeof SearchPetsParams>;
20+
export type SearchPetsParamsOutput = zod.output<typeof SearchPetsParams>;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Generated by orval v8.18.0 🍺
3+
* Do not edit manually.
4+
* Swagger Petstore
5+
* OpenAPI spec version: 1.0.0
6+
*/
7+
import { z as zod } from 'zod';
8+
9+
export const updatePetByIdBodyNameMax = 100;
10+
11+
export const updatePetByIdBodyTagMax = 50;
12+
13+
export const updatePetByIdBodyStatusDefault = `available`;
14+
export const updatePetByIdBodyAgeMin = 0;
15+
export const updatePetByIdBodyAgeMax = 30;
16+
17+
export const updatePetByIdBodyRatingMin = 0;
18+
export const updatePetByIdBodyRatingMax = 5;
19+
export const updatePetByIdBodyRatingMultipleOf = 0.5;
20+
21+
export const updatePetByIdBodyPhoneRegExp = new RegExp('^\\+?[1-9]\\d{1,14}$');
22+
23+
export const UpdatePetByIdBody = zod.object({
24+
id: zod.number().min(1).describe('Unique identifier for the pet'),
25+
name: zod
26+
.string()
27+
.min(1)
28+
.max(updatePetByIdBodyNameMax)
29+
.describe('Name of the pet'),
30+
tag: zod
31+
.string()
32+
.min(1)
33+
.max(updatePetByIdBodyTagMax)
34+
.optional()
35+
.describe('Optional classification tag'),
36+
email: zod.email().optional().describe('Owner contact email'),
37+
status: zod
38+
.enum(['available', 'pending', 'sold'])
39+
.default(updatePetByIdBodyStatusDefault)
40+
.describe('Current adoption status'),
41+
age: zod
42+
.number()
43+
.min(updatePetByIdBodyAgeMin)
44+
.max(updatePetByIdBodyAgeMax)
45+
.optional()
46+
.describe('Age of the pet in years'),
47+
rating: zod
48+
.number()
49+
.min(updatePetByIdBodyRatingMin)
50+
.max(updatePetByIdBodyRatingMax)
51+
.multipleOf(updatePetByIdBodyRatingMultipleOf)
52+
.optional()
53+
.describe('Average customer rating'),
54+
phone: zod
55+
.string()
56+
.regex(updatePetByIdBodyPhoneRegExp)
57+
.optional()
58+
.describe('Contact phone in E.164 format'),
59+
requiredNullableString: zod.string().nullable(),
60+
optionalNullableString: zod.string().nullish(),
61+
});
62+
63+
export type UpdatePetByIdBody = zod.input<typeof UpdatePetByIdBody>;
64+
export type UpdatePetByIdBodyOutput = zod.output<typeof UpdatePetByIdBody>;

0 commit comments

Comments
 (0)