fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add snapshot test for discriminator with oneOf and read/write transforms

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>

+99
+7
packages/openapi-ts-tests/main/test/3.1.x.test.ts
··· 229 229 }, 230 230 { 231 231 config: createConfig({ 232 + input: 'discriminator-one-of-read-write.yaml', 233 + output: 'discriminator-one-of-read-write', 234 + }), 235 + description: 'handles discriminator with oneOf and read/write transforms', 236 + }, 237 + { 238 + config: createConfig({ 232 239 input: 'duplicate-null.json', 233 240 output: 'duplicate-null', 234 241 }),
+3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of-read-write/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { AnimalPayload, CatPayload, CatPayloadWritable, ClientOptions, CreatePetRequest, CreatePetRequestWritable, CreatePetResponse, CreatePetResponseWritable, DogPayload, DogPayloadWritable, PostPetsData, PostPetsResponse, PostPetsResponses } from './types.gen';
+89
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of-read-write/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type ClientOptions = { 4 + baseUrl: `${string}://${string}` | (string & {}); 5 + }; 6 + 7 + export type AnimalPayload = { 8 + typeDiscriminator: string; 9 + }; 10 + 11 + export type DogPayload = Omit<AnimalPayload, 'typeDiscriminator'> & { 12 + breed: string; 13 + canFetch: boolean; 14 + readonly displayBreed: string; 15 + typeDiscriminator: 'dog'; 16 + }; 17 + 18 + export type CatPayload = Omit<AnimalPayload, 'typeDiscriminator'> & { 19 + breed: string; 20 + livesRemaining: number; 21 + readonly displayBreed: string; 22 + typeDiscriminator: 'cat'; 23 + }; 24 + 25 + export type CreatePetRequest = { 26 + name: string; 27 + animal: ({ 28 + typeDiscriminator: 'dog'; 29 + } & DogPayload) | ({ 30 + typeDiscriminator: 'cat'; 31 + } & CatPayload); 32 + }; 33 + 34 + export type CreatePetResponse = { 35 + id: string; 36 + name: string; 37 + animal: ({ 38 + typeDiscriminator: 'dog'; 39 + } & DogPayload) | ({ 40 + typeDiscriminator: 'cat'; 41 + } & CatPayload); 42 + }; 43 + 44 + export type DogPayloadWritable = Omit<AnimalPayload, 'typeDiscriminator'> & { 45 + breed: string; 46 + canFetch: boolean; 47 + typeDiscriminator: 'DogPayloadWritable'; 48 + }; 49 + 50 + export type CatPayloadWritable = Omit<AnimalPayload, 'typeDiscriminator'> & { 51 + breed: string; 52 + livesRemaining: number; 53 + typeDiscriminator: 'CatPayloadWritable'; 54 + }; 55 + 56 + export type CreatePetRequestWritable = { 57 + name: string; 58 + animal: ({ 59 + typeDiscriminator: 'dog'; 60 + } & DogPayloadWritable) | ({ 61 + typeDiscriminator: 'cat'; 62 + } & CatPayloadWritable); 63 + }; 64 + 65 + export type CreatePetResponseWritable = { 66 + id: string; 67 + name: string; 68 + animal: ({ 69 + typeDiscriminator: 'dog'; 70 + } & DogPayloadWritable) | ({ 71 + typeDiscriminator: 'cat'; 72 + } & CatPayloadWritable); 73 + }; 74 + 75 + export type PostPetsData = { 76 + body: CreatePetRequestWritable; 77 + path?: never; 78 + query?: never; 79 + url: '/pets'; 80 + }; 81 + 82 + export type PostPetsResponses = { 83 + /** 84 + * OK 85 + */ 86 + 200: CreatePetResponse; 87 + }; 88 + 89 + export type PostPetsResponse = PostPetsResponses[keyof PostPetsResponses];