From 7ff1f4bc5f335e88ae3f91d90e5bcb52ff5e2733 Mon Sep 17 00:00:00 2001 From: Tristan Cartledge Date: Wed, 18 Feb 2026 14:35:52 +0000 Subject: [PATCH] feat: upgrade yaml library from gopkg.in/yaml.v3 to go.yaml.in/yaml/v4 --- arazzo/arazzo_order_test.go | 2 +- arazzo/arazzo_test.go | 2 +- arazzo/core/criterion.go | 2 +- arazzo/core/criterion_syncchanges_test.go | 2 +- arazzo/core/criterion_test.go | 2 +- arazzo/core/reusable.go | 2 +- arazzo/core/reusable_test.go | 2 +- arazzo/criterion/condition.go | 2 +- arazzo/requestbody_test.go | 2 +- arazzo/reusable.go | 2 +- arazzo/successaction.go | 2 +- cmd/openapi/commands/openapi/bootstrap.go | 2 +- cmd/openapi/commands/overlay/apply.go | 2 +- cmd/openapi/commands/overlay/compare.go | 2 +- cmd/openapi/go.mod | 3 +- cmd/openapi/go.sum | 2 ++ expression/core/value.go | 2 +- expression/value.go | 2 +- expression/value_test.go | 2 +- extensions/core/extensions.go | 2 +- extensions/core/extensions_test.go | 2 +- extensions/extensions.go | 2 +- extensions/extensions_isequal_test.go | 2 +- extensions/extensions_test.go | 2 +- go.mod | 1 + go.sum | 2 ++ hashing/hashing.go | 2 +- hashing/hashing_test.go | 2 +- internal/interfaces/interfaces.go | 2 +- internal/interfaces/interfaces_test.go | 2 +- internal/testutils/utils.go | 2 +- internal/testutils/utils_test.go | 2 +- json/json.go | 2 +- json/json_test.go | 2 +- jsonpointer/jsonpointer.go | 2 +- jsonpointer/models_yaml_fallback_test.go | 8 ++--- jsonpointer/yamlnode.go | 2 +- jsonpointer/yamlnode_test.go | 2 +- jsonschema/oas3/core/jsonschema_test.go | 2 +- jsonschema/oas3/core/xml_test.go | 2 +- jsonschema/oas3/jsonschema_validate_test.go | 2 +- jsonschema/oas3/resolution.go | 2 +- jsonschema/oas3/resolution_defs.go | 2 +- jsonschema/oas3/resolution_defs_test.go | 2 +- jsonschema/oas3/resolution_external.go | 2 +- jsonschema/oas3/resolution_external_test.go | 2 +- jsonschema/oas3/resolution_test.go | 2 +- .../oas3/schema_exclusive_validation_test.go | 4 +-- jsonschema/oas3/schema_getters_test.go | 2 +- jsonschema/oas3/schema_isequal_test.go | 2 +- jsonschema/oas3/schema_validate_test.go | 4 +-- jsonschema/oas3/tests/go.mod | 1 + jsonschema/oas3/tests/go.sum | 2 ++ jsonschema/oas3/validation.go | 2 +- linter/config.go | 2 +- linter/config_loader.go | 2 +- linter/fix/engine.go | 2 +- linter/fix/engine_test.go | 2 +- linter/fix/terminal_prompter_test.go | 2 +- linter/format/format_test.go | 2 +- marshaller/coremodel.go | 2 +- marshaller/coremodel_getters_test.go | 2 +- marshaller/coremodel_jsonpath_test.go | 14 ++++++-- marshaller/coremodel_jsonpointer_test.go | 2 +- marshaller/extensions.go | 2 +- marshaller/factory.go | 2 +- marshaller/marshal.go | 2 +- marshaller/model.go | 2 +- marshaller/model_test.go | 2 +- marshaller/node.go | 2 +- marshaller/node_test.go | 2 +- marshaller/nodecollector.go | 2 +- marshaller/nodecollector_test.go | 2 +- marshaller/populator.go | 2 +- .../populator_unmarshalextensionmodel_test.go | 2 +- marshaller/sequencedmap.go | 2 +- marshaller/sequencedmap_test.go | 2 +- marshaller/syncer.go | 2 +- marshaller/syncing_test.go | 2 +- marshaller/tests/core/models.go | 2 +- marshaller/tests/models.go | 2 +- marshaller/unmarshaller.go | 16 +++++---- marshaller/unmarshalling_test.go | 12 +++---- openapi/bootstrap_test.go | 2 +- openapi/core/callbacks.go | 2 +- openapi/core/callbacks_test.go | 2 +- openapi/core/paths.go | 2 +- openapi/core/paths_test.go | 2 +- openapi/core/reference.go | 2 +- openapi/core/reference_test.go | 2 +- openapi/core/responses.go | 2 +- openapi/core/responses_test.go | 2 +- openapi/core/security.go | 2 +- openapi/core/security_test.go | 2 +- openapi/index.go | 2 +- openapi/index_node_operation_test.go | 2 +- openapi/linter/converter/generate.go | 2 +- openapi/linter/converter/generate_test.go | 2 +- openapi/linter/converter/parse.go | 2 +- openapi/linter/converter/tests/go.mod | 1 + openapi/linter/converter/tests/go.sum | 2 ++ openapi/linter/customrules/go.mod | 3 +- openapi/linter/customrules/go.sum | 2 ++ openapi/linter/customrules/runtime.go | 2 +- openapi/linter/linter_test.go | 2 +- .../linter/rules/description_duplication.go | 2 +- .../linter/rules/duplicated_entry_in_enum.go | 2 +- openapi/linter/rules/fix_helpers.go | 2 +- openapi/linter/rules/fix_helpers_test.go | 2 +- openapi/linter/rules/fix_integration_test.go | 2 +- openapi/linter/rules/host_trailing_slash.go | 2 +- openapi/linter/rules/markdown_descriptions.go | 2 +- openapi/linter/rules/oas3_no_nullable.go | 2 +- openapi/linter/rules/oas_schema_check.go | 2 +- .../rules/operation_success_response.go | 2 +- .../linter/rules/owasp_jwt_best_practices.go | 2 +- .../rules/owasp_no_additional_properties.go | 2 +- .../rules/owasp_security_hosts_https_oas3.go | 2 +- openapi/linter/rules/path_trailing_slash.go | 2 +- openapi/linter/rules/rule_fixes_test.go | 2 +- openapi/linter/rules/tags_alphabetical.go | 2 +- openapi/linter/rules/typed_enum.go | 2 +- openapi/linter/rules/unused_components.go | 2 +- openapi/localize.go | 2 +- openapi/openapi.go | 2 +- openapi/openapi_examples_test.go | 4 +-- openapi/reference.go | 2 +- openapi/sanitize.go | 2 +- openapi/upgrade.go | 2 +- openapi/upgrade_test.go | 2 +- overlay/apply.go | 2 +- overlay/apply_test.go | 14 ++++++-- overlay/compare.go | 2 +- overlay/compare_test.go | 2 +- overlay/format_test.go | 2 +- overlay/jsonpath.go | 36 ++++++++++++++++--- overlay/loader/spec.go | 2 +- overlay/loader/spec_test.go | 2 +- overlay/overlay_examples_test.go | 2 +- overlay/parents.go | 2 +- overlay/parse.go | 2 +- overlay/schema.go | 2 +- overlay/upgrade_test.go | 2 +- overlay/utils.go | 2 +- overlay/utils_test.go | 2 +- overlay/validate_test.go | 2 +- references/resolution.go | 2 +- references/resolution_test.go | 2 +- sequencedmap/map.go | 2 +- sequencedmap/map_advanced_test.go | 2 +- sequencedmap/yaml_unmarshal_test.go | 2 +- swagger/core/paths.go | 2 +- swagger/core/paths_test.go | 2 +- swagger/core/reference.go | 2 +- swagger/core/reference_test.go | 2 +- swagger/core/response.go | 2 +- swagger/core/response_test.go | 2 +- swagger/roundtrip_test.go | 2 +- validation/errors.go | 2 +- validation/fix.go | 2 +- validation/utils_test.go | 2 +- validation/validation_test.go | 2 +- values/core/eithervalue.go | 2 +- values/core/eithervalue_test.go | 2 +- values/core/value.go | 2 +- values/value.go | 2 +- yml/config.go | 2 +- yml/config_test.go | 2 +- yml/nodekind.go | 2 +- yml/nodekind_test.go | 2 +- yml/walk.go | 2 +- yml/walk_test.go | 2 +- yml/yml.go | 2 +- yml/yml_test.go | 2 +- 174 files changed, 252 insertions(+), 189 deletions(-) diff --git a/arazzo/arazzo_order_test.go b/arazzo/arazzo_order_test.go index fcebe7d6..35c93e29 100644 --- a/arazzo/arazzo_order_test.go +++ b/arazzo/arazzo_order_test.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/expression" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestArazzo_ArrayOrdering_ReorderWorkflows_Success(t *testing.T) { diff --git a/arazzo/arazzo_test.go b/arazzo/arazzo_test.go index 506c27fe..947d0ffb 100644 --- a/arazzo/arazzo_test.go +++ b/arazzo/arazzo_test.go @@ -25,7 +25,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // TODO make it possible to choose json or yaml output diff --git a/arazzo/core/criterion.go b/arazzo/core/criterion.go index 50b3c9ef..3aaa637d 100644 --- a/arazzo/core/criterion.go +++ b/arazzo/core/criterion.go @@ -11,7 +11,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type CriterionExpressionType struct { diff --git a/arazzo/core/criterion_syncchanges_test.go b/arazzo/core/criterion_syncchanges_test.go index 7c02ef96..df9c00c5 100644 --- a/arazzo/core/criterion_syncchanges_test.go +++ b/arazzo/core/criterion_syncchanges_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/pointer" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestCriterionTypeUnion_SyncChanges_WithStringType_Success(t *testing.T) { diff --git a/arazzo/core/criterion_test.go b/arazzo/core/criterion_test.go index fb35a1d5..a8b8a5b8 100644 --- a/arazzo/core/criterion_test.go +++ b/arazzo/core/criterion_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/pointer" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func createCriterionWithRootNode(c Criterion, rootNode *yaml.Node) Criterion { diff --git a/arazzo/core/reusable.go b/arazzo/core/reusable.go index c9022a16..25ddaaf2 100644 --- a/arazzo/core/reusable.go +++ b/arazzo/core/reusable.go @@ -11,7 +11,7 @@ import ( "github.com/speakeasy-api/openapi/validation" values "github.com/speakeasy-api/openapi/values/core" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Reusable[T marshaller.CoreModeler] struct { diff --git a/arazzo/core/reusable_test.go b/arazzo/core/reusable_test.go index 96aeea43..bcd01022 100644 --- a/arazzo/core/reusable_test.go +++ b/arazzo/core/reusable_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestReusable_Unmarshal_WithReference_Success(t *testing.T) { diff --git a/arazzo/criterion/condition.go b/arazzo/criterion/condition.go index 1289a91c..9e11c0f9 100644 --- a/arazzo/criterion/condition.go +++ b/arazzo/criterion/condition.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/expression" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Operator represents the operator used to compare the value of a criterion. diff --git a/arazzo/requestbody_test.go b/arazzo/requestbody_test.go index 8f8cbe7b..01b3609e 100644 --- a/arazzo/requestbody_test.go +++ b/arazzo/requestbody_test.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/pointer" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestRequestBody_Validate_JSONPathInPayload_Success(t *testing.T) { diff --git a/arazzo/reusable.go b/arazzo/reusable.go index d7a2c0a0..d18f0c43 100644 --- a/arazzo/reusable.go +++ b/arazzo/reusable.go @@ -15,7 +15,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/values" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type ( diff --git a/arazzo/successaction.go b/arazzo/successaction.go index 8fc3e5e0..79f8dc69 100644 --- a/arazzo/successaction.go +++ b/arazzo/successaction.go @@ -15,7 +15,7 @@ import ( "github.com/speakeasy-api/openapi/pointer" "github.com/speakeasy-api/openapi/validation" walkpkg "github.com/speakeasy-api/openapi/walk" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // SuccessActionType represents the type of action to take on success. diff --git a/cmd/openapi/commands/openapi/bootstrap.go b/cmd/openapi/commands/openapi/bootstrap.go index 6ab6313a..23a443fa 100644 --- a/cmd/openapi/commands/openapi/bootstrap.go +++ b/cmd/openapi/commands/openapi/bootstrap.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/yml" "github.com/spf13/cobra" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) var bootstrapCmd = &cobra.Command{ diff --git a/cmd/openapi/commands/overlay/apply.go b/cmd/openapi/commands/overlay/apply.go index 342c7167..4f2da0a4 100644 --- a/cmd/openapi/commands/overlay/apply.go +++ b/cmd/openapi/commands/overlay/apply.go @@ -8,7 +8,7 @@ import ( overlayPkg "github.com/speakeasy-api/openapi/overlay" "github.com/speakeasy-api/openapi/overlay/loader" "github.com/spf13/cobra" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) var ( diff --git a/cmd/openapi/commands/overlay/compare.go b/cmd/openapi/commands/overlay/compare.go index 630bc5c4..4983c172 100644 --- a/cmd/openapi/commands/overlay/compare.go +++ b/cmd/openapi/commands/overlay/compare.go @@ -8,7 +8,7 @@ import ( overlayPkg "github.com/speakeasy-api/openapi/overlay" "github.com/speakeasy-api/openapi/overlay/loader" "github.com/spf13/cobra" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) var ( diff --git a/cmd/openapi/go.mod b/cmd/openapi/go.mod index 3c0f3a22..70fad77c 100644 --- a/cmd/openapi/go.mod +++ b/cmd/openapi/go.mod @@ -10,7 +10,7 @@ require ( github.com/speakeasy-api/openapi/openapi/linter/customrules v0.0.0-20260217225223-7d484a30828f github.com/spf13/cobra v1.10.1 github.com/stretchr/testify v1.11.1 - gopkg.in/yaml.v3 v3.0.1 + go.yaml.in/yaml/v4 v4.0.0-rc.4 ) require ( @@ -46,4 +46,5 @@ require ( golang.org/x/sync v0.19.0 // indirect golang.org/x/sys v0.36.0 // indirect golang.org/x/text v0.34.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/cmd/openapi/go.sum b/cmd/openapi/go.sum index 0cc1083f..6a42fe89 100644 --- a/cmd/openapi/go.sum +++ b/cmd/openapi/go.sum @@ -101,6 +101,8 @@ github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9N github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= +go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U= +go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E= golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/expression/core/value.go b/expression/core/value.go index 69effc25..ca299c4b 100644 --- a/expression/core/value.go +++ b/expression/core/value.go @@ -1,5 +1,5 @@ package core -import "gopkg.in/yaml.v3" +import "go.yaml.in/yaml/v4" type ValueOrExpression = *yaml.Node diff --git a/expression/value.go b/expression/value.go index b549b637..ba2fc166 100644 --- a/expression/value.go +++ b/expression/value.go @@ -1,7 +1,7 @@ package expression import ( - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // ValueOrExpression represents a raw value or expression in the Arazzo document. diff --git a/expression/value_test.go b/expression/value_test.go index bf125345..d314987a 100644 --- a/expression/value_test.go +++ b/expression/value_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/expression" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestGetValueOrExpressionValue_Success(t *testing.T) { diff --git a/extensions/core/extensions.go b/extensions/core/extensions.go index 333c4348..64f01a75 100644 --- a/extensions/core/extensions.go +++ b/extensions/core/extensions.go @@ -5,7 +5,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type ( diff --git a/extensions/core/extensions_test.go b/extensions/core/extensions_test.go index f2156518..49e2a397 100644 --- a/extensions/core/extensions_test.go +++ b/extensions/core/extensions_test.go @@ -11,7 +11,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type TestCoreModel struct { diff --git a/extensions/extensions.go b/extensions/extensions.go index c527701c..d4755f88 100644 --- a/extensions/extensions.go +++ b/extensions/extensions.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const ( diff --git a/extensions/extensions_isequal_test.go b/extensions/extensions_isequal_test.go index a8852dda..c8b55631 100644 --- a/extensions/extensions_isequal_test.go +++ b/extensions/extensions_isequal_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestExtensions_IsEqual_Success(t *testing.T) { diff --git a/extensions/extensions_test.go b/extensions/extensions_test.go index 88c1e0ec..5df066f6 100644 --- a/extensions/extensions_test.go +++ b/extensions/extensions_test.go @@ -13,7 +13,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type ModelWithExtensions struct { diff --git a/go.mod b/go.mod index 61cd5d1d..d2e531f6 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/speakeasy-api/jsonpath v0.6.3 github.com/stretchr/testify v1.11.1 github.com/vmware-labs/yaml-jsonpath v0.3.2 + go.yaml.in/yaml/v4 v4.0.0-rc.4 golang.org/x/sync v0.19.0 golang.org/x/text v0.34.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index f80f1b31..4141719f 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk= github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ= +go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U= +go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= diff --git a/hashing/hashing.go b/hashing/hashing.go index ae017929..d1e2f74e 100644 --- a/hashing/hashing.go +++ b/hashing/hashing.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/speakeasy-api/openapi/internal/interfaces" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func Hash(v any) string { diff --git a/hashing/hashing_test.go b/hashing/hashing_test.go index e18bae7d..51daecda 100644 --- a/hashing/hashing_test.go +++ b/hashing/hashing_test.go @@ -14,7 +14,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type testEnum string diff --git a/internal/interfaces/interfaces.go b/internal/interfaces/interfaces.go index e7494d79..3a997599 100644 --- a/internal/interfaces/interfaces.go +++ b/internal/interfaces/interfaces.go @@ -6,7 +6,7 @@ import ( "reflect" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Validator[T any] interface { diff --git a/internal/interfaces/interfaces_test.go b/internal/interfaces/interfaces_test.go index 0dc1a45a..98805ca3 100644 --- a/internal/interfaces/interfaces_test.go +++ b/internal/interfaces/interfaces_test.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Test implementations for Model interface diff --git a/internal/testutils/utils.go b/internal/testutils/utils.go index c4c40007..89579239 100644 --- a/internal/testutils/utils.go +++ b/internal/testutils/utils.go @@ -15,7 +15,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // TODO use these more in tests diff --git a/internal/testutils/utils_test.go b/internal/testutils/utils_test.go index e4f7ba06..6e3937da 100644 --- a/internal/testutils/utils_test.go +++ b/internal/testutils/utils_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestCreateStringYamlNode_Success(t *testing.T) { diff --git a/json/json.go b/json/json.go index 87f14e29..9c350c20 100644 --- a/json/json.go +++ b/json/json.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // YAMLToJSON converts a YAML node to JSON using a custom JSON writer that preserves formatting. diff --git a/json/json_test.go b/json/json_test.go index ab2f868a..428ee432 100644 --- a/json/json_test.go +++ b/json/json_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/json" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestYAMLToJSON_Success(t *testing.T) { diff --git a/jsonpointer/jsonpointer.go b/jsonpointer/jsonpointer.go index 042ee0bb..545a8ba8 100644 --- a/jsonpointer/jsonpointer.go +++ b/jsonpointer/jsonpointer.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/errors" "github.com/speakeasy-api/openapi/internal/interfaces" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const ( diff --git a/jsonpointer/models_yaml_fallback_test.go b/jsonpointer/models_yaml_fallback_test.go index 5f175134..bbd0487d 100644 --- a/jsonpointer/models_yaml_fallback_test.go +++ b/jsonpointer/models_yaml_fallback_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // TestModel represents a simple model for testing YAML fallback @@ -39,7 +39,7 @@ knownField: "known value" unknownField: "unknown value" `, jsonPointer: "/unknownField", - expectedType: "*yaml.Node", + expectedType: "*libyaml.Node", expectedVal: "unknown value", }, { @@ -50,7 +50,7 @@ unknownObject: nestedField: "nested value" `, jsonPointer: "/unknownObject/nestedField", - expectedType: "*yaml.Node", + expectedType: "*libyaml.Node", expectedVal: "nested value", }, { @@ -62,7 +62,7 @@ unknownArray: - "item2" `, jsonPointer: "/unknownArray/1", - expectedType: "*yaml.Node", + expectedType: "*libyaml.Node", expectedVal: "item2", }, } diff --git a/jsonpointer/yamlnode.go b/jsonpointer/yamlnode.go index 541294fe..7a046398 100644 --- a/jsonpointer/yamlnode.go +++ b/jsonpointer/yamlnode.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func getYamlNodeTarget(node *yaml.Node, currentPart navigationPart, stack []navigationPart, currentPath string, o *options) (any, []navigationPart, error) { diff --git a/jsonpointer/yamlnode_test.go b/jsonpointer/yamlnode_test.go index b94cc502..82ade0ef 100644 --- a/jsonpointer/yamlnode_test.go +++ b/jsonpointer/yamlnode_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestGetTarget_YamlNode_Success(t *testing.T) { diff --git a/jsonschema/oas3/core/jsonschema_test.go b/jsonschema/oas3/core/jsonschema_test.go index 297fe11f..ac5f3df5 100644 --- a/jsonschema/oas3/core/jsonschema_test.go +++ b/jsonschema/oas3/core/jsonschema_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestJSONSchema_Unmarshal_BooleanValue_Success(t *testing.T) { diff --git a/jsonschema/oas3/core/xml_test.go b/jsonschema/oas3/core/xml_test.go index 493a8b86..539de437 100644 --- a/jsonschema/oas3/core/xml_test.go +++ b/jsonschema/oas3/core/xml_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func parseYAML(t *testing.T, yml string) *yaml.Node { diff --git a/jsonschema/oas3/jsonschema_validate_test.go b/jsonschema/oas3/jsonschema_validate_test.go index 29c5f230..2086c78a 100644 --- a/jsonschema/oas3/jsonschema_validate_test.go +++ b/jsonschema/oas3/jsonschema_validate_test.go @@ -227,7 +227,7 @@ func TestJSONSchema_Validate_Error(t *testing.T) { name: "schema fails direct validation", yml: ` "test"`, - wantErrs: []string{"[2:1] error validation-type-mismatch failed to validate either Schema [expected `object`, got `te...`] or bool [line 2: cannot unmarshal !!str `test` into bool]"}, + wantErrs: []string{"[2:1] error validation-type-mismatch failed to validate either Schema [expected `object`, got `te...`] or bool [line 2: cannot construct !!str `test` into bool]"}, }, { name: "child schema fails validation", diff --git a/jsonschema/oas3/resolution.go b/jsonschema/oas3/resolution.go index 16bff2ab..05b63480 100644 --- a/jsonschema/oas3/resolution.go +++ b/jsonschema/oas3/resolution.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/internal/utils" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/references" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // ResolveOptions represent the options available when resolving a JSON Schema reference. diff --git a/jsonschema/oas3/resolution_defs.go b/jsonschema/oas3/resolution_defs.go index 97b09daf..621acf7a 100644 --- a/jsonschema/oas3/resolution_defs.go +++ b/jsonschema/oas3/resolution_defs.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/internal/utils" "github.com/speakeasy-api/openapi/jsonpointer" "github.com/speakeasy-api/openapi/references" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // GetRootNoder is an interface for objects that can return a YAML root node. diff --git a/jsonschema/oas3/resolution_defs_test.go b/jsonschema/oas3/resolution_defs_test.go index e6ff438a..4faf8e06 100644 --- a/jsonschema/oas3/resolution_defs_test.go +++ b/jsonschema/oas3/resolution_defs_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/references" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestTryResolveLocalDefs_NilAndBooleanSchema(t *testing.T) { diff --git a/jsonschema/oas3/resolution_external.go b/jsonschema/oas3/resolution_external.go index a97d1896..1fa65d9d 100644 --- a/jsonschema/oas3/resolution_external.go +++ b/jsonschema/oas3/resolution_external.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/jsonpointer" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/references" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // resolveExternalAnchorReference handles resolution of anchor references (e.g., "file.json#anchor") diff --git a/jsonschema/oas3/resolution_external_test.go b/jsonschema/oas3/resolution_external_test.go index ead1e742..9172ce3b 100644 --- a/jsonschema/oas3/resolution_external_test.go +++ b/jsonschema/oas3/resolution_external_test.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestResolveExternalAnchorReference_Success(t *testing.T) { diff --git a/jsonschema/oas3/resolution_test.go b/jsonschema/oas3/resolution_test.go index 5100bb26..a508e645 100644 --- a/jsonschema/oas3/resolution_test.go +++ b/jsonschema/oas3/resolution_test.go @@ -18,7 +18,7 @@ import ( "github.com/speakeasy-api/openapi/references" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // MockResolutionTarget implements references.ResolutionTarget for testing diff --git a/jsonschema/oas3/schema_exclusive_validation_test.go b/jsonschema/oas3/schema_exclusive_validation_test.go index dd5a98e6..6cddc9e6 100644 --- a/jsonschema/oas3/schema_exclusive_validation_test.go +++ b/jsonschema/oas3/schema_exclusive_validation_test.go @@ -248,7 +248,7 @@ exclusiveMaximum: false type: number exclusiveMinimum: "invalid" `, - wantErrs: []string{"[2:1] error validation-type-mismatch schema.exclusiveMinimum expected `number`, got `string`", "[3:19] error validation-type-mismatch schema.exclusiveMinimum failed to validate either bool [schema.exclusiveMinimum line 3: cannot unmarshal !!str `invalid` into bool] or float64 [schema.exclusiveMinimum line 3: cannot unmarshal !!str `invalid` into float64]"}, + wantErrs: []string{"[2:1] error validation-type-mismatch schema.exclusiveMinimum expected `number`, got `string`", "[3:19] error validation-type-mismatch schema.exclusiveMinimum failed to validate either bool [schema.exclusiveMinimum line 3: cannot construct !!str `invalid` into bool] or float64 [schema.exclusiveMinimum line 3: cannot construct !!str `invalid` into float64]"}, }, { name: "invalid string type for exclusiveMaximum", @@ -256,7 +256,7 @@ exclusiveMinimum: "invalid" type: number exclusiveMaximum: "invalid" `, - wantErrs: []string{"[2:1] error validation-type-mismatch schema.exclusiveMaximum expected `number`, got `string`", "[3:19] error validation-type-mismatch schema.exclusiveMaximum failed to validate either bool [schema.exclusiveMaximum line 3: cannot unmarshal !!str `invalid` into bool] or float64 [schema.exclusiveMaximum line 3: cannot unmarshal !!str `invalid` into float64]"}, + wantErrs: []string{"[2:1] error validation-type-mismatch schema.exclusiveMaximum expected `number`, got `string`", "[3:19] error validation-type-mismatch schema.exclusiveMaximum failed to validate either bool [schema.exclusiveMaximum line 3: cannot construct !!str `invalid` into bool] or float64 [schema.exclusiveMaximum line 3: cannot construct !!str `invalid` into float64]"}, }, { name: "invalid array type for exclusiveMinimum", diff --git a/jsonschema/oas3/schema_getters_test.go b/jsonschema/oas3/schema_getters_test.go index d7af313e..7000aeba 100644 --- a/jsonschema/oas3/schema_getters_test.go +++ b/jsonschema/oas3/schema_getters_test.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/speakeasy-api/openapi/values" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestSchema_GetExclusiveMaximum_Success(t *testing.T) { diff --git a/jsonschema/oas3/schema_isequal_test.go b/jsonschema/oas3/schema_isequal_test.go index 5966a8cc..774b4666 100644 --- a/jsonschema/oas3/schema_isequal_test.go +++ b/jsonschema/oas3/schema_isequal_test.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/speakeasy-api/openapi/values" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestSchema_IsEqual_Success(t *testing.T) { diff --git a/jsonschema/oas3/schema_validate_test.go b/jsonschema/oas3/schema_validate_test.go index 8dafa271..8f4385f8 100644 --- a/jsonschema/oas3/schema_validate_test.go +++ b/jsonschema/oas3/schema_validate_test.go @@ -427,7 +427,7 @@ additionalProperties: "invalid" wantErrs: []string{ "[2:1] error validation-type-mismatch schema.additionalProperties expected one of [`boolean`, `object`], got `string`", "[2:1] error validation-type-mismatch schema.additionalProperties expected one of [`boolean`, `object`], got `string`", - "[3:23] error validation-type-mismatch schema.additionalProperties failed to validate either Schema [schema.additionalProperties expected `object`, got `invalid`] or bool [schema.additionalProperties line 3: cannot unmarshal !!str `invalid` into bool]", + "[3:23] error validation-type-mismatch schema.additionalProperties failed to validate either Schema [schema.additionalProperties expected `object`, got `invalid`] or bool [schema.additionalProperties line 3: cannot construct !!str `invalid` into bool]", }, }, { @@ -455,7 +455,7 @@ items: "invalid" wantErrs: []string{ "[2:1] error validation-type-mismatch schema.items expected one of [`boolean`, `object`], got `string`", "[2:1] error validation-type-mismatch schema.items expected one of [`boolean`, `object`], got `string`", - "[3:8] error validation-type-mismatch schema.items failed to validate either Schema [schema.items expected `object`, got `invalid`] or bool [schema.items line 3: cannot unmarshal !!str `invalid` into bool]", + "[3:8] error validation-type-mismatch schema.items failed to validate either Schema [schema.items expected `object`, got `invalid`] or bool [schema.items line 3: cannot construct !!str `invalid` into bool]", }, }, { diff --git a/jsonschema/oas3/tests/go.mod b/jsonschema/oas3/tests/go.mod index 5dafdfdc..aac6da03 100644 --- a/jsonschema/oas3/tests/go.mod +++ b/jsonschema/oas3/tests/go.mod @@ -60,6 +60,7 @@ require ( go.opentelemetry.io/otel/sdk v1.37.0 // indirect go.opentelemetry.io/otel/trace v1.37.0 // indirect go.opentelemetry.io/proto/otlp v1.7.1 // indirect + go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect golang.org/x/crypto v0.45.0 // indirect golang.org/x/sync v0.19.0 // indirect golang.org/x/sys v0.38.0 // indirect diff --git a/jsonschema/oas3/tests/go.sum b/jsonschema/oas3/tests/go.sum index 468ef644..38fcf19e 100644 --- a/jsonschema/oas3/tests/go.sum +++ b/jsonschema/oas3/tests/go.sum @@ -133,6 +133,8 @@ go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mx go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/otlp v1.7.1 h1:gTOMpGDb0WTBOP8JaO72iL3auEZhVmAQg4ipjOVAtj4= go.opentelemetry.io/proto/otlp v1.7.1/go.mod h1:b2rVh6rfI/s2pHWNlB7ILJcRALpcNDzKhACevjI+ZnE= +go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U= +go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= diff --git a/jsonschema/oas3/validation.go b/jsonschema/oas3/validation.go index 07716155..e873b101 100644 --- a/jsonschema/oas3/validation.go +++ b/jsonschema/oas3/validation.go @@ -17,9 +17,9 @@ import ( "github.com/speakeasy-api/openapi/jsonschema/oas3/core" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/validation" + "go.yaml.in/yaml/v4" "golang.org/x/text/language" "golang.org/x/text/message" - "gopkg.in/yaml.v3" ) // custom file to cover for missing openapi 3.0 json schema diff --git a/linter/config.go b/linter/config.go index 97d199e7..c1995efd 100644 --- a/linter/config.go +++ b/linter/config.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/references" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Config represents the linter configuration diff --git a/linter/config_loader.go b/linter/config_loader.go index 0400cdf1..542316d1 100644 --- a/linter/config_loader.go +++ b/linter/config_loader.go @@ -5,7 +5,7 @@ import ( "io" "os" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // LoadConfig loads lint configuration from a YAML reader. diff --git a/linter/fix/engine.go b/linter/fix/engine.go index 7431f70e..bc36e63a 100644 --- a/linter/fix/engine.go +++ b/linter/fix/engine.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Mode controls how fixes are applied. diff --git a/linter/fix/engine_test.go b/linter/fix/engine_test.go index 32f23f80..37b5e447 100644 --- a/linter/fix/engine_test.go +++ b/linter/fix/engine_test.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // mockFix is a non-interactive fix for testing. diff --git a/linter/fix/terminal_prompter_test.go b/linter/fix/terminal_prompter_test.go index c56e36ef..507b3dd9 100644 --- a/linter/fix/terminal_prompter_test.go +++ b/linter/fix/terminal_prompter_test.go @@ -11,7 +11,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestTerminalPrompter_Choice_Success(t *testing.T) { diff --git a/linter/format/format_test.go b/linter/format/format_test.go index ed42e411..cfaaa9f6 100644 --- a/linter/format/format_test.go +++ b/linter/format/format_test.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // testFix is a minimal validation.Fix for testing formatter output. diff --git a/marshaller/coremodel.go b/marshaller/coremodel.go index 75f80c9f..6825f01d 100644 --- a/marshaller/coremodel.go +++ b/marshaller/coremodel.go @@ -11,7 +11,7 @@ import ( "github.com/speakeasy-api/openapi/json" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type CoreModeler interface { diff --git a/marshaller/coremodel_getters_test.go b/marshaller/coremodel_getters_test.go index db1c035b..34df784d 100644 --- a/marshaller/coremodel_getters_test.go +++ b/marshaller/coremodel_getters_test.go @@ -5,7 +5,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestCoreModel_GetRootNodeLine_Success(t *testing.T) { diff --git a/marshaller/coremodel_jsonpath_test.go b/marshaller/coremodel_jsonpath_test.go index 5e4903ea..26a30f61 100644 --- a/marshaller/coremodel_jsonpath_test.go +++ b/marshaller/coremodel_jsonpath_test.go @@ -2,14 +2,22 @@ package marshaller_test import ( "testing" + "unsafe" "github.com/speakeasy-api/jsonpath/pkg/jsonpath" "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" + yamlv3 "gopkg.in/yaml.v3" ) +// queryV4 runs a jsonpath query using a v4 node by casting to v3 and back. +func queryV4(path *jsonpath.JSONPath, node *yaml.Node) []*yaml.Node { + v3result := path.Query((*yamlv3.Node)(unsafe.Pointer(node))) + return *(*[]*yaml.Node)(unsafe.Pointer(&v3result)) +} + func TestCoreModel_GetJSONPath_Success(t *testing.T) { t.Parallel() @@ -178,7 +186,7 @@ func findNodeByJSONPath(t *testing.T, rootNode *yaml.Node, jsonPath string) *yam require.NoError(t, err, "JSONPath should be valid: %s", jsonPath) // Query the YAML node directly - result := path.Query(rootNode) + result := queryV4(path, rootNode) require.NotEmpty(t, result, "JSONPath query should return results: %s", jsonPath) // The result should be a slice of *yaml.Node, so return the first one @@ -196,7 +204,7 @@ func verifyJSONPathWorks(t *testing.T, rootNode *yaml.Node, jsonPath string, exp path, err := jsonpath.NewPath(jsonPath) require.NoError(t, err, "generated JSONPath should be valid: %s", jsonPath) - result := path.Query(rootNode) + result := queryV4(path, rootNode) require.NotEmpty(t, result, "JSONPath query should return results: %s", jsonPath) // Special case for root node: the query might return the document node diff --git a/marshaller/coremodel_jsonpointer_test.go b/marshaller/coremodel_jsonpointer_test.go index f4d34bfa..6ec9f306 100644 --- a/marshaller/coremodel_jsonpointer_test.go +++ b/marshaller/coremodel_jsonpointer_test.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestCoreModel_GetJSONPointer_Success(t *testing.T) { diff --git a/marshaller/extensions.go b/marshaller/extensions.go index 4f62ed60..b35e87fd 100644 --- a/marshaller/extensions.go +++ b/marshaller/extensions.go @@ -9,7 +9,7 @@ import ( "unsafe" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Extension = *yaml.Node diff --git a/marshaller/factory.go b/marshaller/factory.go index d9713980..453a58c1 100644 --- a/marshaller/factory.go +++ b/marshaller/factory.go @@ -7,7 +7,7 @@ import ( "sync" "github.com/speakeasy-api/openapi/sequencedmap" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // TypeFactory represents a function that creates a new instance of a specific type diff --git a/marshaller/marshal.go b/marshaller/marshal.go index 8924231a..809755a3 100644 --- a/marshaller/marshal.go +++ b/marshaller/marshal.go @@ -6,7 +6,7 @@ import ( "io" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Marshallable represents a high-level model that can be marshaled diff --git a/marshaller/model.go b/marshaller/model.go index ec7feae7..2657e224 100644 --- a/marshaller/model.go +++ b/marshaller/model.go @@ -4,7 +4,7 @@ import ( "reflect" "sync" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // CoreAccessor provides type-safe access to the core field in models diff --git a/marshaller/model_test.go b/marshaller/model_test.go index 1e1822c1..838cea8f 100644 --- a/marshaller/model_test.go +++ b/marshaller/model_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/marshaller/tests/core" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // TestModel_GetPropertyNode_Success tests the GetPropertyNode method with valid inputs diff --git a/marshaller/node.go b/marshaller/node.go index f6190795..068a1d6b 100644 --- a/marshaller/node.go +++ b/marshaller/node.go @@ -5,7 +5,7 @@ import ( "reflect" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type NodeMutator interface { diff --git a/marshaller/node_test.go b/marshaller/node_test.go index d0085b03..e49f8aa3 100644 --- a/marshaller/node_test.go +++ b/marshaller/node_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type testCase[T any] struct { diff --git a/marshaller/nodecollector.go b/marshaller/nodecollector.go index 39d1b5e2..41bfb102 100644 --- a/marshaller/nodecollector.go +++ b/marshaller/nodecollector.go @@ -3,7 +3,7 @@ package marshaller import ( "reflect" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // NodeCollector provides utilities for collecting yaml.Node pointers from core models. diff --git a/marshaller/nodecollector_test.go b/marshaller/nodecollector_test.go index edc24445..2ea98c39 100644 --- a/marshaller/nodecollector_test.go +++ b/marshaller/nodecollector_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Test models to verify CollectLeafNodes behavior diff --git a/marshaller/populator.go b/marshaller/populator.go index d5b75eb5..de51c8da 100644 --- a/marshaller/populator.go +++ b/marshaller/populator.go @@ -5,7 +5,7 @@ import ( "reflect" "github.com/speakeasy-api/openapi/internal/interfaces" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Pre-computed reflection types for performance diff --git a/marshaller/populator_unmarshalextensionmodel_test.go b/marshaller/populator_unmarshalextensionmodel_test.go index 6f3e422b..f360ae97 100644 --- a/marshaller/populator_unmarshalextensionmodel_test.go +++ b/marshaller/populator_unmarshalextensionmodel_test.go @@ -11,7 +11,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func init() { diff --git a/marshaller/sequencedmap.go b/marshaller/sequencedmap.go index 0679cff6..b0ccd451 100644 --- a/marshaller/sequencedmap.go +++ b/marshaller/sequencedmap.go @@ -12,8 +12,8 @@ import ( "github.com/speakeasy-api/openapi/internal/utils" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" + "go.yaml.in/yaml/v4" "golang.org/x/sync/errgroup" - "gopkg.in/yaml.v3" ) // MapGetter interface for syncing operations diff --git a/marshaller/sequencedmap_test.go b/marshaller/sequencedmap_test.go index e4aa0767..3ea62c33 100644 --- a/marshaller/sequencedmap_test.go +++ b/marshaller/sequencedmap_test.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // SequencedMap test case for successful operations diff --git a/marshaller/syncer.go b/marshaller/syncer.go index ea529340..3614442b 100644 --- a/marshaller/syncer.go +++ b/marshaller/syncer.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/internal/interfaces" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Syncer interface { diff --git a/marshaller/syncing_test.go b/marshaller/syncing_test.go index 3ea0d242..ae0fd69d 100644 --- a/marshaller/syncing_test.go +++ b/marshaller/syncing_test.go @@ -12,7 +12,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/speakeasy-api/openapi/values" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestSync_PrimitiveTypes_Success(t *testing.T) { diff --git a/marshaller/tests/core/models.go b/marshaller/tests/core/models.go index a624300e..12e47d80 100644 --- a/marshaller/tests/core/models.go +++ b/marshaller/tests/core/models.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" valuescore "github.com/speakeasy-api/openapi/values/core" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // TestPrimitiveModel covers all primitive marshaller.Node field types diff --git a/marshaller/tests/models.go b/marshaller/tests/models.go index 4c699211..641a96e6 100644 --- a/marshaller/tests/models.go +++ b/marshaller/tests/models.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/speakeasy-api/openapi/values" valuescore "github.com/speakeasy-api/openapi/values/core" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // High-level model counterparts for population testing using marshaller.Model diff --git a/marshaller/unmarshaller.go b/marshaller/unmarshaller.go index 42c6faeb..569992b2 100644 --- a/marshaller/unmarshaller.go +++ b/marshaller/unmarshaller.go @@ -12,8 +12,8 @@ import ( "github.com/speakeasy-api/openapi/internal/interfaces" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" + "go.yaml.in/yaml/v4" "golang.org/x/sync/errgroup" - "gopkg.in/yaml.v3" ) // Pre-computed reflection types for performance (reusing from populator.go where possible) @@ -545,8 +545,12 @@ func decodeNode(_ context.Context, parentName string, node *yaml.Node, out any) // Check if this is a type mismatch error if yamlTypeErr := asTypeMismatchError(err); yamlTypeErr != nil { // Convert type mismatch to validation error - validationErr := validation.NewValidationError(validation.SeverityError, validation.RuleValidationTypeMismatch, validation.NewTypeMismatchError(parentName, strings.Join(yamlTypeErr.Errors, ", ")), resolvedNode) - return []error{validationErr}, nil //nolint:nilerr + errStrings := make([]string, len(yamlTypeErr.Errors)) + for i, e := range yamlTypeErr.Errors { + errStrings[i] = e.Error() + } + validationErr := validation.NewValidationError(validation.SeverityError, validation.RuleValidationTypeMismatch, validation.NewTypeMismatchError(parentName, strings.Join(errStrings, ", ")), resolvedNode) + return []error{validationErr}, nil } // For all other errors (syntax, etc.), return as standard error @@ -749,9 +753,9 @@ func validateNodeKind(resolvedNode *yaml.Node, expectedKind yaml.Kind, parentNam return nil } -// asTypeMismatchError returns the underlying yaml.TypeError if the error is a type mismatch error -func asTypeMismatchError(err error) *yaml.TypeError { - var yamlTypeErr *yaml.TypeError +// asTypeMismatchError returns the underlying yaml.LoadErrors if the error is a type mismatch error +func asTypeMismatchError(err error) *yaml.LoadErrors { + var yamlTypeErr *yaml.LoadErrors if errors.As(err, &yamlTypeErr) { return yamlTypeErr } diff --git a/marshaller/unmarshalling_test.go b/marshaller/unmarshalling_test.go index fc64e1f5..6bcb1012 100644 --- a/marshaller/unmarshalling_test.go +++ b/marshaller/unmarshalling_test.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestUnmarshal_PrimitiveTypes_Success(t *testing.T) { @@ -177,7 +177,7 @@ boolField: "not a bool" intField: 42 float64Field: 3.14 `, - wantErrs: []string{"[3:12] error validation-type-mismatch testPrimitiveModel.boolField line 3: cannot unmarshal !!str `not a bool` into bool"}, + wantErrs: []string{"[3:12] error validation-type-mismatch testPrimitiveModel.boolField line 3: cannot construct !!str `not a bool` into bool"}, }, { name: "type mismatch - int field gets string", @@ -187,7 +187,7 @@ boolField: true intField: "not an int" float64Field: 3.14 `, - wantErrs: []string{"[4:11] error validation-type-mismatch testPrimitiveModel.intField line 4: cannot unmarshal !!str `not an int` into int"}, + wantErrs: []string{"[4:11] error validation-type-mismatch testPrimitiveModel.intField line 4: cannot construct !!str `not an int` into int"}, }, { name: "type mismatch - float field gets string", @@ -197,7 +197,7 @@ boolField: true intField: 42 float64Field: "not a float" `, - wantErrs: []string{"[5:15] error validation-type-mismatch testPrimitiveModel.float64Field line 5: cannot unmarshal !!str `not a f...` into float64"}, + wantErrs: []string{"[5:15] error validation-type-mismatch testPrimitiveModel.float64Field line 5: cannot construct !!str `not a f...` into float64"}, }, { name: "multiple validation errors", @@ -208,8 +208,8 @@ intField: "not an int" wantErrs: []string{ "[2:1] error validation-required-field `testPrimitiveModel.float64Field` is required", "[2:1] error validation-required-field `testPrimitiveModel.stringField` is required", - "[2:12] error validation-type-mismatch testPrimitiveModel.boolField line 2: cannot unmarshal !!str `not a bool` into bool", - "[3:11] error validation-type-mismatch testPrimitiveModel.intField line 3: cannot unmarshal !!str `not an int` into int", + "[2:12] error validation-type-mismatch testPrimitiveModel.boolField line 2: cannot construct !!str `not a bool` into bool", + "[3:11] error validation-type-mismatch testPrimitiveModel.intField line 3: cannot construct !!str `not an int` into int", }, }, } diff --git a/openapi/bootstrap_test.go b/openapi/bootstrap_test.go index 8c1309f2..f732c2f0 100644 --- a/openapi/bootstrap_test.go +++ b/openapi/bootstrap_test.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestBootstrap_Success(t *testing.T) { diff --git a/openapi/core/callbacks.go b/openapi/core/callbacks.go index 38c8df6c..62ce8a3a 100644 --- a/openapi/core/callbacks.go +++ b/openapi/core/callbacks.go @@ -4,7 +4,7 @@ import ( "github.com/speakeasy-api/openapi/extensions/core" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Callback struct { diff --git a/openapi/core/callbacks_test.go b/openapi/core/callbacks_test.go index 0a3795a5..8614f41e 100644 --- a/openapi/core/callbacks_test.go +++ b/openapi/core/callbacks_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestNewCallback_Success(t *testing.T) { diff --git a/openapi/core/paths.go b/openapi/core/paths.go index 2a31581c..8a967cdc 100644 --- a/openapi/core/paths.go +++ b/openapi/core/paths.go @@ -4,7 +4,7 @@ import ( "github.com/speakeasy-api/openapi/extensions/core" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Paths struct { diff --git a/openapi/core/paths_test.go b/openapi/core/paths_test.go index fca396be..c092bd6a 100644 --- a/openapi/core/paths_test.go +++ b/openapi/core/paths_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestNewPaths_Success(t *testing.T) { diff --git a/openapi/core/reference.go b/openapi/core/reference.go index ee5d2882..c60d3027 100644 --- a/openapi/core/reference.go +++ b/openapi/core/reference.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Reference[T marshaller.CoreModeler] struct { diff --git a/openapi/core/reference_test.go b/openapi/core/reference_test.go index 99db6947..483a57d8 100644 --- a/openapi/core/reference_test.go +++ b/openapi/core/reference_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/pointer" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestReference_Unmarshal_Success(t *testing.T) { diff --git a/openapi/core/responses.go b/openapi/core/responses.go index e9e9e423..fe707a33 100644 --- a/openapi/core/responses.go +++ b/openapi/core/responses.go @@ -4,7 +4,7 @@ import ( "github.com/speakeasy-api/openapi/extensions/core" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Responses struct { diff --git a/openapi/core/responses_test.go b/openapi/core/responses_test.go index 292753be..a535e43a 100644 --- a/openapi/core/responses_test.go +++ b/openapi/core/responses_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestNewResponses_Success(t *testing.T) { diff --git a/openapi/core/security.go b/openapi/core/security.go index ec204904..263f600e 100644 --- a/openapi/core/security.go +++ b/openapi/core/security.go @@ -4,7 +4,7 @@ import ( "github.com/speakeasy-api/openapi/extensions/core" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type SecurityScheme struct { diff --git a/openapi/core/security_test.go b/openapi/core/security_test.go index 6e962931..73d0d5ac 100644 --- a/openapi/core/security_test.go +++ b/openapi/core/security_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestNewSecurityRequirement_Success(t *testing.T) { diff --git a/openapi/index.go b/openapi/index.go index f9618e28..0fac18be 100644 --- a/openapi/index.go +++ b/openapi/index.go @@ -13,7 +13,7 @@ import ( "github.com/speakeasy-api/openapi/pointer" "github.com/speakeasy-api/openapi/references" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // CircularClassification represents the classification of a circular reference. diff --git a/openapi/index_node_operation_test.go b/openapi/index_node_operation_test.go index 475a0c6d..e72667a4 100644 --- a/openapi/index_node_operation_test.go +++ b/openapi/index_node_operation_test.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/references" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestBuildIndex_NodeToOperations_WithOption_Success(t *testing.T) { diff --git a/openapi/linter/converter/generate.go b/openapi/linter/converter/generate.go index c8852bf9..eed4e2bc 100644 --- a/openapi/linter/converter/generate.go +++ b/openapi/linter/converter/generate.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/linter" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // GenerateOptions configures the output generation. diff --git a/openapi/linter/converter/generate_test.go b/openapi/linter/converter/generate_test.go index cbbb9670..1a025bad 100644 --- a/openapi/linter/converter/generate_test.go +++ b/openapi/linter/converter/generate_test.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestGenerate_SpectralBasic(t *testing.T) { diff --git a/openapi/linter/converter/parse.go b/openapi/linter/converter/parse.go index 778e1e53..aee60c71 100644 --- a/openapi/linter/converter/parse.go +++ b/openapi/linter/converter/parse.go @@ -7,7 +7,7 @@ import ( "sort" "strconv" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Parse reads a Spectral, Vacuum, or Legacy Speakeasy config and returns diff --git a/openapi/linter/converter/tests/go.mod b/openapi/linter/converter/tests/go.mod index d3027bc6..1482b0eb 100644 --- a/openapi/linter/converter/tests/go.mod +++ b/openapi/linter/converter/tests/go.mod @@ -22,6 +22,7 @@ require ( github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect + go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect golang.org/x/sync v0.19.0 // indirect golang.org/x/sys v0.36.0 // indirect golang.org/x/text v0.34.0 // indirect diff --git a/openapi/linter/converter/tests/go.sum b/openapi/linter/converter/tests/go.sum index 26db0d46..c44ee0a4 100644 --- a/openapi/linter/converter/tests/go.sum +++ b/openapi/linter/converter/tests/go.sum @@ -26,6 +26,8 @@ github.com/speakeasy-api/jsonpath v0.6.3 h1:c+QPwzAOdrWvzycuc9HFsIZcxKIaWcNpC+xh github.com/speakeasy-api/jsonpath v0.6.3/go.mod h1:2cXloNuQ+RSXi5HTRaeBh7JEmjRXTiaKpFTdZiL7URI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U= +go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/openapi/linter/customrules/go.mod b/openapi/linter/customrules/go.mod index 753b209b..b5e7db81 100644 --- a/openapi/linter/customrules/go.mod +++ b/openapi/linter/customrules/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-sourcemap/sourcemap v2.1.4+incompatible github.com/speakeasy-api/openapi v1.19.1-0.20260217225223-7d484a30828f github.com/stretchr/testify v1.11.1 - gopkg.in/yaml.v3 v3.0.1 + go.yaml.in/yaml/v4 v4.0.0-rc.4 ) require ( @@ -23,4 +23,5 @@ require ( golang.org/x/sync v0.19.0 // indirect golang.org/x/sys v0.36.0 // indirect golang.org/x/text v0.34.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/openapi/linter/customrules/go.sum b/openapi/linter/customrules/go.sum index a52d437d..f08a029a 100644 --- a/openapi/linter/customrules/go.sum +++ b/openapi/linter/customrules/go.sum @@ -27,6 +27,8 @@ github.com/speakeasy-api/jsonpath v0.6.3 h1:c+QPwzAOdrWvzycuc9HFsIZcxKIaWcNpC+xh github.com/speakeasy-api/jsonpath v0.6.3/go.mod h1:2cXloNuQ+RSXi5HTRaeBh7JEmjRXTiaKpFTdZiL7URI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U= +go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/openapi/linter/customrules/runtime.go b/openapi/linter/customrules/runtime.go index 6b906b81..73279c9b 100644 --- a/openapi/linter/customrules/runtime.go +++ b/openapi/linter/customrules/runtime.go @@ -7,7 +7,7 @@ import ( "github.com/dop251/goja" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Runtime wraps a goja JavaScript runtime with custom rule support. diff --git a/openapi/linter/linter_test.go b/openapi/linter/linter_test.go index 0f383326..e9022283 100644 --- a/openapi/linter/linter_test.go +++ b/openapi/linter/linter_test.go @@ -20,7 +20,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type mockVirtualFS struct { diff --git a/openapi/linter/rules/description_duplication.go b/openapi/linter/rules/description_duplication.go index a4725404..3f45cdc5 100644 --- a/openapi/linter/rules/description_duplication.go +++ b/openapi/linter/rules/description_duplication.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleStyleDescriptionDuplication = "style-description-duplication" diff --git a/openapi/linter/rules/duplicated_entry_in_enum.go b/openapi/linter/rules/duplicated_entry_in_enum.go index 5cf94507..430a1d59 100644 --- a/openapi/linter/rules/duplicated_entry_in_enum.go +++ b/openapi/linter/rules/duplicated_entry_in_enum.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/linter" "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleSemanticDuplicatedEnum = "semantic-duplicated-enum" diff --git a/openapi/linter/rules/fix_helpers.go b/openapi/linter/rules/fix_helpers.go index 08d8dcf7..c1102c47 100644 --- a/openapi/linter/rules/fix_helpers.go +++ b/openapi/linter/rules/fix_helpers.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // addErrorResponseFix adds a skeleton error response to an operation's responses node. diff --git a/openapi/linter/rules/fix_helpers_test.go b/openapi/linter/rules/fix_helpers_test.go index 5c687d67..19a2be56 100644 --- a/openapi/linter/rules/fix_helpers_test.go +++ b/openapi/linter/rules/fix_helpers_test.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // ============================================================ diff --git a/openapi/linter/rules/fix_integration_test.go b/openapi/linter/rules/fix_integration_test.go index 9bf7a844..abd31029 100644 --- a/openapi/linter/rules/fix_integration_test.go +++ b/openapi/linter/rules/fix_integration_test.go @@ -12,7 +12,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // These integration tests verify that fixes actually resolve the violations diff --git a/openapi/linter/rules/host_trailing_slash.go b/openapi/linter/rules/host_trailing_slash.go index aa3126aa..3009a239 100644 --- a/openapi/linter/rules/host_trailing_slash.go +++ b/openapi/linter/rules/host_trailing_slash.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/linter" "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleStyleOAS3HostTrailingSlash = "style-oas3-host-trailing-slash" diff --git a/openapi/linter/rules/markdown_descriptions.go b/openapi/linter/rules/markdown_descriptions.go index b38160d4..a825a56c 100644 --- a/openapi/linter/rules/markdown_descriptions.go +++ b/openapi/linter/rules/markdown_descriptions.go @@ -1,7 +1,7 @@ package rules import ( - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // GetFieldValueNode gets the YAML value node for a specific field from any object with a GetCore() method. diff --git a/openapi/linter/rules/oas3_no_nullable.go b/openapi/linter/rules/oas3_no_nullable.go index ec7cb719..49a996ba 100644 --- a/openapi/linter/rules/oas3_no_nullable.go +++ b/openapi/linter/rules/oas3_no_nullable.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleOAS3NoNullable = "oas3-no-nullable" diff --git a/openapi/linter/rules/oas_schema_check.go b/openapi/linter/rules/oas_schema_check.go index ecb5ae70..9363fbf5 100644 --- a/openapi/linter/rules/oas_schema_check.go +++ b/openapi/linter/rules/oas_schema_check.go @@ -11,7 +11,7 @@ import ( "github.com/speakeasy-api/openapi/linter" "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleOasSchemaCheck = "oas-schema-check" diff --git a/openapi/linter/rules/operation_success_response.go b/openapi/linter/rules/operation_success_response.go index 4a73ce74..9cb98772 100644 --- a/openapi/linter/rules/operation_success_response.go +++ b/openapi/linter/rules/operation_success_response.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/linter" "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleStyleOperationSuccessResponse = "style-operation-success-response" diff --git a/openapi/linter/rules/owasp_jwt_best_practices.go b/openapi/linter/rules/owasp_jwt_best_practices.go index 5a65a5cb..26a59213 100644 --- a/openapi/linter/rules/owasp_jwt_best_practices.go +++ b/openapi/linter/rules/owasp_jwt_best_practices.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleOwaspJWTBestPractices = "owasp-jwt-best-practices" diff --git a/openapi/linter/rules/owasp_no_additional_properties.go b/openapi/linter/rules/owasp_no_additional_properties.go index f7c35fe1..86a919c1 100644 --- a/openapi/linter/rules/owasp_no_additional_properties.go +++ b/openapi/linter/rules/owasp_no_additional_properties.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleOwaspNoAdditionalProperties = "owasp-no-additional-properties" diff --git a/openapi/linter/rules/owasp_security_hosts_https_oas3.go b/openapi/linter/rules/owasp_security_hosts_https_oas3.go index 365df6ae..5f043d32 100644 --- a/openapi/linter/rules/owasp_security_hosts_https_oas3.go +++ b/openapi/linter/rules/owasp_security_hosts_https_oas3.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleOwaspSecurityHostsHttpsOAS3 = "owasp-security-hosts-https-oas3" diff --git a/openapi/linter/rules/path_trailing_slash.go b/openapi/linter/rules/path_trailing_slash.go index e758ef27..802fadd4 100644 --- a/openapi/linter/rules/path_trailing_slash.go +++ b/openapi/linter/rules/path_trailing_slash.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/linter" "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleStylePathTrailingSlash = "style-path-trailing-slash" diff --git a/openapi/linter/rules/rule_fixes_test.go b/openapi/linter/rules/rule_fixes_test.go index 92fd988e..c5117995 100644 --- a/openapi/linter/rules/rule_fixes_test.go +++ b/openapi/linter/rules/rule_fixes_test.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // ============================================================ diff --git a/openapi/linter/rules/tags_alphabetical.go b/openapi/linter/rules/tags_alphabetical.go index ac525435..29ced6ce 100644 --- a/openapi/linter/rules/tags_alphabetical.go +++ b/openapi/linter/rules/tags_alphabetical.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleStyleTagsAlphabetical = "style-tags-alphabetical" diff --git a/openapi/linter/rules/typed_enum.go b/openapi/linter/rules/typed_enum.go index 75147cb8..231148fc 100644 --- a/openapi/linter/rules/typed_enum.go +++ b/openapi/linter/rules/typed_enum.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/linter" "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleSemanticTypedEnum = "semantic-typed-enum" diff --git a/openapi/linter/rules/unused_components.go b/openapi/linter/rules/unused_components.go index 020cfc58..50e0bb14 100644 --- a/openapi/linter/rules/unused_components.go +++ b/openapi/linter/rules/unused_components.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/speakeasy-api/openapi/references" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const RuleSemanticUnusedComponent = "semantic-unused-component" diff --git a/openapi/localize.go b/openapi/localize.go index 25757109..43b9695f 100644 --- a/openapi/localize.go +++ b/openapi/localize.go @@ -14,7 +14,7 @@ import ( "github.com/speakeasy-api/openapi/references" "github.com/speakeasy-api/openapi/sequencedmap" "github.com/speakeasy-api/openapi/system" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // LocalizeNamingStrategy defines how external reference files should be named when localized. diff --git a/openapi/openapi.go b/openapi/openapi.go index bfcf2efa..34d1f22d 100644 --- a/openapi/openapi.go +++ b/openapi/openapi.go @@ -15,7 +15,7 @@ import ( "github.com/speakeasy-api/openapi/pointer" "github.com/speakeasy-api/openapi/sequencedmap" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Version is the version of the OpenAPI Specification that this package conforms to. diff --git a/openapi/openapi_examples_test.go b/openapi/openapi_examples_test.go index f4f50c86..3f240403 100644 --- a/openapi/openapi_examples_test.go +++ b/openapi/openapi_examples_test.go @@ -265,10 +265,10 @@ func Example_validating() { // [56:7] error validation-type-mismatch schema.examples expected `array`, got `object` // [59:15] error validation-type-mismatch schema.properties.name expected one of [`boolean`, `object`], got `string` // [59:15] error validation-type-mismatch schema.properties.name expected one of [`boolean`, `object`], got `string` - // [59:15] error validation-type-mismatch schema.properties.name failed to validate either Schema [schema.properties.name expected `object`, got `str...`] or bool [schema.properties.name line 59: cannot unmarshal !!str `string` into bool] + // [59:15] error validation-type-mismatch schema.properties.name failed to validate either Schema [schema.properties.name expected `object`, got `str...`] or bool [schema.properties.name line 59: cannot construct !!str `string` into bool] // [60:18] error validation-type-mismatch schema.properties.example expected one of [`boolean`, `object`], got `string` // [60:18] error validation-type-mismatch schema.properties.example expected one of [`boolean`, `object`], got `string` - // [60:18] error validation-type-mismatch schema.properties.example failed to validate either Schema [schema.properties.example expected `object`, got `John Do...`] or bool [schema.properties.example line 60: cannot unmarshal !!str `John Doe` into bool] + // [60:18] error validation-type-mismatch schema.properties.example failed to validate either Schema [schema.properties.example expected `object`, got `John Do...`] or bool [schema.properties.example line 60: cannot construct !!str `John Doe` into bool] // [63:9] error validation-type-mismatch schema.examples expected `sequence`, got `object` // // Fixing validation errors... diff --git a/openapi/reference.go b/openapi/reference.go index 4c307762..b8b4d043 100644 --- a/openapi/reference.go +++ b/openapi/reference.go @@ -14,7 +14,7 @@ import ( "github.com/speakeasy-api/openapi/pointer" "github.com/speakeasy-api/openapi/references" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type ( diff --git a/openapi/sanitize.go b/openapi/sanitize.go index 2aa6a985..75beaddd 100644 --- a/openapi/sanitize.go +++ b/openapi/sanitize.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/extensions" "github.com/speakeasy-api/openapi/jsonschema/oas3" "github.com/speakeasy-api/openapi/marshaller" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // ExtensionFilter specifies patterns for filtering extensions using allowed and denied lists. diff --git a/openapi/upgrade.go b/openapi/upgrade.go index ec056ac0..84485168 100644 --- a/openapi/upgrade.go +++ b/openapi/upgrade.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/jsonschema/oas3" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type UpgradeOptions struct { diff --git a/openapi/upgrade_test.go b/openapi/upgrade_test.go index 29b63f4f..ce4ee48e 100644 --- a/openapi/upgrade_test.go +++ b/openapi/upgrade_test.go @@ -12,7 +12,7 @@ import ( "github.com/speakeasy-api/openapi/openapi" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestUpgrade_Success(t *testing.T) { diff --git a/overlay/apply.go b/overlay/apply.go index fdf3856b..5f5d6259 100644 --- a/overlay/apply.go +++ b/overlay/apply.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/jsonpath/pkg/jsonpath/config" "github.com/speakeasy-api/jsonpath/pkg/jsonpath/token" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // ApplyTo will take an overlay and apply its changes to the given YAML diff --git a/overlay/apply_test.go b/overlay/apply_test.go index 6d2ddfc7..7e8dafa4 100644 --- a/overlay/apply_test.go +++ b/overlay/apply_test.go @@ -5,15 +5,23 @@ import ( "os" "strconv" "testing" + "unsafe" "github.com/speakeasy-api/jsonpath/pkg/jsonpath" "github.com/speakeasy-api/openapi/overlay" "github.com/speakeasy-api/openapi/overlay/loader" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" + yamlv3 "gopkg.in/yaml.v3" ) +// queryV4 runs a jsonpath query using a v4 node by casting to v3 and back. +func queryV4(path *jsonpath.JSONPath, node *yaml.Node) []*yaml.Node { + v3result := path.Query((*yamlv3.Node)(unsafe.Pointer(node))) + return *(*[]*yaml.Node)(unsafe.Pointer(&v3result)) +} + // NodeMatchesFile is a test that marshals the YAML file from the given node, // then compares those bytes to those found in the expected file. func NodeMatchesFile( @@ -305,7 +313,7 @@ func TestApplyToOld(t *testing.T) { path, err := jsonpath.NewPath(`$.paths["/anything/selectGlobalServer"]`) require.NoError(t, err) - result := path.Query(nodeOld) + result := queryV4(path, nodeOld) require.NoError(t, err) require.Empty(t, result) o.JSONPathVersion = "rfc9535" @@ -319,7 +327,7 @@ func TestApplyToOld(t *testing.T) { o.Actions[0].Target = "$.paths[?(@[\"x-my-ignore\"])]" // @ should always refer to the child node in RFC 9535.. _, err = o.ApplyToStrict(nodeNew) require.NoError(t, err) - result = path.Query(nodeNew) + result = queryV4(path, nodeNew) require.NoError(t, err) require.Empty(t, result) } diff --git a/overlay/compare.go b/overlay/compare.go index 06360a49..72ac82c5 100644 --- a/overlay/compare.go +++ b/overlay/compare.go @@ -6,7 +6,7 @@ import ( "log" "strings" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Compare compares input specifications from two files and returns an overlay diff --git a/overlay/compare_test.go b/overlay/compare_test.go index 10ec184f..c5e8f22d 100644 --- a/overlay/compare_test.go +++ b/overlay/compare_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/overlay/loader" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestCompare(t *testing.T) { diff --git a/overlay/format_test.go b/overlay/format_test.go index 0701b7f4..ce0ec917 100644 --- a/overlay/format_test.go +++ b/overlay/format_test.go @@ -9,7 +9,7 @@ import ( "github.com/speakeasy-api/openapi/overlay" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestOverlay_Format_Success(t *testing.T) { diff --git a/overlay/jsonpath.go b/overlay/jsonpath.go index 2ccc3c73..920766c8 100644 --- a/overlay/jsonpath.go +++ b/overlay/jsonpath.go @@ -2,12 +2,14 @@ package overlay import ( "fmt" + "unsafe" "github.com/speakeasy-api/jsonpath/pkg/jsonpath" "github.com/speakeasy-api/jsonpath/pkg/jsonpath/config" "github.com/speakeasy-api/openapi/internal/version" "github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" + yamlv3 "gopkg.in/yaml.v3" ) // Queryable is an interface for querying YAML nodes using JSONPath expressions. @@ -15,6 +17,20 @@ type Queryable interface { Query(root *yaml.Node) []*yaml.Node } +// nodeV4toV3 converts a *yaml.v4.Node to a *yaml.v3.Node via unsafe pointer cast. +// This is safe because v4.Node is a strict superset of v3.Node — the first 12 fields +// have identical types, sizes, and offsets. The v3 code never accesses the extra v4 fields. +func nodeV4toV3(n *yaml.Node) *yamlv3.Node { + return (*yamlv3.Node)(unsafe.Pointer(n)) //nolint:gosec // v4.Node is a strict superset of v3.Node (verified via reflect) +} + +// nodesV3toV4 converts a []*yaml.v3.Node slice to []*yaml.v4.Node. +// The underlying pointer types have identical memory layouts so the slice header +// can be reinterpreted directly. +func nodesV3toV4(nodes []*yamlv3.Node) []*yaml.Node { + return *(*[]*yaml.Node)(unsafe.Pointer(&nodes)) //nolint:gosec // pointer types have identical memory layouts +} + type yamlPathQueryable struct { path *yamlpath.Path } @@ -24,8 +40,17 @@ func (y yamlPathQueryable) Query(root *yaml.Node) []*yaml.Node { return []*yaml.Node{} } // errors aren't actually possible from yamlpath. - result, _ := y.path.Find(root) - return result + result, _ := y.path.Find(nodeV4toV3(root)) + return nodesV3toV4(result) +} + +// rfcJSONPathQueryable wraps a jsonpath.JSONPath to implement Queryable with v4 nodes. +type rfcJSONPathQueryable struct { + path *jsonpath.JSONPath +} + +func (r rfcJSONPathQueryable) Query(root *yaml.Node) []*yaml.Node { + return nodesV3toV4(r.path.Query(nodeV4toV3(root))) } // NewPath creates a new JSONPath queryable from the given target expression. @@ -35,7 +60,10 @@ func (y yamlPathQueryable) Query(root *yaml.Node) []*yaml.Node { func (o *Overlay) NewPath(target string, warnings *[]string) (Queryable, error) { rfcJSONPath, rfcJSONPathErr := jsonpath.NewPath(target, config.WithPropertyNameExtension()) if o.UsesRFC9535() { - return rfcJSONPath, rfcJSONPathErr + if rfcJSONPathErr != nil { + return nil, rfcJSONPathErr + } + return rfcJSONPathQueryable{path: rfcJSONPath}, nil } // For version < 1.1.0 without explicit rfc9535, warn about future incompatibility diff --git a/overlay/loader/spec.go b/overlay/loader/spec.go index 95401ddd..860dc5bb 100644 --- a/overlay/loader/spec.go +++ b/overlay/loader/spec.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/speakeasy-api/openapi/overlay" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // GetOverlayExtendsPath returns the path to file if the extends URL is a file diff --git a/overlay/loader/spec_test.go b/overlay/loader/spec_test.go index 1a6b70b9..2c0af042 100644 --- a/overlay/loader/spec_test.go +++ b/overlay/loader/spec_test.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/overlay" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // pathToFileURL converts a file path to a proper file:// URL diff --git a/overlay/overlay_examples_test.go b/overlay/overlay_examples_test.go index 0f3eb5f0..4d04d98b 100644 --- a/overlay/overlay_examples_test.go +++ b/overlay/overlay_examples_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/overlay" "github.com/speakeasy-api/openapi/overlay/loader" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Example_applying demonstrates how to apply an overlay to an OpenAPI document. diff --git a/overlay/parents.go b/overlay/parents.go index a2b4942c..59546893 100644 --- a/overlay/parents.go +++ b/overlay/parents.go @@ -1,6 +1,6 @@ package overlay -import "gopkg.in/yaml.v3" +import "go.yaml.in/yaml/v4" type parentIndex map[*yaml.Node]*yaml.Node diff --git a/overlay/parse.go b/overlay/parse.go index e3fb93c1..8debed16 100644 --- a/overlay/parse.go +++ b/overlay/parse.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // ParseReader parses an overlay from the given reader. diff --git a/overlay/schema.go b/overlay/schema.go index 2658be73..04f62e9f 100644 --- a/overlay/schema.go +++ b/overlay/schema.go @@ -3,7 +3,7 @@ package overlay import ( "bytes" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Version constants for the Overlay specification diff --git a/overlay/upgrade_test.go b/overlay/upgrade_test.go index a335a44c..7fbbd032 100644 --- a/overlay/upgrade_test.go +++ b/overlay/upgrade_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/overlay" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestUpgrade_Success(t *testing.T) { diff --git a/overlay/utils.go b/overlay/utils.go index 38439706..e1f3897d 100644 --- a/overlay/utils.go +++ b/overlay/utils.go @@ -3,7 +3,7 @@ package overlay import ( "fmt" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func NewTargetSelector(path, method string) string { diff --git a/overlay/utils_test.go b/overlay/utils_test.go index 8c96a0ab..e22d8e85 100644 --- a/overlay/utils_test.go +++ b/overlay/utils_test.go @@ -5,7 +5,7 @@ import ( "github.com/speakeasy-api/openapi/overlay" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestNewTargetSelector_Success(t *testing.T) { diff --git a/overlay/validate_test.go b/overlay/validate_test.go index d68dc571..0c53b4d9 100644 --- a/overlay/validate_test.go +++ b/overlay/validate_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/overlay" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestOverlay_Validate(t *testing.T) { diff --git a/references/resolution.go b/references/resolution.go index c310840f..6d811862 100644 --- a/references/resolution.go +++ b/references/resolution.go @@ -12,7 +12,7 @@ import ( "github.com/speakeasy-api/openapi/internal/utils" "github.com/speakeasy-api/openapi/jsonpointer" "github.com/speakeasy-api/openapi/system" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type ResolutionTarget interface { diff --git a/references/resolution_test.go b/references/resolution_test.go index afa8bd48..cf9f7eb4 100644 --- a/references/resolution_test.go +++ b/references/resolution_test.go @@ -16,7 +16,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller/tests" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // MockResolutionTarget implements ResolutionTarget for testing diff --git a/sequencedmap/map.go b/sequencedmap/map.go index 8c5f2c49..ec1e5844 100644 --- a/sequencedmap/map.go +++ b/sequencedmap/map.go @@ -15,7 +15,7 @@ import ( "github.com/speakeasy-api/openapi/internal/interfaces" "github.com/speakeasy-api/openapi/internal/utils" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // OrderType represents the different ways to order iteration through the map diff --git a/sequencedmap/map_advanced_test.go b/sequencedmap/map_advanced_test.go index 011d6a9e..64f1c2ce 100644 --- a/sequencedmap/map_advanced_test.go +++ b/sequencedmap/map_advanced_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestMap_NavigateWithKey_Success(t *testing.T) { diff --git a/sequencedmap/yaml_unmarshal_test.go b/sequencedmap/yaml_unmarshal_test.go index f5ec1fbd..7484c626 100644 --- a/sequencedmap/yaml_unmarshal_test.go +++ b/sequencedmap/yaml_unmarshal_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/sequencedmap" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestSequencedMap_Standard_Yaml_Unmarshal(t *testing.T) { diff --git a/swagger/core/paths.go b/swagger/core/paths.go index c05967f5..8ea289f5 100644 --- a/swagger/core/paths.go +++ b/swagger/core/paths.go @@ -4,7 +4,7 @@ import ( "github.com/speakeasy-api/openapi/extensions/core" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Paths holds the relative paths to the individual endpoints. diff --git a/swagger/core/paths_test.go b/swagger/core/paths_test.go index 0a4a3709..a3ca2afc 100644 --- a/swagger/core/paths_test.go +++ b/swagger/core/paths_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func parseYAML(t *testing.T, yml string) *yaml.Node { diff --git a/swagger/core/reference.go b/swagger/core/reference.go index 32efa31b..c8d1b618 100644 --- a/swagger/core/reference.go +++ b/swagger/core/reference.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/validation" "github.com/speakeasy-api/openapi/yml" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Reference represents either a reference to a component or an inline object. diff --git a/swagger/core/reference_test.go b/swagger/core/reference_test.go index 58865efc..f6faa63c 100644 --- a/swagger/core/reference_test.go +++ b/swagger/core/reference_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestReference_Unmarshal_Success(t *testing.T) { diff --git a/swagger/core/response.go b/swagger/core/response.go index a3210121..aef6e1d7 100644 --- a/swagger/core/response.go +++ b/swagger/core/response.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/sequencedmap" values "github.com/speakeasy-api/openapi/values/core" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Responses is a container for the expected responses of an operation. diff --git a/swagger/core/response_test.go b/swagger/core/response_test.go index 5b3cb88e..1ec4c16f 100644 --- a/swagger/core/response_test.go +++ b/swagger/core/response_test.go @@ -6,7 +6,7 @@ import ( "github.com/speakeasy-api/openapi/marshaller" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestNewResponses_Success(t *testing.T) { diff --git a/swagger/roundtrip_test.go b/swagger/roundtrip_test.go index f7cbc4f4..9eb83bbc 100644 --- a/swagger/roundtrip_test.go +++ b/swagger/roundtrip_test.go @@ -13,7 +13,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type roundTripTest struct { diff --git a/validation/errors.go b/validation/errors.go index a37100aa..4340b016 100644 --- a/validation/errors.go +++ b/validation/errors.go @@ -3,7 +3,7 @@ package validation import ( "fmt" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type Severity string diff --git a/validation/fix.go b/validation/fix.go index 0364e3d7..160849ec 100644 --- a/validation/fix.go +++ b/validation/fix.go @@ -1,6 +1,6 @@ package validation -import "gopkg.in/yaml.v3" +import "go.yaml.in/yaml/v4" // PromptType describes what kind of user input a fix needs. type PromptType int diff --git a/validation/utils_test.go b/validation/utils_test.go index 71fc92e2..9309aa57 100644 --- a/validation/utils_test.go +++ b/validation/utils_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Test SortValidationErrors function diff --git a/validation/validation_test.go b/validation/validation_test.go index d53c2ed9..b7c50791 100644 --- a/validation/validation_test.go +++ b/validation/validation_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) // Test the Error type methods diff --git a/values/core/eithervalue.go b/values/core/eithervalue.go index b280f0e7..1e3795ec 100644 --- a/values/core/eithervalue.go +++ b/values/core/eithervalue.go @@ -10,7 +10,7 @@ import ( "github.com/speakeasy-api/openapi/internal/interfaces" "github.com/speakeasy-api/openapi/marshaller" "github.com/speakeasy-api/openapi/validation" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type EitherValue[L any, R any] struct { diff --git a/values/core/eithervalue_test.go b/values/core/eithervalue_test.go index 6270c21d..f68e2ab0 100644 --- a/values/core/eithervalue_test.go +++ b/values/core/eithervalue_test.go @@ -11,7 +11,7 @@ import ( "github.com/speakeasy-api/openapi/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type TestEitherValue[L any, R any] struct { diff --git a/values/core/value.go b/values/core/value.go index 027e7ed5..b8dabb32 100644 --- a/values/core/value.go +++ b/values/core/value.go @@ -1,6 +1,6 @@ package core -import "gopkg.in/yaml.v3" +import "go.yaml.in/yaml/v4" // Value represents a raw value in an OpenAPI or Arazzo document. type Value = *yaml.Node diff --git a/values/value.go b/values/value.go index a255214c..39aa05e2 100644 --- a/values/value.go +++ b/values/value.go @@ -1,6 +1,6 @@ package values -import "gopkg.in/yaml.v3" +import "go.yaml.in/yaml/v4" // Value represents a raw value in an OpenAPI or Arazzo document. type Value = *yaml.Node diff --git a/yml/config.go b/yml/config.go index 0bb9aede..848d6fb9 100644 --- a/yml/config.go +++ b/yml/config.go @@ -5,7 +5,7 @@ import ( "context" "strconv" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) type contextKey string diff --git a/yml/config_test.go b/yml/config_test.go index 92d9ea24..82519a5a 100644 --- a/yml/config_test.go +++ b/yml/config_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestContextKey_String_Success(t *testing.T) { diff --git a/yml/nodekind.go b/yml/nodekind.go index a90996f7..2adb06c2 100644 --- a/yml/nodekind.go +++ b/yml/nodekind.go @@ -1,6 +1,6 @@ package yml -import "gopkg.in/yaml.v3" +import "go.yaml.in/yaml/v4" // NodeKindToString returns a human-readable string representation of a yaml.Kind. // This helper function is useful for creating more user-friendly error messages diff --git a/yml/nodekind_test.go b/yml/nodekind_test.go index 9163a198..b2af252a 100644 --- a/yml/nodekind_test.go +++ b/yml/nodekind_test.go @@ -5,7 +5,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestNodeKindToString(t *testing.T) { diff --git a/yml/walk.go b/yml/walk.go index 46bd0065..c5200a0c 100644 --- a/yml/walk.go +++ b/yml/walk.go @@ -4,7 +4,7 @@ import ( "context" "github.com/speakeasy-api/openapi/errors" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) const ( diff --git a/yml/walk_test.go b/yml/walk_test.go index aa13115f..50125bab 100644 --- a/yml/walk_test.go +++ b/yml/walk_test.go @@ -8,7 +8,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestWalk_Success(t *testing.T) { diff --git a/yml/yml.go b/yml/yml.go index ec654882..473b0d3d 100644 --- a/yml/yml.go +++ b/yml/yml.go @@ -5,7 +5,7 @@ import ( "reflect" "strconv" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func CreateOrUpdateKeyNode(ctx context.Context, key string, keyNode *yaml.Node) *yaml.Node { diff --git a/yml/yml_test.go b/yml/yml_test.go index 67782d99..2382f67c 100644 --- a/yml/yml_test.go +++ b/yml/yml_test.go @@ -7,7 +7,7 @@ import ( "github.com/speakeasy-api/openapi/yml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v4" ) func TestCreateOrUpdateKeyNode_Success(t *testing.T) {