Open scflode opened 5 years ago
@scflode I think the error is related to the :file
type used on the body parameter.
It is a valid type for swagger 2.0, but not for Json Schema (https://swagger.io/specification/v2/#dataTypeType)
Primitive data types in the Swagger Specification are based on the types supported by the JSON-Schema Draft 4. Models are described using the Schema Object which is a subset of JSON Schema Draft 4.
An additional primitive data type "file" is used by the Parameter Object and the Response Object to set the parameter type or the response as being a file.
As a workaround perhaps the :file
type should be internally replaced with :binary
for validation purposes in lib/phoenix_swagger/validator.ex
?
@scflode I hit the same issue, and worked around it by using :formData
instead of :body
for this particular endpoint
I'm not too familiar with this package, or swagger in general, so I'm not sure if this is even semantically correct. But it sort of works for now
I am not sure if this is related to this library or more to the
ex_json_schema
.If you have an endpoint with a
multipart/form-data
file upload everything works fine when the validation is disabled. If the validation gets enabled (e.g.PhoenixSwagger.Validator.parse_swagger_schema/1
called inMyApp.Application.start/2
) the application cannot start anymore.The error is as follows:
It looks like either I am doing something silly or the JSON schema library cannot cope with the type
:file
being set in theswagger_path
macro call. If the type is anything else (e.g.:string
) it works.For reproduction I set up a small sample app with the different steps as separate commits (boilerplate, adding Swagger lib, enabling validation): https://github.com/scflode/ex_swagger_playground
It would be cool if someone can have a look and maybe show me a workaround or in the best case come up with a fix (or an idea therefore).