Repository navigation
feat: stricter document path validation - #329
ySnoopyDogy wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #329 +/- ##
==========================================
+ Coverage 98.27% 98.29% +0.02%
==========================================
Files 80 81 +1
Lines 9481 9592 +111
==========================================
+ Hits 9317 9428 +111
Misses 139 139
Partials 25 25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for adding this. The opt-in approach makes sense, and the full test suite passes at In I reproduced this with
Both cases also reproduce with this change applied to current Please make these changes:
The existing checks are green, but they don't cover this failure path yet. Thanks for working on this — let's close that gap before it goes in :) |
ef761b3 to
d26c829
Compare
|
Good catch! Now the validation runs even if building the model returns some errors. If the model can't be built, an explicit error is returned. I'm ignoring the build error when the model is still available, because ValidateDocument never checked whether |
While using the lib, I notice that the document validation is not strict enough. The OpenAPI spec does not allow to have path parameters defined that diverge from the path templates of an operation.
I checked against the kin-openapi, and their lib correctly validate the document that do not include the correct path templates:
To make the libopenapi-validator more strict following the OpenAPI spec without adding a breaking change, there is a new option called
ValidateDocumentPathParams, with its functionWithPathParameterDocumentValidationto enable the config.With this config, we run another validation just to catch the missing and extra path parameters.
All tests pass, and the new ones ensure that the stricter path checking is working as intended.