Skip to content

Conversation

StefanTerdell
Copy link
Contributor

@StefanTerdell StefanTerdell commented Mar 13, 2025

Changes

This PR adds support for boolean property schemas, ie:

{
  "type": "object",
  "properties": {
    "truthy": true,
    "falsy": false
  }
}

The PR changes the flow in the loop handling object properties to reach "edge-case" handling that was already present for boolean schemas. This was previously not reached due to an early error that was thrown if the property schema was not an object. Properties that were previously accessed directly from the schema object are now extracted conditionally before hand.

Closes #2198.

How to Review

See the added test case for details.

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

@StefanTerdell StefanTerdell requested a review from a team as a code owner March 13, 2025 12:09
@StefanTerdell StefanTerdell requested a review from gzm0 March 13, 2025 12:09
Copy link

netlify bot commented Mar 13, 2025

Deploy Preview for openapi-ts failed.

Name Link
🔨 Latest commit 5617b57
🔍 Latest deploy log https://app.netlify.com/projects/openapi-ts/deploys/67d2ccd687fb880008dedb5e

Copy link

changeset-bot bot commented Mar 13, 2025

🦋 Changeset detected

Latest commit: 5617b57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openapi-typescript Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR and test! As stated in the issue, this is a feature of JSONSchema, so it’s an easy addition given that it’s backwards-compatible. Thanks!

@drwpow drwpow merged commit fc3f7f8 into openapi-ts:main Mar 19, 2025
8 checks passed
@openapi-ts-bot openapi-ts-bot mentioned this pull request Mar 19, 2025
@StefanTerdell
Copy link
Contributor Author

Thank you @drwpow! Happy to contribute to a fantastic set of tools.

ut0xygen pushed a commit to ut0xygen/openapi-typescript that referenced this pull request Aug 5, 2025
* Add failing test case for boolean object props

* Fix boolean object props

* Add changeset

---------

Co-authored-by: Stefan Terdell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected error when property schemas are boolean
2 participants