Open inFocus7 opened 5 days ago
I can also pick this up if it's okay. I have a branch in progress here https://github.com/pb33f/libopenapi/compare/main...inFocus7:libopenapi:355/fix-bad-yaml-not-being-errored-correctly?expand=1. Just need to clean up test naming, and discuss/figure out which path to take (w.r.t. bypass
also used to catch decoding
errors, or always do so, or add another field to set for this error checking to affect less people)
Issue
When opening a document with invalid spec, during the decoding of a document regardless of
byass
ing the document check, we ignore any errors that come up from decoding (ex._ = parsedNode.Decode(&jsonSpec)
). parsing code re-usedExpected Behavior
If we set
bypass=false
(or some new configuration, if preferred), we should not ignore any errors that happen during decoding.Reproduction
I linked a branch in Extra Information, but the example spec used for this is:
As you can see, the doc has a malindented second path. This should result in an error during decoding - which it does, but it is dropped (
_
). Technically the get(?) operation is set twice, since the second path + its operation is just treated as values for the first path, which is why this is a JSON/YAML issue.Side Note: If you change the second path's operation to something else (put), then it technically would be valid JSON/YAML and would decode properly. At this point, the API doc would be invalid; I already tested that it results in an error through
libopenapi-validator
, which is good.Extra Information
libopenapi-validator
with the example doc used to reproduce this (error being ignored): https://github.com/pb33f/libopenapi-validator/compare/main...inFocus7:libopenapi-validator:102/fix-malindented-path-validation?expand=1next
version) results in the error we''d expect during decoding.