Closed shubhaguha closed 4 years ago
The same goes for OpenAPIv2. Unfortunately this PR breaks many tests and it also does not have any new tests, so I cannot accept it. I hope to address this in the new API I'm working on in #160 and json-validator#189.
Can you say a bit more about why you need this change? Maybe there's another way to solve this with the current functionality.
The same goes for OpenAPIv2. Unfortunately this PR breaks many tests and it also does not have any new tests, so I cannot accept it. I hope to address this in the new API I'm working on in #160 and json-validator#189.
Can you say a bit more about why you need this change? Maybe there's another way to solve this with the current functionality.
Sorry for the delayed response. I haven't had a chance to dive deeper into the test failures yet and somehow your comment didn't appear to me until just now.
The reason is that I need to implement an API endpoint that takes a file in the request body. The file can be one of many types (text, xml, json, pdf, etc.) which in OpenAPI 3.0 can be denoted like so:
requestBody:
content:
*/*:
schema:
type: string
format: binary
But with the latest version of this plugin, my application invalidates the request by trying to force this raw body to json.
Currently, my workaround is in the controller sub:
sub process {
my $c = shift();
$c->req()->{json} = $c->req()->body();
my $self = $c->openapi()->valid_input() or return;
EDIT: But even this workaround does not fully work because the request body seems to be stripped of all newline characters. I have not yet tracked down where in the code this happens.
Another OpenAPI 3 reference, about how to specify file types: https://swagger.io/docs/specification/data-models/data-types/#file
I'm closing this PR, since no new tests or code has been provided.
In OpenAPI 3.0, you can specify any content type for the request body, not just JSON.
https://swagger.io/docs/specification/describing-request-body/