-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Definining URL-encoded JSON value #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you give an explicit example of what it would look like (not in a given language, but a raw request)? |
webron - thanks for your quick resonse. The POST data would be an encoded form of request={"key":"value"} which I believe would be request=3D%7B%22key%22%3A%22value%22%7D Thanks. |
Note that the object that is passed can be quite complex, and I have various definitions for the parameters that can be passed, it´s just that the json data is not passes as application/json, it´s multipart/form-data, with a key before the JSON value. |
The only way I can think of doing that is using the |
OK, thanks. I´ll look into that. And the parameters, how would I define them? I´m thinking about something like:
|
You can take a look at the petstore (http://petstore.swagger.io/v2/swagger.json) or the ones provides with the editor. There are plenty examples on how to define parameters, though if you have any problem let me know and I'll be happy to assist. |
Thanks. I had a look before, but couldn't manage it for this specific example - hence the post. I'll try again, though, and if I really can't, I'll come back to you. Thanks for your help. |
Perhaps I didn't understand the question there. Do you ask how to define a parameter in general or something more specific? |
It's specific to this example. There are two possible parameters, each of which are URL-encoded JSON objects/arrays. The objects/arrays have specific formats, and themselves have parameters defined for them, but are not at the 'top level', as would be the case if they were sent in application/json format. As such the two top-level parameters (json or requests) each take URL-encoded JSON objects/arrays, which themselves have parameters defined for them. Specifically, the 'json' parameter takes a single JSON object (which defines a single API action), whereas 'requests' takes an array of objects (i.e. a list of API actions). The issue I'm having is how to define this hierarchy of parameters. Is that any clearer? |
I should have picked up on it earlier, but you can't define a model for a form parameter. The most you can do is define it as a string. I believe this is one thing we may change in future versions of the spec, for form parameters only. |
Hmm, OK. Thanks. That's kind of what I thought might be the case. I guess I'm going to have to hack some existing tools. |
Is it not possible to define a schema for the inputs that themselves define schemas? (I'm guessing not from your response, I just wanted to check.) |
Only If you're asking whether you can define a schema that allows the definitions of schemas as a model, then you may be able to do that within some limitations. |
I'm not sure if I should put this in a different question, since it's not quite the same thing, but is it not possible then to define a schema and use $ref when the parameters are query or path parameters? |
No. You can't use schemas for query or path parameters. The reason is that you can't really define a mime type for these parameters. The mime type of the request affects the body of the request, but not anything around it. |
OK, thanks. |
Can we close this issue? |
Yeah - done. |
Is this still the case? |
Hi,
Is it possible to define a URL-encoded JSON value that has a name. e.g. the sent data is of type
multipart/form-data
And the POST data is a URL-encoded version of the following code (in PHP):
request=json_encode(array(...))
If it's not possible in the main spec, is there a hack to allow such forms?
Thanks.
The text was updated successfully, but these errors were encountered: