Skip to content

feat(namedParameters): Add global named parameters option #914

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 26 commits into from
Sep 11, 2023

Conversation

Marcel-G
Copy link
Contributor

@Marcel-G Marcel-G commented Aug 16, 2023

Status

READY

Description

Often times routes have many path parameters. As the number grows, type-safety is less effective as arguments (commonly string or number types) can easily get used in the wrong order.
Using named parameters helps this, as you get the added safety of needing to specify the appropriate name for the parameter.

This PR adds a global useNamedParameters option which creates path parameters as a single object.

Related PRs

Supersedes previous implementations:

Todos

  • Tests
  • Documentation
  • Clients
    • angular
    • axios
    • react-query
    • svelte-query
    • vue-query
    • swr

Steps to Test or Reproduce

Outline the steps to test or reproduce the PR here.

> git pull --prune
> git checkout <branch>
> yarn install
> yarn prerelease

View the named-parameters builds under each client in tests/generated

@vercel
Copy link

vercel bot commented Aug 16, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @anymaniax on Vercel.

@anymaniax first needs to authorize it.

@Marcel-G Marcel-G force-pushed the feat/named-parameters-global branch from 04f0aad to 3abc99c Compare August 16, 2023 15:04
@Marcel-G Marcel-G marked this pull request as ready for review August 28, 2023 16:06
@Marcel-G Marcel-G force-pushed the feat/named-parameters-global branch from 03ffe00 to f242e0b Compare September 4, 2023 11:52
@anymaniax
Copy link
Collaborator

@Marcel-G thanks for the work!

@anymaniax anymaniax merged commit 663cafa into orval-labs:master Sep 11, 2023
@Marcel-G Marcel-G deleted the feat/named-parameters-global branch September 11, 2023 08:59
queryParams ? ', ...(params ? [params]: [])' : ''
}${body.implementation ? `, ${body.implementation}` : ''}] as const;`;
const queryKeyFn = `export const ${queryKeyFnName} = (${queryKeyProps}) => {
${isVue(outputClient) ? vueUnRefParams(props) : ''}
Copy link
Contributor

Choose a reason for hiding this comment

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

@Marcel-G is there any good reason why this was added? Please see #931 (comment) for context

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.

3 participants