Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arazzo/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
high "github.com/pb33f/libopenapi/datamodel/high/arazzo"
v3high "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
4 changes: 2 additions & 2 deletions arazzo/criterion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/pb33f/libopenapi/arazzo/expression"
high "github.com/pb33f/libopenapi/datamodel/high/arazzo"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
)

func TestEvaluateCriterion_SimpleCondition_StatusCodeComparison(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions arazzo/engine_coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
high "github.com/pb33f/libopenapi/datamodel/high/arazzo"
v3high "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down Expand Up @@ -2067,8 +2067,8 @@ func TestFetchSourceBytes_WindowsDriveInHost(t *testing.T) {
driveAndPath := filepath.ToSlash(testFile)
fakeURL := &url.URL{
Scheme: "file",
Host: driveAndPath[:2], // e.g. "/p" on Unix, "C:" on Windows
Path: driveAndPath[2:], // rest of path
Host: driveAndPath[:2], // e.g. "/p" on Unix, "C:" on Windows
Path: driveAndPath[2:], // rest of path
}

// This only works as a Windows drive when Host is like "X:" (letter + colon).
Expand Down
4 changes: 2 additions & 2 deletions arazzo/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/pb33f/libopenapi/arazzo/expression"
high "github.com/pb33f/libopenapi/datamodel/high/arazzo"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
6 changes: 3 additions & 3 deletions arazzo/expression/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package expression
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/pb33f/testify/assert"
"go.yaml.in/yaml/v4"
)

Expand Down Expand Up @@ -56,8 +56,8 @@ nested:
a~c: tilde
`),
ResponseHeaders: map[string]string{
"Content-Type": "application/json",
"X-Request-Id": "req-999",
"Content-Type": "application/json",
"X-Request-Id": "req-999",
},
ResponseBody: buildYAMLNode(t, `results:
- id: 1
Expand Down
4 changes: 2 additions & 2 deletions arazzo/expression/gap_coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package expression
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
2 changes: 1 addition & 1 deletion arazzo/expression/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package expression
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/pb33f/testify/assert"
)

// ---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions arazzo/final_coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (

"github.com/pb33f/libopenapi/arazzo/expression"
high "github.com/pb33f/libopenapi/datamodel/high/arazzo"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
6 changes: 3 additions & 3 deletions arazzo/gap_coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (

"github.com/pb33f/libopenapi/arazzo/expression"
high "github.com/pb33f/libopenapi/datamodel/high/arazzo"
v3high "github.com/pb33f/libopenapi/datamodel/high/v3"
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
lowarazzo "github.com/pb33f/libopenapi/datamodel/low/arazzo"
v3high "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
4 changes: 2 additions & 2 deletions arazzo/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

high "github.com/pb33f/libopenapi/datamodel/high/arazzo"
v3high "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
)

func TestResolveSources_PopulatesDocumentWithConfiguredFactories(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions arazzo/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
v3high "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
4 changes: 2 additions & 2 deletions arazzo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/pb33f/libopenapi/datamodel/low"
lowArazzo "github.com/pb33f/libopenapi/datamodel/low/arazzo"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
4 changes: 2 additions & 2 deletions bundler/bundler_composer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
4 changes: 2 additions & 2 deletions bundler/bundler_embedded_rootrefs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/pb33f/libopenapi"
"github.com/pb33f/libopenapi/bundler/test/specs/rootrefs"
"github.com/pb33f/libopenapi/datamodel"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
)

func TestBundleDocument_Embedded_RootRelativeRefs(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions bundler/bundler_issue873_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
highbase "github.com/pb33f/libopenapi/datamodel/high/base"
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/index"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
4 changes: 2 additions & 2 deletions bundler/bundler_ref_rewrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/pb33f/libopenapi"
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/libopenapi/index"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
)

// assertNoFilePathRefs checks that no file-path refs remain in the bundled output
Expand Down
4 changes: 2 additions & 2 deletions bundler/bundler_strict_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

"github.com/pb33f/libopenapi/datamodel"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
)

func TestStrictValidation_RefWithSiblings_ShouldError(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions bundler/bundler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
4 changes: 2 additions & 2 deletions bundler/composer_functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/pb33f/libopenapi/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
"go.yaml.in/yaml/v4"
)

Expand Down
5 changes: 3 additions & 2 deletions bundler/detect_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

v3 "github.com/pb33f/libopenapi/datamodel/low/v3"
"github.com/stretchr/testify/assert"
"github.com/pb33f/testify/assert"
"go.yaml.in/yaml/v4"
)

Expand Down Expand Up @@ -712,7 +712,8 @@ func TestDetectOpenAPIComponentType_JSONSourced(t *testing.T) {

// TestGetNodeKeys_UniformQuoting guards the detector's key-filter against JSON. When every
// key in a mapping shares the same quote style, the style carries no intent to escape
// keywords, the filter only kicks in when styles are mixed within one mapping.
//
// keywords, the filter only kicks in when styles are mixed within one mapping.
func TestGetNodeKeys_UniformQuoting(t *testing.T) {
cases := []struct {
name string
Expand Down
4 changes: 2 additions & 2 deletions bundler/external_component_ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/pb33f/libopenapi"
"github.com/pb33f/libopenapi/datamodel"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
)

// TestBundleDocument_ExternalParameterRef tests that external $ref in components.parameters
Expand Down
137 changes: 137 additions & 0 deletions bundler/issue590_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Copyright 2026 Princess Beef Heavy Industries / Dave Shanley
// SPDX-License-Identifier: MIT

package bundler

import (
"context"
"log/slog"
"os"
"path/filepath"
"strings"
"sync"
"testing"

"github.com/pb33f/libopenapi"
"github.com/pb33f/libopenapi/datamodel"
"github.com/pb33f/testify/assert"
"github.com/pb33f/testify/require"
)

type issue590LogCapture struct {
mu sync.Mutex
records []string
}

func (h *issue590LogCapture) Enabled(_ context.Context, level slog.Level) bool {
return level >= slog.LevelError
}

func (h *issue590LogCapture) Handle(_ context.Context, record slog.Record) error {
h.mu.Lock()
defer h.mu.Unlock()
var b strings.Builder
b.WriteString(record.Message)
record.Attrs(func(attr slog.Attr) bool {
b.WriteByte(' ')
b.WriteString(attr.Key)
b.WriteByte('=')
b.WriteString(attr.Value.String())
return true
})
h.records = append(h.records, b.String())
return nil
}

func (h *issue590LogCapture) WithAttrs(_ []slog.Attr) slog.Handler {
return h
}

func (h *issue590LogCapture) WithGroup(_ string) slog.Handler {
return h
}

func (h *issue590LogCapture) joined() string {
h.mu.Lock()
defer h.mu.Unlock()
return strings.Join(h.records, "\n")
}

func TestBundleDocument_Issue590_NoFalseRolodexErrors(t *testing.T) {
tmp := t.TempDir()
specDir := filepath.Join(tmp, "oapispec")
require.NoError(t, os.MkdirAll(filepath.Join(specDir, "ops", "somefolder"), 0755))
require.NoError(t, os.MkdirAll(filepath.Join(specDir, "parameters"), 0755))

openapi := `openapi: 3.1.0
info:
title: Common schemas
version: 0.0.1
servers:
- url: http://localhost:8080/
paths:
/somePath:
$ref: './ops/somefolder/someOp.yaml'
components:
parameters:
foo:
$ref: "./parameters/list.yaml#/foo"
bar:
in: query
name: bar
schema:
type: integer
required: false
`
operation := `get:
parameters:
- $ref: '../../parameters/list.yaml#/foo'
responses:
"200":
content:
application/json:
schema:
type: string
`
parameters := `foo:
name: SomeName
in: path
required: true
schema:
type: string
`

require.NoError(t, os.WriteFile(filepath.Join(specDir, "openapi.yaml"), []byte(openapi), 0644))
require.NoError(t, os.WriteFile(filepath.Join(specDir, "ops", "somefolder", "someOp.yaml"), []byte(operation), 0644))
require.NoError(t, os.WriteFile(filepath.Join(specDir, "parameters", "list.yaml"), []byte(parameters), 0644))

logs := &issue590LogCapture{}
config := datamodel.NewDocumentConfiguration()
config.AllowFileReferences = true
config.ExtractRefsSequentially = true
config.BasePath = specDir
config.Logger = slog.New(logs)

specBytes, err := os.ReadFile(filepath.Join(specDir, "openapi.yaml"))
require.NoError(t, err)

doc, err := libopenapi.NewDocumentWithConfiguration(specBytes, config)
require.NoError(t, err)

v3Model, errs := doc.BuildV3Model()
require.Empty(t, errs)

bundled, err := BundleDocument(&v3Model.Model)
require.NoError(t, err)

output := string(bundled)
assert.Contains(t, output, "name: SomeName")
assert.Equal(t, 2, strings.Count(output, "name: SomeName"))
assert.NotContains(t, output, "parameters/list.yaml")
assert.NotContains(t, output, "$ref")

logOutput := logs.joined()
assert.NotContains(t, logOutput, "unable to open the rolodex file")
assert.NotContains(t, logOutput, filepath.Join(tmp, "parameters", "list.yaml"))
assert.NotContains(t, logOutput, filepath.Join(specDir, "parameters", "parameters", "list.yaml"))
}
Loading
Loading