civisanalytics / swagger-diff

Utility for comparing two Swagger specifications.
BSD 3-Clause "New" or "Revised" License
264 stars 32 forks source link

Diff fails on identical or very similar schemas #25

Closed zam17 closed 8 years ago

zam17 commented 8 years ago

Hello,

I'm getting a failure when comparing two schemas that are identical or very similar.

I'm attaching two schemas that are very similar: swagger1.json and swagger2.json I've tried running the following commands: 1) swagger-diff swagger1.json swagger1.json 2) swagger-diff swagger1.json swagger2.json

In both cases I'm getting a following error: "C:/Ruby21/lib/ruby/gems/2.1.0/gems/swagger-diff-1.0.5/lib/swagger/diff/specifica tion.rb:109:in schema': undefined methodallOf' for nil:NilClass (NoMethodErro r)'

swaggerFiles.zip

jeffreyc commented 8 years ago

Thank you for your feedback!

I looked at swagger1.json, and the specification appears to be incomplete. You have references ($ref keys) to #/definitions/Map┬лstring,object┬╗, but that doesn't appear to be defined anywhere. Swagger::Diff parses definitions recursively, and is failing when it attempts to find the missing definition.

We should probably handle that error in a way that makes it clear what's going wrong, but I think you can resolve your issue by making sure all references are defined. Please let us know if that doesn't resolve your issue, or if you have additional feedback!

zam17 commented 8 years ago

Thank you very much for help, I've resolved the issue.