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

Fix empty request / response bodies #1280

Merged

Conversation

pvanagtmaal
Copy link
Contributor

Changes

Fixes #1109 and #1174

How to Review

Nothing special

Checklist

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

@changeset-bot
Copy link

changeset-bot bot commented Aug 8, 2023

🦋 Changeset detected

Latest commit: 32ac1e5

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

@pvanagtmaal
Copy link
Contributor Author

@drwpow The tests that are failing are because we cannot simply return never for responses anymore because the headers could still be set. Do you consider this a problem / breaking change? IMO it is not a problem, since types of response objects that were never wouldn't be used anyways. 🤔

@drwpow
Copy link
Contributor

drwpow commented Aug 8, 2023

This is a good change to make! No I think you’re right—I can’t see this actually being a “breaking” change for most people; this feels like a bugfix. content: never; is a better type than having its parent be never.

I’m OK with updating the test snapshots to reflect the changes made here. There’s not really an automated script to handle it because I kinda like making updating snapshots annoying :P (i.e. it shouldn’t happen frequently and in bulk)

@drwpow
Copy link
Contributor

drwpow commented Aug 8, 2023

Also, so sorry to do this to you, but I realized Prettier was out of date and bumped it 😓. The diff shouldn’t be too bad, but let me know if you encounter any annoying conflicts.

@pvanagtmaal
Copy link
Contributor Author

Not sure why the CI is failing, tests are passing locally:

~/openapi-typescript/packages/openapi-typescript on  fix/empy-response-or-request-objects [$?] is 📦 v6.4.3 via  v18.10.0
❯ pnpm run test

> [email protected] test ~/openapi-typescript/packages/openapi-typescript
> run-p -s test:*


 RUN  v0.33.0 ~/openapi-typescript/packages/openapi-typescript

 ✓ test/cli.test.ts (8) 22314ms
 ✓ test/cjs.test.ts (1) 709ms
 ✓ test/yaml.test.ts (1) 430ms
 ✓ test/utils.test.ts (35)
 ✓ test/schema-object.test.ts (67)
 ✓ test/load.test.ts (7)
 ✓ test/response-object.test.ts (2)
 ✓ test/operation-object.test.ts (1)
 ✓ test/index.test.ts (26) 22131ms
 ✓ test/paths-object.test.ts (3)
 ✓ test/components-object.test.ts (5)
 ✓ test/request-body-object.test.ts (2)
 ✓ test/invalid.test.ts (2)
 ✓ test/path-item-object.test.ts (3)
 ✓ test/webhooks-object.test.ts (2)
 ✓ test/header-object.test.ts (1)

 Test Files  16 passed (16)
      Tests  166 passed (166)
   Start at  10:02:05
   Duration  22.87s (transform 465ms, setup 0ms, collect 2.46s, tests 45.70s, environment 3ms, prepare 1.76s)

@drwpow
Copy link
Contributor

drwpow commented Aug 9, 2023

@pvanagtmaal you’ll need to update the snapshots in examples/* with the newly-generated types. The tests are failing on my machine. Also be sure to run pnpm run build so you’re testing the freshly-built client (many tests test the actual compiled CLI version just to make sure it’s working, and that won’t rebuild automatically just from editing .ts files unless you’re running pnpm run dev)!

@pvanagtmaal pvanagtmaal force-pushed the fix/empy-response-or-request-objects branch from 4fe895d to 32ac1e5 Compare August 10, 2023 17:21
@@ -16033,7 +16041,14 @@ export interface external {
page?: number;
region?: external["shared/attributes/region_slug.yml"];
};
"shared/responses/accepted.yml": never
"shared/responses/accepted.yml": {
headers: {
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉 🎉 🎉

These were the type of test failures we like to see 😄

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.

Thank you! This is a huge fix 🙏

@drwpow drwpow merged commit 50441d0 into openapi-ts:main Aug 10, 2023
5 checks passed
@github-actions github-actions bot mentioned this pull request Aug 10, 2023
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.

Responses without bodies also omit headers from generated output.
2 participants