Skip to content

test: add goccy/go-yaml tests and improve YAML marshal/unmarshal #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SVilgelm
Copy link
Member

Add tests for goccy/go-yaml in RefOrSpec and Extendable types to ensure
compatibility with an alternative YAML library. This increases test
coverage and robustness for YAML handling.

Refactor Schema YAML marshal/unmarshal to use JSON as intermediate
format, simplifying the process and avoiding issues with extension
fields. Update UnmarshalYAML to support both go-yaml and legacy YAML
unmarshalers.

Remove some invalid or redundant test cases in singleOrArray tests and
fix minor formatting issues.

@Copilot Copilot AI review requested due to automatic review settings May 13, 2025 22:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds tests for the goccy/go-yaml library and refactors YAML marshal/unmarshal implementations across several OpenAPI types to use JSON as an intermediate format. Key changes include the introduction of goyaml-based tests for types (e.g. RefOrSpec, Schema, etc.), refactoring of marshal/unmarshal methods to support both legacy and goyaml interfaces, and some cleanup of redundant test cases.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
validation_test.go Added goyaml tests alongside legacy YAML tests for spec validation.
single_or_array_test.go Refactored test helper and added goyaml tests for both JSON and YAML.
single_or_array.go Updated marshal/unmarshal methods to use JSON intermediates for YAML.
schema_test.go, schema.go Updated YAML handling using both yaml.v3 and goyaml libraries.
responses.{go,test.go} Refactored responses marshal/unmarshal to use map-based fields.
ref_test.go, ref.go Adjusted tests and ref unmarshaling methods to support goyaml.
paths.{go,test.go} Updated YAML interface methods to adopt newer unmarshal function style.
extensions.{go,test.go} Refactored extension handling to use JSON intermediates for YAML.
components.go Minor adjustment to the regex pattern for validating component names.
bool_or_schema.{go,test.go} Updated bool-or-schema tests and YAML unmarshal implementation.
README.md Documented the new support for the goccy/go-yaml library.
Comments suppressed due to low confidence (1)

single_or_array_test.go:121

  • There appears to be an extra trailing quote in the test data for the 'array of string for int' case. Please remove the extra quote to ensure the test data matches the intended JSON array format.
data:     []byte(`["first", "second"]"`),

@SVilgelm SVilgelm force-pushed the yaml-marshaling-and-goccy-support branch from 25c2b52 to 7e2431a Compare May 13, 2025 22:33
@SVilgelm SVilgelm marked this pull request as draft May 18, 2025 17:45
@SVilgelm SVilgelm force-pushed the yaml-marshaling-and-goccy-support branch 2 times, most recently from 06d0130 to 7a18e3c Compare May 19, 2025 18:48
Add tests for goccy/go-yaml in RefOrSpec and Extendable types to ensure
compatibility with an alternative YAML library. This increases test
coverage and robustness for YAML handling.

Refactor Schema YAML marshal/unmarshal to use JSON as intermediate
format, simplifying the process and avoiding issues with extension
fields. Update UnmarshalYAML to support both go-yaml and legacy YAML
unmarshalers.

Remove some invalid or redundant test cases in singleOrArray tests and
fix minor formatting issues.
@SVilgelm SVilgelm force-pushed the yaml-marshaling-and-goccy-support branch from 7a18e3c to f16597d Compare May 19, 2025 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant