GET parameters from model definition

46 views
Skip to first unread message

dishwashweb

unread,
Apr 15, 2014, 5:32:24 AM4/15/14
to swagger-sw...@googlegroups.com
Hi there

I am using swagger-node-express and got separate files for models, and resources. The goal is to provide a GET and POST method for the same model.

For the POST method, its easy to provide the model structure as parameters like this within the resource spec:

 parameters: [{
"name": "body",
"description": "Search body object that needs to be defined",
"required": true,
"type": "searchCars",
"paramType": "body"
}],

Which works great and the structure is provided and can be taken over into the request-body within the frontend docs.

The model is defined/exported:
module.exports = {
    "searchCars":{
        "id":"searchCars",
        "required": ["page", "pageSize"],
        "properties":{
            "Doors":{
              "type":"integer",
              "format": "int32",
              "description": "Amount of doors",
              "minimum": "0",
              "maximum": "7"
            },
            "DrivingLicense":{
                "type":"integer",
                "format": "int32",
                "description": "DrivingLicence ??? ",
            },

The problem arises when trying the same thing for the GET method. To simply align the model definition as parameters[{}]  and get any related queryparams autocreated as select/input-fields in the UI.

Is this out of the box or am i simply just missing something?
thanks for any feedback & cheers

tony tam

unread,
Apr 15, 2014, 11:40:54 AM4/15/14
to swagger-sw...@googlegroups.com
Hi, I think your answer is in the sample app.  Can you look here:

dishwashweb

unread,
Apr 16, 2014, 4:35:40 AM4/16/14
to swagger-sw...@googlegroups.com
Hi Tony

Thanks for getting back to me.
I checked out the exaple app and was not able to find a workaround for this scenario:

one model definition
one GET method for same model with req.param.values
one POST method for same model with req.body.values

to have the docs input/select fields auto created for the GET method without having to re-define the spec.parameters section.

cheers

tony tam

unread,
Apr 16, 2014, 11:59:22 AM4/16/14
to swagger-sw...@googlegroups.com
Oh do you mean you want to send a complex model as a GET parameter?  If so, that's not really supported.  You can only pass in headers, query params, path params, etc.

colin rimann

unread,
Apr 17, 2014, 4:56:39 AM4/17/14
to swagger-sw...@googlegroups.com
Ok no troubles. was just wondering if there are approaches to do so.
thanks anyway. 


--
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/mO48f9h88U4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
always washes your dishes clean. always.
Reply all
Reply to author
Forward
0 new messages