question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameters names are different from their usage names

See original GitHub issue

What are the steps to reproduce this issue?

This might be related to using requestBodies as an abstraction layer between paths and schemas.

Fastest way to repro this is generate a client from this schema: https://github.com/Southclaws/storyden/blob/main/api/openapi.yaml

What happens?

Paths that have POST payloads specified as requestBody which $ref’s components/requestBodies will generate slightly different names for the parameters of the function compared to the actual invocations within the function:

image

In text form:

/**
 * @summary Register a new account with a username and password.
 */
export const authPasswordSignup = (authPasswordBody: AuthPasswordBody) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append("identifier", authRequest.identifier);
  formUrlEncoded.append("token", authRequest.token);

  return customInstance<AuthSuccessResponse>({
    url: `/v1/auth/password/signup`,
    method: "post",
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    data: formUrlEncoded,
  });
};

In this code, the generated function parameter is called authPasswordBody but the invocations for calls to formUrlEncoded.append has generated authRequest.

Some observations here:

  • The requestBody ref is named AuthPassword
  • The actual schema referenced by the requestBody is named AuthRequest

What versions are you using?

Operating System: mac Package Version: v6.9.6

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
anymaniaxcommented, Sep 23, 2022

will be fixed in the next release

0reactions
Southclawscommented, Oct 17, 2022

Working perfectly, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is using parameter names that differ from type names only by ...
coding standards - Is using parameter names that differ from type names only by casing considered a bad practice in C#? - Software...
Read more >
CA1719: Parameter names should not match member names
Rule description. A parameter name should communicate the meaning of a parameter and a member name should communicate the meaning of a member....
Read more >
Parameter name differs in partial method declaration - JetBrains
When processing partial methods, C# compiler only checks the order and the types of the parameters, not their names.
Read more >
The Importance of Parameter Names - LinkedIn
Client developers like descriptive parameter names such as firstName, totalDeductible, and ipAddress. At one glance they know what it does. Yet, ...
Read more >
Argument label and parameter name | Apple Developer Forums
The general idea is that it's desirable to use a different name for a parameter in the place where it's called, vs. its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found