Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set allowrelaxedtypes to true for all apis #85

Merged
merged 4 commits into from
Mar 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

## Unreleased

- Set `allowrelaxedtypes` annotation for every function (API) ([#85](https://github.com/hasura/ndc-open-api-lambda/pull/85))

- Fix param parsing of `anyOf`, `allOf` and `oneOf` ([#83](https://github.com/hasura/ndc-open-api-lambda/pull/83))


13 changes: 9 additions & 4 deletions src/app/generator/functions-ts-generator.ts
Original file line number Diff line number Diff line change
@@ -24,10 +24,15 @@ export async function generateFunctionsTsCode(
description: routeTypes.getDescription(route.route),
request: routeTypes.getFormattedRouteName(route.route),
isGetRequest: routeTypes.isGetRequest(route.route),
requiresRelaxedTypeAnnotation: requiresRelaxedTypeAnnotation(
route.params,
route.returnType,
),

// set requiresRelaxedTypeAnnotation to `true` for everything for now becuase it does not cause issues with types that don't need it
requiresRelaxedTypeAnnotation: true,

// previous implementation
// requiresRelaxedTypeAnnotation: requiresRelaxedTypeAnnotation(
// route.params,
// route.returnType,
// ),
});

const namespace = routeTypes.getNamespace(route.route);
7 changes: 7 additions & 0 deletions tests/test-data/golden-files/1password
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ export async function getActivityGetApiActivity(
/**
* Get state of the server and its dependencies.
* @request GET :/health
* @allowrelaxedtypes
* @readonly
*/
export async function getHealthGetServerHealth(
@@ -70,6 +71,7 @@ export async function getHealthGetServerHealth(
/**
* Ping the server for liveness
* @request GET :/heartbeat
* @allowrelaxedtypes
* @readonly
*/
export async function getHeartbeatGetHeartbeat(
@@ -90,6 +92,7 @@ export async function getHeartbeatGetHeartbeat(
/**
* Query server for exposed Prometheus metrics
* @request GET :/metrics
* @allowrelaxedtypes
* @readonly
*/
export async function getMetricsGetPrometheusMetrics(
@@ -215,6 +218,7 @@ export async function postVaultsCreateVaultItem(
/**
* Delete an Item
* @request DELETE :/vaults/{vaultUuid}/items/{itemUuid}
* @allowrelaxedtypes
*/
export async function deleteVaultsDeleteVaultItem(
/** The UUID of the Vault the item is in */
@@ -325,6 +329,7 @@ export async function putVaultsUpdateVaultItem(
/**
* Get all the files inside an Item
* @request GET :/vaults/{vaultUuid}/items/{itemUuid}/files
* @allowrelaxedtypes
* @readonly
*/
export async function getVaultsGetItemFiles(
@@ -356,6 +361,7 @@ export async function getVaultsGetItemFiles(
/**
* Get the details of a File
* @request GET :/vaults/{vaultUuid}/items/{itemUuid}/files/{fileUuid}
* @allowrelaxedtypes
* @readonly
*/
export async function getVaultsGetDetailsOfFileById(
@@ -390,6 +396,7 @@ export async function getVaultsGetDetailsOfFileById(
/**
* Get the content of a File
* @request GET :/vaults/{vaultUuid}/items/{itemUuid}/files/{fileUuid}/content
* @allowrelaxedtypes
* @readonly
*/
export async function getVaultsDownloadFileById(
3 changes: 3 additions & 0 deletions tests/test-data/golden-files/acko-insurance
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ const api = new Api({
/**
* Insurance Policy - Car
* @request POST :/cripc/certificate
* @allowrelaxedtypes
*/
export async function postCripcCripc(
/** Request body */
@@ -52,6 +53,7 @@ export async function postCripcCripc(
/**
* Insurance Policy - Health
* @request POST :/hlipc/certificate
* @allowrelaxedtypes
*/
export async function postHlipcHlipc(
/** Request body */
@@ -96,6 +98,7 @@ export async function postHlipcHlipc(
/**
* Insurance Policy - Two Wheeler
* @request POST :/twipc/certificate
* @allowrelaxedtypes
*/
export async function postTwipcTwipc(
/** Request body */
Loading