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

Import failing #31

Open
wimleers opened this issue Apr 11, 2017 · 3 comments
Open

Import failing #31

wimleers opened this issue Apr 11, 2017 · 3 comments

Comments

@wimleers
Copy link

wimleers commented Apr 11, 2017

On this Swagger file:

https://raw.githubusercontent.com/acquia/waterwheel.js/master/test/sample/swagger.example.json

I'm getting this error:

Import Failed
A JavaScript exception was raised. Open the Extension Console (under the Window menu) for more information.

Error: Invalid Swagger File (invalid schema / version < 2.0):
ValidationError: String does not match pattern: ^/

@JonathanMontane
Copy link
Contributor

JonathanMontane commented Apr 12, 2017

Thanks for the report!

After investigating, it seems the issue lies in the swagger file rather than in the Parser. For some reason, / are escaped before being dumped as a JSON. This causes issues as the path is interpreted as starting with \ instead of / which is invalid per the swagger spec (paths must start with a /).

If you fix the / escape issue, the import should probably work.

@JonathanMontane
Copy link
Contributor

Additionally, the basePath should not be "" but "/" per the Swagger v2 spec.

@JonathanMontane
Copy link
Contributor

After further investigation, it seems that the library tv4 is the culprit here as it expects the JSON to be formatted as is standard on the web instead as per the JSON spec, and we have found a workaround for this issue (using JSON.stringify(JSON.parse(content)) before feeding it to tv4...)

This will be fixed in the next release of the SwaggerImporter. Thanks for the report.

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