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

localhost:PORT isn't recognized as a valid url #219

Closed
davidsonsns opened this issue Oct 1, 2021 · 5 comments
Closed

localhost:PORT isn't recognized as a valid url #219

davidsonsns opened this issue Oct 1, 2021 · 5 comments

Comments

@davidsonsns
Copy link
Contributor

What are the steps to reproduce this issue?

  1. swagger spec being delivered at http://localhost:6001/swagger/v1/swagger.json
  2. adds the target like below
  3. try to run orval
...
input: {
      target: 'http://localhost:6001/swagger/v1/swagger.json',
...

What happens?

validator.js doesn't recognize localhost:${PORT} as a valid URL and ORVAL concatenates it with the current path and throws the exception below:

ResolverError: Error opening file "/Users/myusername/myprojectfolder/http:/localhost:6001/swagger/v1/swagger.json"
ENOENT: no such file or directory, open '/Users/myusername/myprojectfolder/http:/localhost:6001/swagger/v1/swagger.json'
error Command failed with exit code 1.

What were you expecting to happen?

recognize localhost as a valid URL

Any other comments?

found a couple of PR opened on validator.js repository regarding this behavior: https://github.com/validatorjs/validator.js/issues?q=isurl+localhost
so, my guess is that we could improve it if (isString(path) && !isUrl(path)) { to if (isString(path) && !isUrl(path, { require_tld: false })) {

What versions are you using?

Operating System: macOS Big Sur Version 11.6
Package Version: ^6.1.1
Browser Version:

@anymaniax
Copy link
Collaborator

@davidsonsns nice investigation. Do you open a pull request for that changes?

@davidsonsns davidsonsns mentioned this issue Oct 1, 2021
3 tasks
@davidsonsns
Copy link
Contributor Author

davidsonsns commented Oct 1, 2021

@anymaniax I was opening rn 😅 plz let me know ur thots

@sdindu
Copy link

sdindu commented May 26, 2023

@anymaniax I was opening rn 😅 plz let me know ur thots

I am still getting this error today api - Error: ENOENT: no such file or directory, open 'C:\Users\xxx\source\repos\ABC\Sample\src\ABC.Sample.ClientApp\https:\localhost:7108\swagger\v1\swagger.json'

@melloware
Copy link
Collaborator

I have updated this again and I think it fixes all scenarios: #1032

@Choco-milk-for-u
Copy link

+1 still have this error

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

No branches or pull requests

5 participants