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.

fix: readWrite transform drops unevaluatedProperties schemas with readOnly sibling

Add `unevaluatedProperties` to `childSchemaRelationships` as 'single' type
(same as `additionalProperties`) so the pruneSchemaByScope function
correctly recognizes it as a structural keyword and does not remove
schemas that use it alongside readOnly properties.

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

+112
+8
packages/openapi-ts-tests/main/test/3.1.x.test.ts
··· 739 739 }, 740 740 { 741 741 config: createConfig({ 742 + input: 'transforms-read-write-unevaluated.yaml', 743 + output: 'transforms-read-write-unevaluated', 744 + plugins: ['@hey-api/typescript'], 745 + }), 746 + description: 'preserves unevaluatedProperties in schemas with readOnly fields', 747 + }, 748 + { 749 + config: createConfig({ 742 750 input: 'ref-type.json', 743 751 output: 'ref-type', 744 752 }),
+3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write-unevaluated/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type { ClientOptions, CreateXData, CreateXResponse, CreateXResponses, DisposableEmail, DisposableEmailWritable, GetXData, GetXResponse, GetXResponses } from './types.gen';
+52
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write-unevaluated/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 DisposableEmail = { 8 + domain: string; 9 + readonly disposable: boolean; 10 + metadata: { 11 + [key: string]: unknown; 12 + }; 13 + }; 14 + 15 + export type DisposableEmailWritable = { 16 + domain: string; 17 + metadata: { 18 + [key: string]: unknown; 19 + }; 20 + }; 21 + 22 + export type GetXData = { 23 + body?: never; 24 + path?: never; 25 + query?: never; 26 + url: '/x'; 27 + }; 28 + 29 + export type GetXResponses = { 30 + /** 31 + * ok 32 + */ 33 + 200: DisposableEmail; 34 + }; 35 + 36 + export type GetXResponse = GetXResponses[keyof GetXResponses]; 37 + 38 + export type CreateXData = { 39 + body: DisposableEmailWritable; 40 + path?: never; 41 + query?: never; 42 + url: '/x'; 43 + }; 44 + 45 + export type CreateXResponses = { 46 + /** 47 + * ok 48 + */ 49 + 200: DisposableEmail; 50 + }; 51 + 52 + export type CreateXResponse = CreateXResponses[keyof CreateXResponses];
+1
packages/shared/src/openApi/shared/transforms/readWrite.ts
··· 46 46 'patternProperties', 47 47 'properties', 48 48 'schema', 49 + 'unevaluatedProperties', 49 50 ]); 50 51 51 52 const getComponentContext = (path: ReadonlyArray<string | number>): Scope | undefined => {
+1
packages/shared/src/openApi/shared/utils/schemaChildRelationships.ts
··· 12 12 ['properties', 'objectMap'], 13 13 ['propertyNames', 'single'], 14 14 ['then', 'single'], 15 + ['unevaluatedProperties', 'single'], 15 16 ] as const;
+47
specs/3.1.x/transforms-read-write-unevaluated.yaml
··· 1 + openapi: 3.1.0 2 + info: 3 + title: readOnly map property with unevaluatedProperties 4 + version: 1.0.0 5 + paths: 6 + /x: 7 + get: 8 + operationId: getX 9 + responses: 10 + '200': 11 + description: ok 12 + content: 13 + application/json: 14 + schema: 15 + $ref: '#/components/schemas/DisposableEmail' 16 + post: 17 + operationId: createX 18 + requestBody: 19 + required: true 20 + content: 21 + application/json: 22 + schema: 23 + $ref: '#/components/schemas/DisposableEmail' 24 + responses: 25 + '200': 26 + description: ok 27 + content: 28 + application/json: 29 + schema: 30 + $ref: '#/components/schemas/DisposableEmail' 31 + components: 32 + schemas: 33 + DisposableEmail: 34 + type: object 35 + required: 36 + - domain 37 + - disposable 38 + - metadata 39 + properties: 40 + domain: 41 + type: string 42 + disposable: 43 + type: boolean 44 + readOnly: true 45 + metadata: 46 + type: object 47 + unevaluatedProperties: {}