luckymarmot / Paw-SwaggerImporter

Swagger/OpenAPI 2.0 Importer for Paw
https://paw.cloud/extensions/SwaggerImporter
MIT License
38 stars 10 forks source link

Import failing #31

Open wimleers opened 7 years ago

wimleers commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

JonathanMontane commented 7 years ago

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.