Skip to content

Generates incorrect dynamic path with integer parameters #1930

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

Closed
1 of 2 tasks
kleinepls opened this issue Sep 25, 2024 · 4 comments · Fixed by #1982
Closed
1 of 2 tasks

Generates incorrect dynamic path with integer parameters #1930

kleinepls opened this issue Sep 25, 2024 · 4 comments · Fixed by #1982
Labels
bug Something isn't working good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project openapi-ts Relevant to the openapi-typescript library PRs welcome PRs are welcome to solve this issue!

Comments

@kleinepls
Copy link

Description

Using the --path-params-as-types flag, the library doesn't generate the number type for OpenAPI integer type dynamic path parameters. It leaves it as integer, which is an invalid type in TypeScript.

Name Version
openapi-typescript 7.4.0
Node.js 20.17.0
OS + version Pop!_OS, kernel 6.9.3-76060903

Reproduction

Generate with the --path-params-as-types flag off of this example:

openapi: 3.0.0
info: 
  title: "test" 
components:
  schemas: {}
paths: 
  /user/{user_id}/profile:
    get:
      parameters:
        - name: user_id
          in: path
          required: true
          schema:
            type: integer

Result (omitting unrelated fields):

export interface paths {
    [path: `/user/${integer}/profile`]: {
        get: {
            parameters: {
                path: {
                    user_id: number; <- notice how this one is generated correctly.
                };
            };
        };

Checklist

@kleinepls kleinepls added bug Something isn't working openapi-ts Relevant to the openapi-typescript library labels Sep 25, 2024
@prewk
Copy link
Contributor

prewk commented Oct 30, 2024

@drwpow drwpow added PRs welcome PRs are welcome to solve this issue! good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project labels Oct 30, 2024
@drwpow
Copy link
Contributor

drwpow commented Oct 30, 2024

Good catch! Would love a PR fix for this, thank you

@prewk
Copy link
Contributor

prewk commented Oct 30, 2024

Sure, I'll give it go!

@prewk prewk mentioned this issue Oct 30, 2024
1 task
@prewk
Copy link
Contributor

prewk commented Oct 30, 2024

There.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project openapi-ts Relevant to the openapi-typescript library PRs welcome PRs are welcome to solve this issue!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants