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.

Merge pull request #742 from hey-api/fix/ignore-as-class-for-named

fix: ignore services.asClass setting for named clients

authored by

Lubos and committed by
GitHub
c8f39842 4169e293

+29 -13
+5
.changeset/long-moles-mate.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: ignore services.asClass setting for named clients
+1 -1
packages/openapi-ts/src/openApi/v2/parser/getServices.ts
··· 41 41 // Each method contains an OpenAPI operation, we parse the operation 42 42 const op = path[method]!; 43 43 const tags = 44 - op.tags?.length && config.services.asClass 44 + op.tags?.length && (config.services.asClass || config.name) 45 45 ? op.tags.filter(unique) 46 46 : ['Default']; 47 47 tags.forEach((tag) => {
+1 -1
packages/openapi-ts/src/openApi/v3/parser/getServices.ts
··· 49 49 if (allowedServiceMethods.includes(method)) { 50 50 const op = path[method]!; 51 51 const tags = 52 - op.tags?.length && config.services.asClass 52 + op.tags?.length && (config.services.asClass || config.name) 53 53 ? op.tags.filter(unique) 54 54 : ['Default']; 55 55 tags.forEach((tag) => {
+1 -1
packages/openapi-ts/src/utils/write/services.ts
··· 506 506 } 507 507 }); 508 508 509 - if (!config.services.asClass) { 509 + if (!config.services.asClass && !config.name) { 510 510 service.operations.forEach((operation) => { 511 511 const expression = compiler.types.function({ 512 512 parameters: toOperationParamType(client, operation),
+20 -10
packages/openapi-ts/test/index.spec.ts
··· 57 57 input: '', 58 58 output: '', 59 59 schemas: true, 60 - services: { 61 - asClass: true, 62 - }, 63 60 types: { 64 61 enums: 'javascript', 65 62 }, ··· 73 70 74 71 const clientScenarios = [ 75 72 { 76 - config: createConfig(), 73 + config: createConfig({ 74 + services: { 75 + asClass: true, 76 + }, 77 + }), 77 78 description: 'generate fetch client', 78 79 name: 'v3', 79 80 }, 80 81 { 81 82 config: createConfig({ 82 83 client: 'angular', 84 + services: { 85 + asClass: true, 86 + }, 83 87 types: {}, 84 88 }), 85 89 description: 'generate angular client', ··· 88 92 { 89 93 config: createConfig({ 90 94 client: 'node', 95 + services: { 96 + asClass: true, 97 + }, 91 98 }), 92 99 description: 'generate node client', 93 100 name: 'v3_node', ··· 95 102 { 96 103 config: createConfig({ 97 104 client: 'axios', 105 + services: { 106 + asClass: true, 107 + }, 98 108 }), 99 109 description: 'generate axios client', 100 110 name: 'v3_axios', ··· 102 112 { 103 113 config: createConfig({ 104 114 client: '@hey-api/client-fetch', 105 - services: { 106 - asClass: false, 107 - }, 108 115 }), 109 116 description: 'generate axios client', 110 117 name: 'v3_hey-api_client-fetch', ··· 112 119 { 113 120 config: createConfig({ 114 121 client: '@hey-api/client-axios', 115 - services: { 116 - asClass: false, 117 - }, 118 122 }), 119 123 description: 'generate axios client', 120 124 name: 'v3_hey-api_client-axios', ··· 122 126 { 123 127 config: createConfig({ 124 128 client: 'xhr', 129 + services: { 130 + asClass: true, 131 + }, 125 132 }), 126 133 description: 'generate xhr client', 127 134 name: 'v3_xhr', ··· 187 194 { 188 195 config: createConfig({ 189 196 schemas: false, 197 + services: { 198 + asClass: true, 199 + }, 190 200 types: { 191 201 enums: 'typescript', 192 202 },
+1
packages/openapi-ts/test/sample.cjs
··· 8 8 debug: true, 9 9 input: './test/spec/v3-transforms.json', 10 10 // input: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', 11 + name: 'foo', 11 12 output: { 12 13 path: './test/generated/sample/', 13 14 },