smollweide / node-mock-server

File based Node REST API mock server
MIT License
255 stars 65 forks source link

request body validation for POST requests ?? #81

Closed skalyanapu-mtuity closed 6 years ago

skalyanapu-mtuity commented 6 years ago

Hi, Can we validate request body for POST requests ,For instance, If I'm sending XML data to POST method, I want to validate the presence of mandatory elements presence in post XML data to the API ?? If mandatory XML elements were missing I should throw exception accordingly, can we such validations ??

Regards.

smollweide commented 6 years ago

Hi, XML validations are not included currently. I will not include them in v0.x.x but version v1.x.x will have an plug-in System which allow you to add features like the described one.

skalyanapu-mtuity commented 6 years ago

Okay, thanks for the information !!!

skalyanapu-mtuity commented 6 years ago

"XML validations are not included currently." -- keeping XML content validations apart , does "node-mock-server" also supports "application/xml" or "text/xml" content-type now i.e XML request and response methods along with JSON ??

smollweide commented 6 years ago

Hi @skalyanapu-mtuity, yes node-mock-server supports xml. You just need to add an xml file in correct directory (see link folder-structure) and select them in the ui (see link expected-response).

skalyanapu-mtuity commented 6 years ago

Hello @smollweide Thank you! Yes it was working with XML , but I'm facing issue with error response,

If I create success.xml and select it as the expected response from UI by setting Content-Type header to "application/xml" it was working fine , similarly if create error.xml and set it as expected response from UI , then content-type was being set to application/json automatically though I set it to application/xml manually ? can you suggest what i'm doing wrong ?

Regards.

smollweide commented 6 years ago

Hi @skalyanapu-mtuity, you are right this is a bug. I will fix it.

smollweide commented 6 years ago

Published v0.19.1