openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

feat: fixed typescript error dynamic paths

Open walid-mos opened this issue 10 months ago • 3 comments

Changes

Openapi-typescript creates an faulty file when using --path-params-as-types to generate types when nested path parameters exists.

This is particularly annoying when used with a Restful CRUD like :

  • /users
  • /users/{userId} ...

#1752

How to Review

How can a reviewer review your changes? What should be kept in mind for this review?

Checklist

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

walid-mos avatar Jan 20 '25 20:01 walid-mos

Deploy Preview for openapi-ts ready!

Name Link
Latest commit abbea8cea748b4bfbcf3418b2b4e976587d97058
Latest deploy log https://app.netlify.com/projects/openapi-ts/deploys/678eb2cd80b01b000835113e
Deploy Preview https://deploy-preview-2106--openapi-ts.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Jan 20 '25 20:01 netlify[bot]

⚠️ No Changeset found

Latest commit: abbea8cea748b4bfbcf3418b2b4e976587d97058

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

changeset-bot[bot] avatar Jan 20 '25 20:01 changeset-bot[bot]

Hello, I drafted the PR because I thought there was a bug in my solution.

Finally I came across this observation, when you use a path that has a static part after the dynamic part, you have to add a / to make the typing work.

I don't know if that's likely to cause a problem, in my case it's fine, but I don't want to speak for other people.

Here's some example of what i am talking about : Capture d’écran 2025-01-20 à 23 07 06 Capture d’écran 2025-01-20 à 23 10 20

without trailing slash: Capture d’écran 2025-01-20 à 23 10 43

any other path works fine

walid-mos avatar Jan 20 '25 22:01 walid-mos