Skip to content

Commit 0744e43

Browse files
authored
set allowrelaxedtypes to true for all apis (#85)
1 parent ed8c1ed commit 0744e43

25 files changed

+2474
-4
lines changed

changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Set `allowrelaxedtypes` annotation for every function (API) ([#85](https://github.com/hasura/ndc-open-api-lambda/pull/85))
6+
57
- Fix param parsing of `anyOf`, `allOf` and `oneOf` ([#83](https://github.com/hasura/ndc-open-api-lambda/pull/83))
68

79

src/app/generator/functions-ts-generator.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ export async function generateFunctionsTsCode(
2424
description: routeTypes.getDescription(route.route),
2525
request: routeTypes.getFormattedRouteName(route.route),
2626
isGetRequest: routeTypes.isGetRequest(route.route),
27-
requiresRelaxedTypeAnnotation: requiresRelaxedTypeAnnotation(
28-
route.params,
29-
route.returnType,
30-
),
27+
28+
// set requiresRelaxedTypeAnnotation to `true` for everything for now becuase it does not cause issues with types that don't need it
29+
requiresRelaxedTypeAnnotation: true,
30+
31+
// previous implementation
32+
// requiresRelaxedTypeAnnotation: requiresRelaxedTypeAnnotation(
33+
// route.params,
34+
// route.returnType,
35+
// ),
3136
});
3237

3338
const namespace = routeTypes.getNamespace(route.route);

tests/test-data/golden-files/1password

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export async function getActivityGetApiActivity(
4545
/**
4646
* Get state of the server and its dependencies.
4747
* @request GET :/health
48+
* @allowrelaxedtypes
4849
* @readonly
4950
*/
5051
export async function getHealthGetServerHealth(
@@ -70,6 +71,7 @@ export async function getHealthGetServerHealth(
7071
/**
7172
* Ping the server for liveness
7273
* @request GET :/heartbeat
74+
* @allowrelaxedtypes
7375
* @readonly
7476
*/
7577
export async function getHeartbeatGetHeartbeat(
@@ -90,6 +92,7 @@ export async function getHeartbeatGetHeartbeat(
9092
/**
9193
* Query server for exposed Prometheus metrics
9294
* @request GET :/metrics
95+
* @allowrelaxedtypes
9396
* @readonly
9497
*/
9598
export async function getMetricsGetPrometheusMetrics(
@@ -215,6 +218,7 @@ export async function postVaultsCreateVaultItem(
215218
/**
216219
* Delete an Item
217220
* @request DELETE :/vaults/{vaultUuid}/items/{itemUuid}
221+
* @allowrelaxedtypes
218222
*/
219223
export async function deleteVaultsDeleteVaultItem(
220224
/** The UUID of the Vault the item is in */
@@ -325,6 +329,7 @@ export async function putVaultsUpdateVaultItem(
325329
/**
326330
* Get all the files inside an Item
327331
* @request GET :/vaults/{vaultUuid}/items/{itemUuid}/files
332+
* @allowrelaxedtypes
328333
* @readonly
329334
*/
330335
export async function getVaultsGetItemFiles(
@@ -356,6 +361,7 @@ export async function getVaultsGetItemFiles(
356361
/**
357362
* Get the details of a File
358363
* @request GET :/vaults/{vaultUuid}/items/{itemUuid}/files/{fileUuid}
364+
* @allowrelaxedtypes
359365
* @readonly
360366
*/
361367
export async function getVaultsGetDetailsOfFileById(
@@ -390,6 +396,7 @@ export async function getVaultsGetDetailsOfFileById(
390396
/**
391397
* Get the content of a File
392398
* @request GET :/vaults/{vaultUuid}/items/{itemUuid}/files/{fileUuid}/content
399+
* @allowrelaxedtypes
393400
* @readonly
394401
*/
395402
export async function getVaultsDownloadFileById(

tests/test-data/golden-files/acko-insurance

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const api = new Api({
88
/**
99
* Insurance Policy - Car
1010
* @request POST :/cripc/certificate
11+
* @allowrelaxedtypes
1112
*/
1213
export async function postCripcCripc(
1314
/** Request body */
@@ -52,6 +53,7 @@ export async function postCripcCripc(
5253
/**
5354
* Insurance Policy - Health
5455
* @request POST :/hlipc/certificate
56+
* @allowrelaxedtypes
5557
*/
5658
export async function postHlipcHlipc(
5759
/** Request body */
@@ -96,6 +98,7 @@ export async function postHlipcHlipc(
9698
/**
9799
* Insurance Policy - Two Wheeler
98100
* @request POST :/twipc/certificate
101+
* @allowrelaxedtypes
99102
*/
100103
export async function postTwipcTwipc(
101104
/** Request body */

0 commit comments

Comments
 (0)