stubby4node icon indicating copy to clipboard operation
stubby4node copied to clipboard

Default file?

Open ValeryIvanov opened this issue 7 years ago • 5 comments

I have to create a fallback response for some endpoints and I currently use body option for that. But those responses are quite long (SOAP responses) and it is quite painful to add them to json config file.

Would it be possible to add a default file option so that I could externalise this default response for better readability?

Thanks!

ValeryIvanov avatar Jun 28 '17 08:06 ValeryIvanov

You can use the file option for the response so that you aren't writing SOAP in json or yaml

mrak avatar Jun 29 '17 20:06 mrak

I am using. I route to correct response file, but if it is not found then body response is used. Only thing is that body response may be long and would be good if that could be file as well.

ValeryIvanov avatar Jun 30 '17 06:06 ValeryIvanov

It sounds like you want the fallback to your non-existent file option to also be a file instead of just the regular body option?

mrak avatar Jul 12 '17 03:07 mrak

Yes! This is how I use it now

    "response": {
      "status": 200,
      "file": "data/some_pattern_file_<% post[2] %>_<% post[1] %>.xml",
      "body": "<soapenv:Envelope some really long xml response here... it is really long and ugly believe me :D"
    }

and this is how I really want to use

    "response": {
      "status": 200,
      "file": "data/some_pattern_file_<% post[2] %>_<% post[1] %>.xml",
      "body": "data/default.xml"
    }

ValeryIvanov avatar Aug 07 '17 08:08 ValeryIvanov

I'll accept a pull request that allows file: to be a String or Array of filepaths in order of fall-back precedence.

response:
  status: 200
  file:
    - "first/file.json"
    - "second/file.json"

mrak avatar Aug 08 '17 02:08 mrak