-
-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
There seems to be some confusion with it sometimes using relative paths, and otherwise not. I see an attempt to fix this previously, but I'm not sure it was a complete fix.
Edit: I created a PR #498 with some failing tests. I don't know how to fix it, though!
To reproduce, clone the DigitalOcean spec:
git clone https://github.com/digitalocean/openapi
Then in the specification directory, create the following test:
package openapi_definitions
import (
"embed"
"fmt"
"io/fs"
"testing"
"github.com/pb33f/libopenapi"
"github.com/pb33f/libopenapi/bundler"
"github.com/pb33f/libopenapi/datamodel"
"gotest.tools/v3/assert"
)
//go:embed DigitalOcean-public.v2.yaml
var v2 []byte
//go:embed description.yml resources shared
var files embed.FS
func Doc() (libopenapi.Document, error) {
return libopenapi.NewDocumentWithConfiguration(v2, &datamodel.DocumentConfiguration{
LocalFS: &wrapper{files},
AllowFileReferences: true,
})
}
func TestDigitalOcean(t *testing.T) {
doc, err := Doc()
assert.NilError(t, err)
model, err := doc.BuildV3Model()
assert.NilError(t, err)
_, err = bundler.BundleDocument(&model.Model)
assert.NilError(t, err)
}
type wrapper struct {
delegate fs.FS
}
func (w *wrapper) Open(name string) (fs.File, error) {
open, err := w.delegate.Open(name)
fmt.Println("!!!!", name, err)
return open, err
}
For me it gets upset about loading all sorts of files. I've tried various tricks, like setting the base path to /, wrapping the embed.FS, etc, but nothing seems to do the trick.
!!!! resources/addons/responses/resources/gen-ai/genai_delete_workspace.yml open resources/addons/responses/resources/gen-ai/genai_delete_workspace.yml: file does not exist
You can see it doubling up on the path names: resources/addons/responses/ + resources/gen-ai/genai_delete_workspace.yml
Metadata
Metadata
Assignees
Labels
No labels