Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to verify yaml conversions work (#6819)
### **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description This PR adds a test to verify that no additional yaml struct tags aren't required on OAS structs to support yaml while defining Tyk OAS APIs. kin-openapi supports parsing yaml openapi specifications making use of json struct tags. [kin-openapi/go.mod at cea0a13b906a708102947f95b9b09d631ff60976 · getkin/kin-openapi](https://github.com/getkin/kin-openapi/blob/cea0a13b906a708102947f95b9b09d631ff60976/go.mod#L9) it can be seen that kin-openapi is using [GitHub - oasdiff/yaml: A better way to marshal and unmarshal YAML in Golang](https://github.com/oasdiff/yaml) which explains [here](https://github.com/oasdiff/yaml) that it converts yaml ↔︎ json internally. This means we don’t have to have additional struct tags for yaml. ## Related Issue https://tyktech.atlassian.net/browse/TT-13783 ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** Tests, Enhancement ___ ### **Description** - Added a new test `TestYaml` to validate YAML and JSON conversions. - Introduced dependency on `github.com/oasdiff/yaml` for YAML handling. - Updated `go.mod` and `go.sum` to include new YAML-related dependencies. - Enhanced test coverage for OpenAPI and Tyk extension integration. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>oas_test.go</strong><dd><code>Added `TestYaml` for YAML and JSON conversion validation</code> </dd></summary> <hr> apidef/oas/oas_test.go <li>Added a new test <code>TestYaml</code> for YAML and JSON conversion.<br> <li> Validated Tyk extension integration with OpenAPI structures.<br> <li> Used <code>yaml.JSONToYAML</code> for JSON to YAML conversion.<br> <li> Ensured equality between original and converted objects. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6819/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+54/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>go.mod</strong><dd><code>Updated dependencies for YAML handling</code> </dd></summary> <hr> go.mod <li>Added <code>github.com/oasdiff/yaml</code> as a direct dependency.<br> <li> Added <code>github.com/oasdiff/yaml3</code> as an indirect dependency. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6819/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6">+2/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>go.sum</strong><dd><code>Updated checksums for new YAML dependencies</code> </dd></summary> <hr> go.sum <li>Added checksums for <code>github.com/oasdiff/yaml</code> and <br><code>github.com/oasdiff/yaml3</code>.<br> <li> Updated dependency metadata for YAML-related libraries. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6819/files#diff-3295df7234525439d778f1b282d146a4f1ff6b415248aaac074e8042d9f42d63">+4/-0</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information
- Loading branch information