Skip to content

Commit aa189c0

Browse files
test: windows
1 parent 4554d8b commit aa189c0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/utils/references.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,16 @@ func (rc *ReferenceClassification) joinURL(relative string) (string, error) {
186186
// joinFilePath joins this file path reference with a relative path using Go's filepath package
187187
func (rc *ReferenceClassification) joinFilePath(relative string) (string, error) {
188188
// If relative path is absolute, return it as-is
189-
if filepath.IsAbs(relative) {
189+
// Check for both OS-specific absolute paths and Unix-style absolute paths (for cross-platform compatibility)
190+
if filepath.IsAbs(relative) || strings.HasPrefix(relative, "/") {
190191
return relative, nil
191192
}
192193

193194
// For all relative paths, join them with the base directory
194-
// This will work correctly on the native OS (Windows paths on Windows, Unix paths on Unix)
195-
return filepath.Join(filepath.Dir(rc.Original), relative), nil
195+
// Use filepath.Join for proper path handling, then convert to forward slashes for OpenAPI/JSON Schema compatibility
196+
joined := filepath.Join(filepath.Dir(rc.Original), relative)
197+
// Convert backslashes to forward slashes for cross-platform compatibility in OpenAPI contexts
198+
return strings.ReplaceAll(joined, "\\", "/"), nil
196199
}
197200

198201
// JoinReference is a convenience function that classifies the base reference and joins it with a relative reference.

0 commit comments

Comments
 (0)