-
Notifications
You must be signed in to change notification settings - Fork 55
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
Allow resolving of external refs in openapi #70
Allow resolving of external refs in openapi #70
Conversation
Im not sure why the Scrutinizer tests aren't passing. I have no issues when I run the tests locally
|
Will this also support local references to a relative path? |
@@ -9,7 +9,7 @@ type SpecificationLoader interface { | |||
func New() SpecificationLoader { | |||
return &processingLoader{ | |||
&autoLoader{ | |||
loader: openapi3.NewLoader(), | |||
loader: &openapi3.Loader{IsExternalRefsAllowed: true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks for the PR. Perhaps this behavior should be configurable. What do you think?
I suggest adding options.
For package loader.
type Options struct {
IsExternalRefsAllowed bool
}
func New(options Options) SpecificationLoader {
return &processingLoader{
&autoLoader{
loader: &openapi3.Loader{
IsExternalRefsAllowed: options.IsExternalRefsAllowed,
},
},
}
}
YAML option
# OpenAPI specification options
openapi:
specification_url: 'path/to/your/openapi-specification.yaml'
allow_external_refs: true
In config package
type Configuration struct {
// OpenAPI options
SpecificationURL string
AllowExternalRefs bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. The PR in its current form is for a "PoC" if you like. I will add this and update the PR.
@strider2038 What to do about the failing tests in the CI. They pass locally on my machine. Can you confirm it's the same for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought a little more. It seems that it is better to leave the behavior as simple as possible. If it is necessary for security reasons, it is better to add an option to disable reference reading.
What to do about the failing tests in the CI. They pass locally on my machine. Can you confirm it's the same for you?
It looks like these are some issues with scrutinizer in newer versions of Go.
@crjones |
@strider2038 Any idea when you will release this? |
@kylehodgetts released in v0.3.3 |
support added in v0.3.3 via muonsoft#70
Given an API whose response schema is hosted externally, i want to be able to mock this API without having to edit the openapi file to move the schema definitions inline.
Before the change, openapi-mock would throw an error about encountering a disallowed external reference. Now mock responses work as expected, returning mock responses that conform to the schema hosted at the given url.