-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: optional oneOf / allOf / anyOf / $ref's (#110)
previously, these would never be marked as optional, even if the key they belonged to wasn't `required` this was made evident whilst testing #109 which relies on `oneOf` to handle arrays of `type` this moves that logic up into the `AbstractSchemaBuilder`, and applies it more predictably, as well as swapping the order such that `nullable` always comes before `optional` this means that schemas like: ``` schema: type: object properties: enabled: "$ref": "#/components/schemas/actions-enabled" allowed_actions: "$ref": "#/components/schemas/allowed-actions" required: - enabled ``` will correctly mark `allowed_actions` as optional, and schemas like: ``` setup_intent_payment_method_options: description: '' properties: us_bank_account: anyOf: - $ref: >- #/components/schemas/setup_intent_payment_method_options_us_bank_account - $ref: >- #/components/schemas/setup_intent_type_specific_payment_method_options_client title: SetupIntentPaymentMethodOptions type: object ``` correctly mark `us_bank_account` as optional. note: the typescript types were already correct here. the problem wasn't picked up by typescript because were being stricter on the validation and then passing that to a looser type, eg: passing `T` to a `T | undefined` parameter.
- Loading branch information
Showing
12 changed files
with
9,796 additions
and
8,176 deletions.
There are no files selected for viewing
332 changes: 167 additions & 165 deletions
332
integration-tests/typescript-koa/src/generated/api.github.com.yaml/generated.ts
Large diffs are not rendered by default.
Oops, something went wrong.
972 changes: 488 additions & 484 deletions
972
integration-tests/typescript-koa/src/generated/api.github.com.yaml/schemas.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.