Skip to content

fix: Avoid index signature error for paths with empty params #1156

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

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

horaklukas
Copy link
Contributor

@horaklukas horaklukas commented Jun 1, 2023

Changes

It fixes using --path-as-params-types option for paths that doesn't contain a param (like /api/user). In that case, using the option causes generating path name as [path: '/api/user'] and produces compiler error An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead.

How to Review

It fixes this fix. The pathParams variable is already non-empty variable, but can have empty size.

Checklist

  • Unit tests updated
  • README updated - not necessary [bugfix]
  • examples/ directory updated (only applicable for openapi-typescript) - not necessary [bugfix]

@changeset-bot
Copy link

changeset-bot bot commented Jun 1, 2023

🦋 Changeset detected

Latest commit: f5a9a48

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

@horaklukas horaklukas force-pushed the fix/empty-params-in-path branch from 6f9599e to f5a9a48 Compare June 1, 2023 07:12
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.

Looks great! Great tests, too.

@drwpow drwpow merged commit ad017a9 into openapi-ts:main Jun 12, 2023
@github-actions github-actions bot mentioned this pull request Jun 12, 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.

2 participants