pb33f / libopenapi

libopenapi is a fully featured, high performance OpenAPI 3.1, 3.0 and Swagger parser, library, validator and toolkit for golang applications.
https://pb33f.io/libopenapi/
Other
487 stars 64 forks source link

fix: improved handling of complex yaml in YAMLNodeToJSON #316

Closed TristanSpeakEasy closed 3 months ago

TristanSpeakEasy commented 3 months ago

Makes it possible to render yaml that uses anchors and complex map keys

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 99.65%. Comparing base (61b8a2f) to head (ecc3d69).

Files Patch % Lines
json/json.go 87.50% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #316 +/- ## ========================================== + Coverage 99.62% 99.65% +0.02% ========================================== Files 164 164 Lines 16586 16593 +7 ========================================== + Hits 16524 16535 +11 + Misses 57 53 -4 Partials 5 5 ``` | [Flag](https://app.codecov.io/gh/pb33f/libopenapi/pull/316/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pb33f) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/pb33f/libopenapi/pull/316/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pb33f) | `99.65% <87.50%> (+0.02%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pb33f#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

daveshanley commented 3 months ago

Bump those two lines of coverage, and it's good to go.

TristanSpeakEasy commented 3 months ago

@daveshanley I didn't cover those lines as I really don't know how to inject invalid data into this to cause those to be covered.

If you have any ideas let me know and I will add tests

TristanSpeakEasy commented 3 months ago

@daveshanley essential asking for a pass on dealing with those bits of coverage, though if you really do want them covered I guess a way forward is to unit test the internal functions directly (currently I am only testing the public interface with the package json_test restriction in the test file) and manually trying to construct an invalid yaml.Node

daveshanley commented 3 months ago

I spent about 20 minutes and I could get one line covered, but the other is impossible to test as it's a deep catch.

Pass granted.