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

failed to load OpenAPI specification from absolute path #71

Closed
T1p0un3t opened this issue Sep 7, 2022 · 1 comment
Closed

failed to load OpenAPI specification from absolute path #71

T1p0un3t opened this issue Sep 7, 2022 · 1 comment

Comments

@T1p0un3t
Copy link
Contributor

T1p0un3t commented Sep 7, 2022

Hello,

I try to start openapi-mock with a locale specification file.
the file are not in the same folder (another mount point).

file configuration

openapi:
  specification_url: '/path/to/your/openapi-specification.yaml'

Start command
./openapi-mock serve -c my-mock-config.yaml

Error

failed to load OpenAPI specification from './/path/to/your/openapi-specification.yaml': open .//path/to/your/openapi-specification.yaml: no such file or directory

the path are prefixed with ./ and the file are found on local folder.

I think it's due to this line .

if specificationURLIsRelativeFilename(filename, fileConfig) {
	fileConfig.OpenAPI.SpecificationURL = filepath.Dir(filename) + "/" + fileConfig.OpenAPI.SpecificationURL
}

the filepath.Dir(filename) + "/" + prefix should be conditioned on the presence of a / at the beginning of the path to avoid this case.

shouldn't the function specificationURLIsRelativeFilename only test if the path starts with ./ to validate a relative path?

A priori this self-correction does not seem necessary. Maybe checking the existence of the file with os.Stat(filename) can be enough ?

T1p0un3t added a commit to T1p0un3t/openapi-mock that referenced this issue Sep 7, 2022
T1p0un3t added a commit to T1p0un3t/openapi-mock that referenced this issue Sep 9, 2022
strider2038 added a commit that referenced this issue Sep 12, 2022
fix(#71): naive fix excluding absolute path
@strider2038
Copy link
Collaborator

Fixed in v0.3.3

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

2 participants