Skip to content
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

$ref in parameters not being transpiled #984

Closed
1 of 2 tasks
wolfy1339 opened this issue Nov 10, 2022 · 4 comments · Fixed by #1061
Closed
1 of 2 tasks

$ref in parameters not being transpiled #984

wolfy1339 opened this issue Nov 10, 2022 · 4 comments · Fixed by #1061
Assignees
Labels
bug Something isn't working

Comments

@wolfy1339
Copy link

wolfy1339 commented Nov 10, 2022

Description

A brief description of the bug.

ReferenceObjects are not being transpiled into the types from the schema when used in OperationObject for the parameters field

This was working fine in 5.x, it stopped working in the 6.x releases.

Name Version
openapi-typescript 6.0.3
Node.js 18.12.0
OS + version macOS 13, Windows 11, etc.

Reproduction

How can this be reproduced / when did the error occur?
https://raw.githubusercontent.com/octokit/octokit-next.js/main/cache/types-openapi/ghes-3.2.json on line 431, for the /admin/hooks/{hook_id} path
Generated types: https://raw.githubusercontent.com/octokit/octokit-next.js/fix-types/packages/types-openapi-ghes-3.2/index.d.ts on line 17291

You can see that only the first parameter gets transpiled

Expected result

(in case it’s not obvious)

Checklist

  • My OpenAPI schema passes a validator
  • I’m willing to open a PR (see CONTRIBUTING.md)
@wolfy1339
Copy link
Author

I retried with the code from #986 and it did not fix this problem

@wolfy1339 wolfy1339 changed the title Not all paramerters are being transpiled in the OperationObject Not all parameters are being transpiled in the OperationObject Nov 13, 2022
@wolfy1339 wolfy1339 changed the title Not all parameters are being transpiled in the OperationObject $ref in parameters not being transpiled Nov 14, 2022
@wolfy1339
Copy link
Author

Reposted from #989

I think that the problem could be in this part of the code https://github.com/drwpow/openapi-typescript/blob/main/src/transform/operation-object.ts#L72-L74

This is expecting paramIn to be part of the ref like components["parameters"]["query"]["limit"] but it is actually components["parameters"]["limit"]

Originally posted by @axelhzf in #989 (comment)

@drwpow drwpow added the bug Something isn't working label Nov 16, 2022
@drwpow drwpow mentioned this issue Nov 16, 2022
3 tasks
@drwpow
Copy link
Contributor

drwpow commented Nov 16, 2022

@wolfy1339 yeah this is one area where it assumes there’s a hint in the $ref path about which type of param this is. I was trying to see if I could avoid doing an entire deep-pass over the whole schema to collect all parameters, but that may have to happen (which is tricky because we would not only need to collect all parameter definitions, but all $refs to parameters as well so they forward correctly).

In the meantime, please see the generated types here: https://github.com/drwpow/openapi-typescript/pull/997/files#diff-b43503415e823d5023ec484469dd542b2e2d6698bcc6112e4225053b9bab6dc7R83. Is this output acceptable as a workaround?

@drwpow drwpow self-assigned this Nov 16, 2022
@wolfy1339
Copy link
Author

I believe that would work.

wolfy1339 added a commit to octokit/openapi-types.ts that referenced this issue Jan 18, 2023
Until openapi-ts/openapi-typescript#984 is fixed (and any other blocking issue that may be found afterwards)
wolfy1339 added a commit to octokit/openapi-types.ts that referenced this issue Jan 19, 2023
Until openapi-ts/openapi-typescript#984 is fixed (and any other blocking issue that may be found afterwards)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants