You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The $ref resolution for external file references appears inconsistent when the reference is used directly in the paths section, compared to when it is indirectly used via components.
Here, the reference in the components section resolves correctly from components.yaml.
Non-Working Example
base.yaml
openapi: 3.0.0
info:
title: Example API
version: 1.0.0
paths:
"/test":
post:
description: Update script
operationId: updateScript
parameters:
- $ref: './components.yaml#/components/parameters/test'
tags:
- scripts
responses:
'200':
description: OK
Here, the $ref for parameters used directly in paths does not resolve successfully if it points to an external file (components.yaml).
Expected Behavior
The $ref in parameters under paths should resolve properly when pointing to an external file, just as it works when referenced indirectly via the components section.
Testing Code
This is the code I used to test parameters resolution:
package main
import (
"fmt"
"os"
"github.com/pb33f/libopenapi"
"github.com/pb33f/libopenapi/datamodel"
)
func main() {
// Load the primary OpenAPI spec
bytes, _ := os.ReadFile("./routes.yaml")
// Build the OpenAPI document with configuration
document, _ := libopenapi.NewDocumentWithConfiguration(bytes, &datamodel.DocumentConfiguration{
AllowRemoteReferences: true,
AllowFileReferences: true,
BasePath: "./",
})
// Build the V3 OpenAPI Model
docModel, _ := (document).BuildV3Model()
fmt.Println(docModel)
// Serialize the resolved document for export
data, _ := document.Render()
file, _ := os.Create("./output.yaml")
file.Write(data)
file.Close()
}
Environment:
libopenapi version: v0.21.2
Go version: go version go1.23.0
The text was updated successfully, but these errors were encountered:
dani2819
changed the title
Reference Resolver Fails for External Parameter Definitions in paths Section
Reference resolver fails for external parameter definitions in paths section
Feb 13, 2025
Description
The
$ref
resolution for external file references appears inconsistent when the reference is used directly in the paths section, compared to when it is indirectly used via components.Working Example
base.yaml
components.yaml
Here, the reference in the components section resolves correctly from
components.yaml
.Non-Working Example
base.yaml
Here, the
$ref
for parameters used directly in paths does not resolve successfully if it points to an external file (components.yaml
).Expected Behavior
The
$ref
in parameters under paths should resolve properly when pointing to an external file, just as it works when referenced indirectly via the components section.Testing Code
This is the code I used to test parameters resolution:
Environment:
libopenapi version: v0.21.2
Go version: go version go1.23.0
The text was updated successfully, but these errors were encountered: