URL query string format for JSON object as value

492 views
Skip to first unread message

SS

unread,
Aug 7, 2015, 6:15:47 AM8/7/15
to JSON Schema
Hello All,

I have recently started working on JSON Schema v4 and RESTfull API implementation.
We (team) as decided to use Swagger supported API description file as a center piece for the implementation.

I'm wondering to understand - is below URL a valid one?
http://localhost/v1/List?filter={"params":[{"operator":"ALL","clauses":[{"cmp":"=","filter_key":"status","filter_value":"0"}]}],"duration":{"type":"past","past":"month","range_start":"","range_end":""}}&secure=no

- I have gone through the RFC3986 but still not able to conclude. It seems valid because as per rfc -
------------
The following are two example URIs and their component parts:

         foo://example.com:8042/over/there?name=ferret#nose
         \_/   \______________/\_________/ \_________/ \__/
          |           |            |            |        |
       scheme     authority       path        query   fragment
          |   _____________________|__
         / \ /                        \
         urn:example:animal:ferret:nose

....

query       = *( pchar / "/" / "?" )

------------

- I also used this URL in browser and it is supporting that (means i'm getting it at the server side without any issue).

So, if above URL is valid then why i'm not allowed to define above GET method in swagger API document like below -

...
"in":"query",
"type":"object",
...

As per swagger specification v2.0 they are mentioning  -

--------------

If in is "body":

Field NameTypeDescription
schemaSchema ObjectRequired. The schema defining the type used for the body parameter.

If in is any value other than "body":

Field NameTypeDescription
typestringRequired. The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of "string""number""integer""boolean""array" or "file". Iftype is "file", the consumes MUST be either "multipart/form-data" or " application/x-www-form-urlencoded" and the parameter MUST be in"formData".
--------------

Please help to understand, is this a swagger v2.0 spec issue or JSON schema v4 or URL formation?

I want to create a JSON schema for the above URL "filter" JSON and want to use in swagger API description file.

Thank you.

Jason Desrosiers

unread,
Aug 8, 2015, 3:04:46 AM8/8/15
to JSON Schema, shashank....@gmail.com
This is a swagger issue, but I will contribute a couple observations.

1.  Yes, your example is a valid URL.  However, this is an unusual kind of thing to put into query parameter.  I'm not surprised you are having difficulty expressing it with swagger.

2.  The documentation you are referencing makes it clear that swagger recognizes only simple types for query parameters.  It would seem that the best you can do is declare it as a string and then parse it as JSON when it is processed.

3.  Swagger isn't very RESTful.  It is an RPC style description language.  REST is supposed to be an alternative to this style of architecture.  You many want to consider JSON Hyper Schema for future projects.  However, that is not to say that JSON Hyper Schema would have any easier a time expressing JSON in a query parameter than Swagger.
Reply all
Reply to author
Forward
0 new messages