Closed anshchaturvedi closed 1 month ago
:tada: This PR is included in version @api-ts/openapi-generator@4.23.0 :tada:
The release is available on npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
:tada: This PR is included in version @api-ts/express-wrapper@1.0.28 :tada:
The release is available on npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
:tada: This PR is included in version @api-ts/typed-express-router@1.1.8 :tada:
The release is available on npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
:tada: This PR is included in version @api-ts/superagent-wrapper@1.2.3 :tada:
The release is available on npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
:tada: This PR is included in version @api-ts/io-ts-http@3.1.0 :tada:
The release is available on npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
This PR aims to introduce a union-consolidation step, where we can simplify union schemas if they meet certain conditions.
Motivation:
We have encountered multiple codecs that type the same
A
type with differentI
types. For example, a value intended as aboolean
at runtime might be passed into the API as aboolean
(true
orfalse
), astring
("true"
or"false"
), or even anumber
(0
or1
). Currently,dev-portal
displays all these options as valid ways to pass a boolean to the API. However, this can be overwhelming and unnecessary for clients. If the API ultimately expects aboolean
(typed ast.boolean
), we should simplify this by presenting only the primitiveboolean
type.Solution: We propose the following criteria for consolidating union schemas into a single primitive type:
I
) type is a union.A
) type is a primitive type (specifically,string
,number
, orboolean
).A
type exists literally within theI
type.To support this, we need to address two aspects that are not currently available:
Identifying Primitive Types: Add a
primitive
property to theschema
type to identify primitiveio-ts
codecs.Determining Intermediate Types: Add a
decodedType
property (name can be revised) to theschema
type. This will specify the runtime type of codecs likeBooleanFromString
orNumberFromString
, enabling us to determine if a union containing these codecs can be consolidated into a single primitive type.Ticket: DX-614