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

fix(exports): strip referenced imports of models #61

Merged
merged 1 commit into from Apr 20, 2024

Conversation

seriouslag
Copy link
Collaborator

@seriouslag seriouslag commented Apr 11, 2024

The reference import path isn't needed as we have already imported all models into the file in question.

This fixes a bug I am having where the entire type with import is being put where a type is located.

The big issue with this import is that it is an absolute path on the computer that generated the code. This is an issue when we want to deploy the code in a library.

This changes:

  {
    prop1: string;
    myCustomProp: import("/User/person/project/src/openapi/generated/requests/models").MyCustomProp;
  }

to

  {
    prop1: string;
    myCustomProp: MyCustomProp;
  }

I would love to find another way to solve this, as this seems like a hack, but I am still looking for a solution.

A similar change may need to be added to the mutation queries but I do not have an example.

@seriouslag seriouslag requested a review from 7nohe April 11, 2024 13:15
@seriouslag seriouslag added the bug Something isn't working label Apr 11, 2024
@7nohe
Copy link
Owner

7nohe commented Apr 11, 2024

@seriouslag Is there any specific case I can reproduce? I would like to try reproducing it on my PC.

@seriouslag
Copy link
Collaborator Author

@seriouslag Is there any specific case I can reproduce? I would like to try reproducing it on my PC.

openapi.json

I was able to duplicate the issue with this file.

@seriouslag seriouslag force-pushed the fix/handle-referenced-imports branch from 044a1af to edbd14b Compare April 11, 2024 15:11
@seriouslag seriouslag changed the title fix(exports): strips referenced imports of models fix(exports): strip referenced imports of models Apr 11, 2024
@seriouslag seriouslag force-pushed the fix/handle-referenced-imports branch from edbd14b to b0b88b6 Compare April 11, 2024 15:19
The reference import path isn't needed as we import all Models into the file already
@seriouslag seriouslag force-pushed the fix/handle-referenced-imports branch from b0b88b6 to ec2e3f0 Compare April 11, 2024 15:20
@7nohe 7nohe merged commit be51e19 into main Apr 20, 2024
4 checks passed
@7nohe 7nohe deleted the fix/handle-referenced-imports branch April 20, 2024 07:29
seriouslag added a commit that referenced this pull request Apr 22, 2024
- Update to the latest `@hey-api/openapi-ts` version `0.42.1`
- Fixed a bug where types in mutation hooks were imported from a (non-relative) direct file import.
    - This is the same fix implemented in #61, which was done for query hooks.
- Fixed a bug where JSDocs were not being added to generated hooks.
- Add more unit tests

Fixes: #83
Enables work towards: #81
seriouslag added a commit that referenced this pull request Apr 23, 2024
- Update to the latest `@hey-api/openapi-ts` version `0.42.1`
  - fixes: #83,
  - Enables work towards #81
- Fixed a bug where types in mutation hooks were imported from a (non-relative) direct file import.
    - This is the same fix implemented in #61, which was done for query hooks.
    - Expand the match regex to take account of non-alphabetical file paths
      - fixes: #85
- Fixed a bug where JSDocs were not being added to generated hooks.
- Add more unit testing
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
Development

Successfully merging this pull request may close these issues.

None yet

2 participants