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

feat(swagger-ts): support nullable types #493

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

raveclassic
Copy link
Contributor

Hi, this PR adds support for nullable: true annotations for types in swagger-ts plugin. The annotation seems to be supported but there's a bug that skips creation of union type.

@vercel
Copy link

vercel bot commented Oct 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kubb ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 2:20pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 16, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d53d48b:

Sandbox Source
advanced-pet-store Configuration
faker-pet-store Configuration
msw-pet-store Configuration
react-query-pet-store Configuration
typescript-pet-store Configuration
simple-single-pet-store Configuration
solid-query-pet-store Configuration
svelte-query-pet-store Configuration
swr-pet-store Configuration
vue-query-pet-store Configuration
zod-pet-store Configuration
zodios-pet-store Configuration
client-pet-store Configuration

@stijnvanhulle
Copy link
Collaborator

@all-contributors please add @raveclassic for code

@allcontributors
Copy link
Contributor

@stijnvanhulle

I've put up a pull request to add @raveclassic! 🎉

@raveclassic
Copy link
Contributor Author

@stijnvanhulle I fixed the test but it seems there's a type issue somewhere in the internals, as TypeBuilder#getTypeFromSchema received undefined instead of object, I couldn't find the reason.

@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

Merging #493 (d53d48b) into main (0c676e4) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #493   +/-   ##
=======================================
  Coverage   86.35%   86.35%           
=======================================
  Files         106      106           
  Lines        6003     6003           
  Branches      773      774    +1     
=======================================
  Hits         5184     5184           
  Misses        818      818           
  Partials        1        1           
Files Coverage Δ
...ackages/swagger-ts/src/generators/TypeGenerator.ts 65.53% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@raveclassic
Copy link
Contributor Author

Hi @stijnvanhulle, it seems something is off with E2E tests.
typecheck shows an error which I can't reproduce locally.
The issue is on the line e2e/src/gen/mocks/databasesController/createDatabasesUpdateMaintenanceWindow.ts:56, and TS in the current E2E CI snapshot is unable to assign return type of createDatabaseMaintenanceWindow, which is DatabaseMaintenanceWindow (or {...} | null) to DatabasesUpdateMaintenanceWindowMutationRequest which is DatabaseMaintenanceWindow | null (or {...} | null | null).
Essentially, there should be no error.

@stijnvanhulle
Copy link
Collaborator

Hi @stijnvanhulle, it seems something is off with E2E tests. typecheck shows an error which I can't reproduce locally. The issue is on the line e2e/src/gen/mocks/databasesController/createDatabasesUpdateMaintenanceWindow.ts:56, and TS in the current E2E CI snapshot is unable to assign return type of createDatabaseMaintenanceWindow, which is DatabaseMaintenanceWindow (or {...} | null) to DatabasesUpdateMaintenanceWindowMutationRequest which is DatabaseMaintenanceWindow | null (or {...} | null | null). Essentially, there should be no error.

Hi, can you pull in the main in to your branch? There was an issue on a previous PR but it should be fixed now.

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.

2 participants