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: Update @hey-api/openapi-ts version and re-enable namespacing enums #136

Merged

Conversation

collink
Copy link
Contributor

@collink collink commented Aug 2, 2024

I noticed that after updating to 1.4.1, that enums were being spit out next to the types instead of namespaced like previously. After some digging, I found that this was a @hey-api/openapi-ts issue which was resolved this week with a PR and the release of v0.52.0.

This PR does the following:

  • bumps @hey-api/openapi-ts from v0.45.1 => v0.52.0
    • this is to regain enum namespacing
  • bumps ts-morph from v22.0.0 => v23.0.0
    • this was to quiet some TS errors I was seeing
  • bumps typescript from v5.3.3 => v5.5.4
    • this was to quiet some TS errors I was seeing
  • updates relevant tests
  • updates relevant test snapshots

Looks like a huge diff, but it's almost entirely pnpm-lock.json, which we can just leave if you like, or you could re-run so that maybe the diff is smaller?

Why is this change important? The issue is that if you have enums defined in your OAPI YAML, @hey-api/openapi-ts (prior to v0.52.0) is depositing the TS enums directly next to the types, so you end up with enums that look like this:

export type Job = {
  // ...
  status: 'PENDING' | 'DONE',
  // ...
}

export enum status6 {
  PENDING: 'PENDING',
  DONE: 'DONE',
}

Before this change (and with this PR), that would look more like this:

export type Job = {
  // ...
  status: 'PENDING' | 'DONE',
  // ...
}

export namespace Job {
  export enum status {
    PENDING: 'PENDING',
    DONE: 'DONE',
  }
}

It's SO much less ambiguous to be able to use Job.status.DONE in my code than status6.DONE. 😅

@collink
Copy link
Contributor Author

collink commented Aug 2, 2024

@7nohe @seriouslag I saw that there's a couple-week-old PR open for bumping the @hey-api/openapi-ts version, but this one bumps it to the current version. I was able to build and generate correctly without any major changes (just some type-related tweaks). Thanks again for the lib!

@7nohe
Copy link
Owner

7nohe commented Aug 6, 2024

@collink Sorry for the late reply. I would appreciate it if you could resolve the conflicts.

@collink
Copy link
Contributor Author

collink commented Aug 7, 2024

@collink Sorry for the late reply. I would appreciate it if you could resolve the conflicts.

@7nohe no problem! All done 😄

@7nohe 7nohe merged commit 5b6e807 into 7nohe:main Aug 12, 2024
4 checks passed
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