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.

test: add Swagger 2.0 test for schema name transform

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

+95
+24
packages/openapi-ts-tests/main/test/2.0.x.test.ts
··· 289 289 }, 290 290 { 291 291 config: createConfig({ 292 + input: 'transforms-schemas-name.yaml', 293 + output: 'transforms-schemas-name', 294 + parser: { 295 + transforms: { 296 + schemas: { 297 + name: (name: string) => { 298 + // Strip version markers: User_v1_0_0_User → User 299 + let clean = name.replace(/([A-Za-z\d]+)_v\d+_\d+_\d+_([A-Za-z\d]*)/g, (_, p1, p2) => 300 + p2.startsWith(p1) ? p2 : p1 + p2, 301 + ); 302 + // Deduplicate prefixes: Foo_Foo → Foo 303 + const m = clean.match(/^([A-Za-z\d]+)_\1([A-Za-z\d]*)$/); 304 + if (m) clean = m[1] + m[2]; 305 + return clean; 306 + }, 307 + }, 308 + }, 309 + }, 310 + plugins: ['@hey-api/typescript'], 311 + }), 312 + description: 'handles schema name transforms', 313 + }, 314 + { 315 + config: createConfig({ 292 316 input: 'schema-unknown.yaml', 293 317 output: 'schema-unknown', 294 318 plugins: ['@hey-api/client-fetch', '@hey-api/sdk'],
+71
specs/2.0.x/transforms-schemas-name.yaml
··· 1 + swagger: '2.0' 2 + info: 3 + title: Schema Name Transform Test (Swagger 2.0) 4 + version: 1.0.0 5 + paths: 6 + /users: 7 + get: 8 + summary: Get users 9 + produces: 10 + - application/json 11 + responses: 12 + '200': 13 + description: Success 14 + schema: 15 + $ref: '#/definitions/User_v1_0_0_User' 16 + /posts: 17 + post: 18 + summary: Create post 19 + consumes: 20 + - application/json 21 + produces: 22 + - application/json 23 + parameters: 24 + - in: body 25 + name: body 26 + schema: 27 + $ref: '#/definitions/Post_v2_1_3_Post' 28 + responses: 29 + '201': 30 + description: Created 31 + schema: 32 + $ref: '#/definitions/Post_v2_1_3_Post' 33 + definitions: 34 + User_v1_0_0_User: 35 + type: object 36 + properties: 37 + id: 38 + type: string 39 + name: 40 + type: string 41 + profile: 42 + $ref: '#/definitions/UserProfile_v1_0_0_UserProfile' 43 + UserProfile_v1_0_0_UserProfile: 44 + type: object 45 + properties: 46 + bio: 47 + type: string 48 + avatar: 49 + type: string 50 + Post_v2_1_3_Post: 51 + type: object 52 + properties: 53 + id: 54 + type: string 55 + title: 56 + type: string 57 + author: 58 + $ref: '#/definitions/User_v1_0_0_User' 59 + comments: 60 + type: array 61 + items: 62 + $ref: '#/definitions/Comment_v1_5_2_Comment' 63 + Comment_v1_5_2_Comment: 64 + type: object 65 + properties: 66 + id: 67 + type: string 68 + text: 69 + type: string 70 + author: 71 + $ref: '#/definitions/User_v1_0_0_User'