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

CLI: Mocking - allow local file external references #774

Merged

Conversation

kylehodgetts
Copy link
Contributor

@kylehodgetts kylehodgetts commented Sep 26, 2022

This PR closes #769

Changes

  • properly resolves local file paths for schema external references

Limitations

Due to getkin/kin-openapi#618 we are not able to resolve transitive reference dependencies i.e. an external schema you refer to in your openapi spec also has an external reference. At the time of writing, only direct external references are supported

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@netlify
Copy link

netlify bot commented Sep 26, 2022

Deploy Preview for kusk-docs-preview canceled.

Name Link
🔨 Latest commit 5e2c08b
🔍 Latest deploy log https://app.netlify.com/sites/kusk-docs-preview/deploys/63358f7c45ab97000843de37

@kylehodgetts kylehodgetts changed the title Kylehodgetts/bugfix/769 allow relative file references CLI: Mocking - allow local file external references Sep 29, 2022
@kylehodgetts kylehodgetts marked this pull request as ready for review September 29, 2022 10:18
@jasmingacic
Copy link
Contributor

jasmingacic commented Sep 29, 2022

It doesn't seem to be picking up files with relative paths

# go run main.go mock -i  ../../ttt.yaml 
⨯ error when parsing openapi spec: unable to load spec: open ../../ttt.yaml: no such file or directory 💔

exit status 1
# stat ../../ttt.yaml 
  File: ../../ttt.yaml
  Size: 7843            Blocks: 16         IO Block: 4096   regular file

Otherwise it is working

Signed-off-by: jasmingacic <jasmin.gacic@gmail.com>

cli, err := client.NewClientWithOpts(client.FromEnv)
apiSpec, err := apiParser.Parse(apiSpecLocation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylehodgetts i took the liberty to fix this.

jasmingacic
jasmingacic previously approved these changes Sep 29, 2022
mbana
mbana previously approved these changes Sep 29, 2022
Copy link
Contributor

@mbana mbana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comments are optional to resolve.

cmd/kusk/cmd/mock.go Show resolved Hide resolved
cmd/kusk/cmd/mock.go Show resolved Hide resolved
cmd/kusk/cmd/mock.go Show resolved Hide resolved
Signed-off-by: jasmingacic <jasmin.gacic@gmail.com>
@jasmingacic jasmingacic dismissed stale reviews from mbana and themself via 5e2c08b September 29, 2022 12:28
Copy link
Contributor

@mbana mbana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jasmingacic jasmingacic merged commit d4992d7 into main Sep 29, 2022
@jasmingacic jasmingacic deleted the kylehodgetts/bugfix/769-allow-relative-file-references branch September 29, 2022 12:38
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 this pull request may close these issues.

CLI: Mocking with local references doesn't work if not in the same directory as openapi.yaml file
3 participants