kin-openapi
kin-openapi copied to clipboard
Support to skip resolving external references
Hello! I was wondering if it's possible to add support for allowing external references in OpenAPI v3 specification files, but skipping the resolution of those external references, such as when a $ref
object is used for a schema.
When creating a loader, you can define:
- IsExternalRefsAllowed boolean to allow/prevent external references from being used
- a ReadFromURIFunc (defaults to DefaultReadFromURI) which will allow to fine tune operations. Default implementation uses a cache and http.DefaultClient.
Hope it helps
Thanks for the info. I have a couple more questions.
From my understanding, if IsExternalRefsAllowed
is set to false
and an external reference exists in the spec, the parser will return an error. Is this correct?
If I have a spec that contains external references, but one or more of those external references are missing or do not exist, is it possible for the parser to continue parsing the remaining document and return the unmarshaled object?
The reason I ask is I've run into several OpenAPI v3 documents where external references exist, but those references simply do not exist. I would still like to use the parser and try to get the remaining data in the spec.
You are right if you disable external reference usage, you will get an error in such case.
As for missing external references, your source document is somewhat invalid since it references something that does not exist. You could still provide a ReadFromURIFUnc that snoozes 404 errors.