Description
Pre- 4.0.0 when failing to parse a $ref, the error would come out like this:
Error resolving $ref pointer "#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
Now it's kinda annoying since the cwd is added to the beginning by default. This path seems to be mostly useless since the document doesn't exist there and it's just guessing.
Error resolving $ref pointer "d:/git/node-app/#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
(actual location)
d:/git/node-app/test/files/invalid-refs.json#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.'
It should probably just default to an empty string if the path is not provided, and output the same as it used to do. Then if a path is provided when calling validate/dereference, it uses that.
When calling swaggerParser.validate(file, swagger, ...
I also see inconsistent results based on the value of the first parameter (path).
swaggerParser.validate('', swagger, ...
gives meError resolving $ref pointer "d:/git/node-app/#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
when i was expectingError resolving $ref pointer "#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
swaggerParser.validate('foo', swagger, ...
gives meError resolving $ref pointer "d:/git/node-app/foo#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
when i was expectingError resolving $ref pointer "foo#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
swaggerParser.validate('d:/git/node-app/test/files/invalid-refs.json', swagger, ...
gives me the expectedError resolving $ref pointer "d:/git/node-app/test/files/invalid-refs.json#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
swaggerParser.validate('./test/files/invalid-refs.json', swagger, ...
gives meError resolving $ref pointer "d:/git/node-app/test/files/invalid-refs.json#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
when i was expectingError resolving $ref pointer "./test/files/invalid-refs.json#/definitions/ApiResponse". \nToken "ApiResponse" does not exist.
TLDR:
- The use of process.cwd() for the default path seems wrong
- I can't seem to specify a custom path without it trying to resolve it. This may be expected behaviour if it's trying to use the path to get the swagger, but if the swagger is already provided, this seems to only be used for logging so should be customizable.
- It's difficult to test error messages now since I now need to convert the path using the same logic as swagger-parser.