I want to parse an OpenAPI file that references another OpenAPI file like this (example taken from https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject):
{
"$ref": "definitions.json#/Pet"
}
I do this as follows:
func main() {
// on Linux e.g. /dev/my-openapi.json
// on Windows e.g. C:/dev/my-openapi.json
openapi := filepath.FromSlash("C:/dev/my-openapi.json")
swg := openapi3.NewSwaggerLoader()
swg.IsExternalRefsAllowed = true
oas, err := swg.LoadSwaggerFromFile(openapi)
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Printf("%s\n", oas.Info.Title)
}
}
This works on Linux (tested on a Mac) but not on Windows. Here I get something like this (my-openapi.json references my-other-openapi.json and both files are located in the same folder):
Error while resolving reference 'my-other-openapi.json#/components/responses/DefaultResponse': open my-other-openapi.json: The system cannot find the file specified.
I want to parse an OpenAPI file that references another OpenAPI file like this (example taken from https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#referenceObject):
{ "$ref": "definitions.json#/Pet" }I do this as follows:
This works on Linux (tested on a Mac) but not on Windows. Here I get something like this (
my-openapi.jsonreferencesmy-other-openapi.jsonand both files are located in the same folder):