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 #861 from qqilihq/fix-additional-properties-key

authored by

Lubos and committed by
GitHub
70a375e6 37a991a9

+30 -21
+5
.changeset/unlucky-lobsters-brake.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: Additional properties key
+15 -11
packages/openapi-ts/src/utils/type.ts
··· 120 120 const properties: Property[] = model.properties.map((property) => { 121 121 let maybeRequired = property.isRequired ? '' : '?'; 122 122 let value = toType(property); 123 + let name = isStandalone 124 + ? escapeName(unescapeName(transformTypeKeyName(property.name))) 125 + : // special test for 1XX status codes. We need a more robust system 126 + // for escaping values depending on context in which they're printed, 127 + // but since this works for standalone client, it's not worth it right now 128 + /^\dXX$/.test(property.name) 129 + ? escapeName(property.name) 130 + : property.name; 123 131 // special case for additional properties type 124 - if (property.name === '[key: string]' && maybeRequired) { 125 - maybeRequired = ''; 126 - value = compiler.typedef.union([value, 'undefined']); 132 + if (property.name === '[key: string]') { 133 + name = property.name; 134 + if (maybeRequired) { 135 + maybeRequired = ''; 136 + value = compiler.typedef.union([value, 'undefined']); 137 + } 127 138 } 128 139 return { 129 140 comment: [ ··· 132 143 ], 133 144 isReadOnly: property.isReadOnly, 134 145 isRequired: maybeRequired === '', 135 - name: isStandalone 136 - ? escapeName(unescapeName(transformTypeKeyName(property.name))) 137 - : // special test for 1XX status codes. We need a more robust system 138 - // for escaping values depending on context in which they're printed, 139 - // but since this works for standalone client, it's not worth it right now 140 - /^\dXX$/.test(property.name) 141 - ? escapeName(property.name) 142 - : property.name, 146 + name, 143 147 type: value, 144 148 }; 145 149 });
+2 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios/types.gen.ts.snap
··· 242 242 export type DictionaryWithPropertiesAndAdditionalProperties = { 243 243 foo?: number; 244 244 bar?: boolean; 245 - '[key: string]': (string | number | boolean) | undefined; 245 + [key: string]: (string | number | boolean) | undefined; 246 246 }; 247 247 248 248 /** ··· 779 779 * This is a simple string property 780 780 */ 781 781 prop?: string; 782 - '[key: string]': unknown | string; 782 + [key: string]: unknown | string; 783 783 }; 784 784 785 785 export type NestedAnyOfArraysNullable = {
+2 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-axios_bundle/types.gen.ts.snap
··· 242 242 export type DictionaryWithPropertiesAndAdditionalProperties = { 243 243 foo?: number; 244 244 bar?: boolean; 245 - '[key: string]': (string | number | boolean) | undefined; 245 + [key: string]: (string | number | boolean) | undefined; 246 246 }; 247 247 248 248 /** ··· 779 779 * This is a simple string property 780 780 */ 781 781 prop?: string; 782 - '[key: string]': unknown | string; 782 + [key: string]: unknown | string; 783 783 }; 784 784 785 785 export type NestedAnyOfArraysNullable = {
+2 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch/types.gen.ts.snap
··· 242 242 export type DictionaryWithPropertiesAndAdditionalProperties = { 243 243 foo?: number; 244 244 bar?: boolean; 245 - '[key: string]': (string | number | boolean) | undefined; 245 + [key: string]: (string | number | boolean) | undefined; 246 246 }; 247 247 248 248 /** ··· 779 779 * This is a simple string property 780 780 */ 781 781 prop?: string; 782 - '[key: string]': unknown | string; 782 + [key: string]: unknown | string; 783 783 }; 784 784 785 785 export type NestedAnyOfArraysNullable = {
+2 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch_bundle/types.gen.ts.snap
··· 242 242 export type DictionaryWithPropertiesAndAdditionalProperties = { 243 243 foo?: number; 244 244 bar?: boolean; 245 - '[key: string]': (string | number | boolean) | undefined; 245 + [key: string]: (string | number | boolean) | undefined; 246 246 }; 247 247 248 248 /** ··· 779 779 * This is a simple string property 780 780 */ 781 781 prop?: string; 782 - '[key: string]': unknown | string; 782 + [key: string]: unknown | string; 783 783 }; 784 784 785 785 export type NestedAnyOfArraysNullable = {
+2 -2
packages/openapi-ts/test/__snapshots__/test/generated/v3_hey-api_client-fetch_plugin_tanstack-react-query/types.gen.ts.snap
··· 242 242 export type DictionaryWithPropertiesAndAdditionalProperties = { 243 243 foo?: number; 244 244 bar?: boolean; 245 - '[key: string]': (string | number | boolean) | undefined; 245 + [key: string]: (string | number | boolean) | undefined; 246 246 }; 247 247 248 248 /** ··· 779 779 * This is a simple string property 780 780 */ 781 781 prop?: string; 782 - '[key: string]': unknown | string; 782 + [key: string]: unknown | string; 783 783 }; 784 784 785 785 export type NestedAnyOfArraysNullable = {