ah-swagger-plugin icon indicating copy to clipboard operation
ah-swagger-plugin copied to clipboard

question from sanmoy27

Open supamii opened this issue 8 years ago • 8 comments

@sanmoy27

In post call I have there is a field named field1 which is mandatory to be provided in the body,which is mentioned as inputs field1:{required: true} but in swagger this input field is going as query parameter. When I am mentioning it in model schema it is going in body as well as quey parameters. I want to mention only in body not as query parameters

supamii avatar Aug 08 '16 18:08 supamii

Also I have put call in order to upload a file,I cannot change the content-type to applucation/binary instead of application/json and also the option to choose file is not appearing.Please help

sanmoy27 avatar Aug 08 '16 18:08 sanmoy27

Also I have put call in order to upload a file,I cannot change the content-type to applucation/binary instead of application/json and also the option to choose file is not appearing.Please help

I believe that uploads are fairly limited (buggy) with the version of swagger that is used. You'll just have to settle for POSTMAN/etc in the meanwhile.

supamii avatar Aug 08 '16 18:08 supamii

When I am mentioning it in model schema it is going in body as well as quey parameters. I want to mention only in body not as query parameters

Can you provide a more detailed example of how exactly you are defining your parameters?

supamii avatar Aug 08 '16 18:08 supamii

I dont have any query parameters,I just have body in my POST call { "field1":"string" } and my action is like this /api/analytics/jobs POST call In swagger it is appearing like /api/analytics/jobs?field=xyz

I just want.to pass this field only in body

sanmoy27 avatar Aug 08 '16 18:08 sanmoy27

Yes I know multipart form upload is buggy in swagger so for now is it possible to bring the choose file option field in swagger

sanmoy27 avatar Aug 08 '16 18:08 sanmoy27

exports.createTask = { name: 'createTask', description: 'It will create a Task and will return an id in reponse', summary: 'It will create a Task and will return an id in reponse', inputs: { jobName: { required: true } }, responseSchemas: { // By default set this 200 property to provide a sample response in the form of a JSON schema // object. Since schemas can get pretty bulky, consider requiring a file instead of having // everything in-line. E.g. '200': require('myResponseSchema.js') // // It's also possible to automate schema generation with json-schema-generator with json-patch. '200': { description: 'Sample http 200 response', schema: { type: 'object', properties: { 'jobName': { type: 'string' }, 'jobId': { type: 'string' }, 'createdTime': { type: 'integer' }, 'isCron': { type: 'boolean' }, 'jobState': { type: 'string' }, 'isReadyToRun': { type: 'boolean' }, 'cronTime': { type: 'integer' }, 'scheduleStatus': { type: 'string' }, 'scheduleAt': { type: 'integer' }, 'counts': { type: 'integer' }, 'startAt': { type: 'integer' }, 'endAt': { type: 'integer' } } } } }, modelSchema: { jobName: { type: 'string' } },
run: function(api, data, next){

    var apiKey = data.connection.rawConnection.req.headers['x-api-key'];
    api.taskController.addTask(data.params.jobName,apiKey, function(error, success){
        if(error)
            next(error);
        else {
            data.response.success = success;
            next(error, success);
        }
    });

}

};

sanmoy27 avatar Aug 09 '16 07:08 sanmoy27

In post call I have there is a field named field1 which is mandatory to be provided in the body,which is mentioned as inputs field1:{required: true} but in swagger this input field is going as query parameter. When I am mentioning it in model schema it is going in body as well as quey parameters. I want to mention only in body not as query parameters

sanmoy27 avatar Oct 14 '16 08:10 sanmoy27

latest version of swagger will resolve the above issue

sanmoy27 avatar Dec 18 '16 11:12 sanmoy27