Skip to content

Commit a8015ad

Browse files
authored
[typescript] Make additional properties access safer (#5207)
* [typescript-fetch] Make additional properties access safer Instead of asserting that any key access returns a valid property, force the consumer to check that the value is defined. * Update tests * Put null-safe additional props behind and flag and share * Undo over copy * Update docs * Rearrange code * Move to unit tests
1 parent 2aa8a6d commit a8015ad

22 files changed

Lines changed: 68 additions & 26 deletions

docs/generators/javascript-flowtyped.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sidebar_label: javascript-flowtyped
1313
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1414
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
1515
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
16+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1617
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1718
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
1819
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|

docs/generators/typescript-angular.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sidebar_label: typescript-angular
1818
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1919
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
2020
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
21+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
2122
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
2223
|providedInRoot|Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).| |false|
2324
|serviceFileSuffix|The suffix of the file of the generated service (service<suffix>.ts).| |.service|

docs/generators/typescript-angularjs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sidebar_label: typescript-angularjs
1010
|enumNameSuffix|Suffix that will be appended to all enum names. A special 'v4-compat' value enables the backward-compatible behavior (as pre v4.2.3)| |v4-compat|
1111
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |PascalCase|
1212
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
13+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1314
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1415
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
1516
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|

docs/generators/typescript-aurelia.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ sidebar_label: typescript-aurelia
1212
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
1313
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1414
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
15+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1516
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1617
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
1718
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|

docs/generators/typescript-axios.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sidebar_label: typescript-axios
1313
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1414
|npmRepository|Use this property to set an url of your private npmRepo in the package.json| |null|
1515
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
16+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1617
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1718
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
1819
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|

docs/generators/typescript-fetch.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sidebar_label: typescript-fetch
1313
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1414
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
1515
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
16+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1617
|prefixParameterInterfaces|Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.| |false|
1718
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1819
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|

docs/generators/typescript-inversify.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sidebar_label: typescript-inversify
1313
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1414
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
1515
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
16+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1617
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1718
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
1819
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|

docs/generators/typescript-jquery.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sidebar_label: typescript-jquery
1414
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1515
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
1616
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
17+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1718
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1819
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
1920
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|

docs/generators/typescript-node.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sidebar_label: typescript-node
1313
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1414
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
1515
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
16+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1617
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1718
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
1819
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|

docs/generators/typescript-redux-query.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sidebar_label: typescript-redux-query
1313
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
1414
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
1515
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|
16+
|nullSafeAdditionalProps|Set to make additional properties types declare that their indexer may return undefined| |false|
1617
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1718
|snapshot|When setting this property to true, the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
1819
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|

0 commit comments

Comments
 (0)