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

Fix writeOnly refs in nested schemas

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

+62
+23
packages/openapi-ts/src/openApi/shared/transforms/readWrite.ts
··· 630 630 } else if (map.write && (!nextContext || nextContext === 'write')) { 631 631 (node as Record<string, unknown>)[key] = map.write; 632 632 } 633 + } else if ( 634 + inSchema && 635 + nextContext && 636 + value.startsWith(schemasPointerNamespace) 637 + ) { 638 + // If we're in a schema with a defined context (read/write), follow the $ref 639 + // to update nested $refs within the referenced schema 640 + const schemasObj = getSchemasObject(spec); 641 + if (schemasObj) { 642 + const schemaName = value.substring( 643 + schemasPointerNamespace.length, 644 + ); 645 + const referencedSchema = schemasObj[schemaName]; 646 + if (referencedSchema) { 647 + walk({ 648 + context: nextContext, 649 + currentPointer: value, 650 + inSchema: true, 651 + node: referencedSchema, 652 + path: value.split('/').filter(Boolean), 653 + }); 654 + } 655 + } 633 656 } 634 657 } else { 635 658 walk({
+39
specs/3.1.x/transforms-read-write-nested.yaml
··· 1 + openapi: 3.0.3 2 + info: 3 + title: writeOnly repro 4 + version: 1.0.0 5 + paths: 6 + /items: 7 + post: 8 + operationId: item_create 9 + requestBody: 10 + required: true 11 + content: 12 + application/json: 13 + schema: 14 + $ref: '#/components/schemas/CreateItemRequest' 15 + responses: 16 + '201': 17 + description: Created 18 + components: 19 + schemas: 20 + CreateItemRequest: 21 + type: object 22 + required: 23 + - payload 24 + properties: 25 + payload: 26 + $ref: '#/components/schemas/Payload' 27 + Payload: 28 + type: object 29 + required: 30 + - kind 31 + - encoded 32 + properties: 33 + kind: 34 + type: string 35 + enum: [jpeg] 36 + encoded: 37 + type: string 38 + writeOnly: true 39 + description: Data required on write