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

Incorrect path resolving for absolut paths under windows #311

Closed
ScienceOfficer opened this issue Mar 8, 2023 · 5 comments
Closed

Incorrect path resolving for absolut paths under windows #311

ScienceOfficer opened this issue Mar 8, 2023 · 5 comments

Comments

@ScienceOfficer
Copy link

Hello everyone,

unfortunately I noticed that the resolving of absolute paths under windows is not working for me. The code doesn't seem to recognize that a absolute path is entered and prepends another absolute path.

I tracked the error down to this function (https://github.com/APIDevTools/json-schema-ref-parser/blob/main/lib/util/url.ts#L177). Both checks hasProjectDir and hasProjectUri evaluate to false as my api.yaml isn't part of this project. projectDir evaluates to C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\ in my setup but only C:\Projekte\projectname is shared between the library and the source code of the project.

It would be great if the problem could be fixed!

Here is also the stacktrace where you can see, what happend to the absolute path.

{
  "stack":"JSONParserError: Error opening file "C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\Projekte\projectname\dist\server\api.yaml" ENOENT: no such file or directory, open 'C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\Projekte\projectname\dist\server\api.yaml' at Object.<anonymous> (C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\resolvers\file.js:72:23) at Generator.throw (<anonymous>) at rejected (C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\resolvers\file.js:29:65)",
  "code":"ERESOLVER",
  "name":"ResolverError",
  "message":"Error opening file "C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\Projekte\projectname\dist\server\api.yaml" ENOENT: no such file or directory, open 'C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\Projekte\projectname\dist\server\api.yaml'",
  "source":"C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\Projekte\projectname\dist\server\api.yaml",
  "path":null,
  "ioErrorCode":"ENOENT",
  "footprint":"null+C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\Projekte\projectname\dist\server\api.yaml+ERESOLVER+Error opening file "C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\Projekte\projectname\dist\server\api.yaml" ENOENT: no such file or directory, open 'C:\Projekte\projectname\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\Projekte\projectname\dist\server\api.yaml'"
}

Used version of apidevtools: "@apidevtools/json-schema-ref-parser": "10.1.0"

@jonluca
Copy link
Collaborator

jonluca commented Mar 6, 2024

Fixed in v10.1.0

@jonluca jonluca closed this as completed Mar 6, 2024
@janiu-001
Copy link

janiu-001 commented Mar 7, 2024

i have the same error with v10.1.0, i install the packages on pnpm

\.pnpm\\@[email protected]\\node_modules\\@apidevtools\\json-schema-ref-parser\\dist\\.\\packages\\elderly-care\\common\\s
rc\\apidocs\\openapi.json+ERESOLVER+Error opening file

@jonluca
Copy link
Collaborator

jonluca commented Mar 7, 2024

Apologies I meant 11, can you try latest?

@janiu-001
Copy link

janiu-001 commented Mar 7, 2024

@jonluca thanks for your response, but i do not use the apidevtools+json-schema-ref-parser directly, i use the openapi-typescript-codegen, and it depend on the v10.1.0,

    "dependencies": {
        "@apidevtools/json-schema-ref-parser": "^11.1.0",
        "camelcase": "^6.3.0",
        "commander": "^11.1.0",
        "fs-extra": "^11.2.0",
        "handlebars": "^4.7.8"
    },

how can i do? By the way, i install the packages with pnpm, will i rebuild the openapi-typescript-codegen myself?

@BenCGI
Copy link

BenCGI commented Mar 8, 2024

Can confirm version 11 is working. Thanks for the fix!

@janiu-001 You can override the nested dependency via https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides in your own project. No need to rebuild the openapi-typescript-codegen stuff

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 a pull request may close this issue.

4 participants