oliyh / martian

The HTTP abstraction library for Clojure/script, supporting OpenAPI, Swagger, Schema, re-frame and more
MIT License
526 stars 45 forks source link

Cannot convert OpenAPI type to schema #103

Closed evilsneer closed 3 years ago

evilsneer commented 3 years ago

Hi! I try to use with 0.1.15-SNAPSHOT jira swagger

& getting error

#error {
   :message "Cannot convert OpenAPI type to schema", 
   :data {
      :definition 
         {:description "Details of the user who attached the file.", 
         :readOnly true, 
         :allOf [{:$ref "#/components/schemas/User"}]}}}

guess it is because :type is missing? Im assuming "jira" means it is array.

but! version 0.1.12 seems to works fine - I used it with this swagger some time ago; at least, it loads and allows to call methods (some of, not checked it all)

oliyh commented 3 years ago

Hi,

Thanks for reporting this, I suspect it's more likely that Martian is more eagerly consuming more of the schema than it used to, rather than a regression. Either way, I will make a test based on this and ensure it works.

Thanks

oliyh commented 3 years ago

Hi,

This was a difference between the OpenAPI v3 parsing and the Swagger v2 parsing - the latter used to return s/Any for things it didn't understand, whereas the new code throws this error. I've updated it to return s/Any as well so that this schema now parses.

You are correct in that it fails because there was no type, instead the allOf should have this behaviour:

The OpenAPI Specification allows combining and extending model definitions using the allOf property of JSON Schema, in effect offering model composition. allOf takes an array of object definitions that are validated independently but together compose a single object. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#composition-and-inheritance-polymorphism

I have created another issue for supporting that in #107 but I will close this one for now.

oliyh commented 3 years ago

This is available in 0.1.16