I am getting an illegal argument exception related to Schema when using martian.test/respond-with-generated on an API including a 204 (no content) response.
It looks like this is because the handler response schema has a body value of nil, which cannot be handled by the generator generator.
A minimal example is below. Am I missing something in the API client or test setup?
(let [m (-> (martian-http/bootstrap-openapi "/tmp/martian-test.json")
(martian-test/respond-with-generated {:nil-body-response :success}))]
(martian/response-for m :nil-body-response))
;= Execution error (IllegalArgumentException) at schema.core/eval23004$fn$G (core.clj:110).
;= No implementation of method: :spec of protocol: #'schema.core/Schema found for class: nil
make-generator takes the response type (:success) and the response schemas from the Martian client. After filtering for responses in the appropriate status range, the filtered responses are mapped with schema-generators.generators/generator.
Calling (schema-generators.generators/generator nil), as happens when generating a body value generator for the response schema above, throws the illegal argument exception:
(schema-generators.generators/generator nil)
;= Execution error (IllegalArgumentException) at schema.core/eval23004$fn$G (core.clj:110).
;= No implementation of method: :spec of protocol: #'schema.core/Schema found for class: nil
Thanks for the excellent write-up. I think you're right, in that the lack of a body schema is making the generator choke. I will try to find time to address this soon.
Hi,
I am getting an illegal argument exception related to Schema when using
martian.test/respond-with-generated
on an API including a204 (no content)
response.It looks like this is because the handler response schema has a body value of
nil
, which cannot be handled by the generator generator.A minimal example is below. Am I missing something in the API client or test setup?
/tmp/martian-test.json
Looking at the trace brought me to
martian.test/make-generator
:make-generator
takes the response type (:success
) and the response schemas from the Martian client. After filtering for responses in the appropriate status range, the filtered responses are mapped withschema-generators.generators/generator
.The relevant response schemas:
Calling
(schema-generators.generators/generator nil)
, as happens when generating a body value generator for the response schema above, throws the illegal argument exception:Thanks for your time!