Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwaggerValidationError: expected string or buffer #9

Closed
ptman opened this issue Nov 7, 2017 · 7 comments
Closed

SwaggerValidationError: expected string or buffer #9

ptman opened this issue Nov 7, 2017 · 7 comments

Comments

@ptman
Copy link

ptman commented Nov 7, 2017

I get this error trying to do:

from prance import ResolvingParser
p = ResolvingParser('swagger.yaml')

The yaml file is valid according to editor.swagger.io and http://bigstickcarpet.com/swagger-parser/www/index.html

I have no idea where in the swagger file the error is. A line number or similar would be helpful

@jfinkhaeuser
Copy link
Collaborator

Thanks for the report!

Yeah, I know a line number would be great. Ugh. I'll see what I can do about that. Do you have the file so I can reproduce? Or is that sensitive? You can email me directly at jens@finkhaeuser.de if you prefer.

What OS are you using? Can you post the full stack trace?

Thanks!

@jfinkhaeuser
Copy link
Collaborator

So, line numbers are going to be difficult. I'm doing two steps here, a) is read the file into a Python data structure (nested dicts/lists, etc.), and b) to validate the structure via swagger_spec_validator.

At the point you get a SwaggerValidationError, there are no more line numbers known. The best thing would be some kind of keyword context, but swagger_spec_validator does not provide that.

I'm a little reluctant re-implementing this part... but let's see what else I can find.

@ptman
Copy link
Author

ptman commented Nov 8, 2017

Right, a keyword would do just as fine.

@ptman
Copy link
Author

ptman commented Nov 8, 2017

@jfinkhaeuser
Copy link
Collaborator

Thanks for this.

The TL;DR is, I'm going to replace the validation backend. That solves your issue, another issue, and you should get better error messages in case there's something weird in your spec :)

jfinkhaeuser added a commit that referenced this issue Nov 8, 2017
jfinkhaeuser added a commit that referenced this issue Nov 8, 2017
- add --backend CLI option
- Catch our own error class, not the underlying backend's
jfinkhaeuser added a commit that referenced this issue Nov 8, 2017
jfinkhaeuser added a commit that referenced this issue Nov 8, 2017
@jfinkhaeuser
Copy link
Collaborator

Took me a while to see the obvious: this is the same issue as #5.

Still, if it crops up many times, let's still use a different backend. I've made it so people can use the old backend, so that should not cause any issues.

@jfinkhaeuser
Copy link
Collaborator

0.8 should fix it. Otherwise, set strict = False :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants