aiohttp-swagger icon indicating copy to clipboard operation
aiohttp-swagger copied to clipboard

patch: More verbose yaml errors

Open verpeteren opened this issue 5 years ago • 1 comments

When the docstring is invalid yaml/swagger, the generated swagged documentation just shows:

Invalid Swagger
⚠ Swagger document could not be loaded from docstring ⚠

This change makes the docstring parsing step a bit more verbose to indicate that there are problems. It is still not ideal but it is an improvement over guessing/ copy-pasta into a validator.

How to test that this is working:

  1. create a aiohttp route with docstring, add it to the app with the swagger plugin
  2. start the app
  3. navigate to the /api/doc page and find the route observe that the route is displayed correctly in the swagger page
  4. change the docstring to invalid yaml (e.g. by indenting with tabs)
  5. (re) start the app observe that there is more verbose output
  6. (re) navigat ot the /api/doc page and find the route observe that the route now probably is labeled as 'Invalid Swagger'

verpeteren avatar Dec 18 '19 08:12 verpeteren

Codecov Report

Merging #84 into master will decrease coverage by 3.43%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #84      +/-   ##
=========================================
- Coverage   94.73%   91.3%   -3.44%     
=========================================
  Files           4       4              
  Lines         133     138       +5     
=========================================
  Hits          126     126              
- Misses          7      12       +5
Impacted Files Coverage Δ
aiohttp_swagger/helpers/builders.py 86.66% <0%> (-5.1%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update db559ae...a85683e. Read the comment docs.

codecov-io avatar Dec 18 '19 08:12 codecov-io