apideck-libraries / portman

Port OpenAPI Specs to Postman Collections, inject test suite and run via Newman 👨🏽‍🚀
http://getportman.com/
Apache License 2.0
636 stars 59 forks source link

Add ability to send files from newman #387

Open proDOOMman opened 2 years ago

proDOOMman commented 2 years ago

If openApi schema has "binary" content ("schema": {"type": "string","format": "binary"}), it will be translated into postman collection with body:

"body": {
"mode": "file"
},

To send this file from newman, I should change collection to:

"body": {
"mode": "file", "file": {"src": "files/MyFile.bin"}
},

But I can't find any way to do this. "Globals -> portmanReplacement" can't help me with such replacement.

thim81 commented 2 years ago

@proDOOMman, Question: Do you want to overwrite the "file" elements, with a custom "file": {"src": "files/MyFile.bin"} OR do you expect this to be part of the conversion?

thim81 commented 1 year ago

@proDOOMman Any feedback from you, that we can look into?

wernermorgenstern commented 1 year ago

@thim81 , I need this functionality too. Can I just specify a specific file? Or make it part of the conversion?

Lars-Brebels-92 commented 1 year ago

For anyone that still needs this. I did the following: In the newman script:

globals:{
  "values": [
    {
        "key": "filePathSystem",
        "value": `${process.cwd().toString()}`,
        "type": "text",
        "enabled": true
    }
  ]
  }

Then in the prequest script:

filePathSystem = pm.globals.get('filePathSystem');
pm.request.body = {
    mode: "file",
    file: filePathSystem+"/PathFromRunFolderToFile/File.json"
}