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

Remote reference cannot be resolved #269

Closed
yozel opened this issue Apr 4, 2024 · 2 comments
Closed

Remote reference cannot be resolved #269

yozel opened this issue Apr 4, 2024 · 2 comments
Labels
requires investigation This needs to be looked at in more detail

Comments

@yozel
Copy link

yozel commented Apr 4, 2024

Hi, I found out a bug with the remote references.

Steps to reproduce:

package main

import (
	"errors"
	"fmt"

	"github.com/pb33f/libopenapi"
	"github.com/pb33f/libopenapi/datamodel"
)

var spec = []byte(`openapi: "3.0.0"
info:
  title: test
  version: "3"
paths: { }
components:
  schemas:
    Container:
      properties:
        pet:
          $ref: https://petstore3.swagger.io/api/v3/openapi.json#/components/schemas/Pet
`)

func main() {
	doc, err := libopenapi.NewDocumentWithConfiguration(spec, &datamodel.DocumentConfiguration{
		AllowRemoteReferences: true,
	})
	if err != nil {
		panic(err)
	}
	_, errs := doc.BuildV3Model()
	if len(errs) > 0 {
		fmt.Println(errors.Join(errs...))
	}
}
go run ./issues/...
cannot resolve reference `https://petstore3.swagger.io/api/v3/openapi.json#/components/schemas/Pet`, it's missing: $https:.['petstore3.swagger.io'].api.v3['openapi.json$'].components.schemas.Pet [11:11]

According to git bisect the culprit is 7119b51, which I could confirm that reverting this commit actually solves the issue.

@daveshanley
Copy link
Member

The commit was to prevent non http lookups from hitting the remote file system code, but it seems to have had a strange effect, thanks for finding this - will look into it.

@daveshanley daveshanley added the requires investigation This needs to be looked at in more detail label Apr 5, 2024
daveshanley added a commit that referenced this issue Apr 18, 2024
Regression undone
@daveshanley daveshanley mentioned this issue Apr 18, 2024
daveshanley added a commit that referenced this issue Apr 19, 2024
daveshanley added a commit that referenced this issue Apr 19, 2024
Regression undone
daveshanley added a commit that referenced this issue Apr 19, 2024
@daveshanley
Copy link
Member

This regression has been fixed in v0.16.0

A test was added to validate: https://github.com/pb33f/libopenapi/blob/main/document_test.go#L1348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires investigation This needs to be looked at in more detail
Projects
None yet
Development

No branches or pull requests

2 participants