apiaryio / gavel.js

Validator of HTTP messages (JavaScript implementation)
MIT License
97 stars 22 forks source link

NaN type #16

Closed tu1ly closed 11 years ago

tu1ly commented 11 years ago

getting "No validator found for real data media type "NaN" and expected data media type "NaN"". error in results when "Unknown real body media type. Content-type header is "application/json" but body is not a parseble JSON."

tu1ly commented 11 years ago

snapshot25

ondrejsika commented 11 years ago

i have similar problem apiarybug

netmilk commented 11 years ago

Hi,

I finally manage to replicate it and it was probably caused by the Content-Type header with value containing semicolon (;) and additional information about character set e.g.:

Content-Type: application/json; charset=utf-8

Gavel was setting the JSON validator only for exact match with application/json. Now it takes the semicolon into the game, so it should work as we expect.

Adam

Almad commented 11 years ago

Well actually, application/json; charset=utf-8 is not a valid JSON MIME, see http://lucumr.pocoo.org/2013/7/19/application-mimetypes-and-encodings/

@netmilk but maybe it wouldn't be a bad idea to utilise https://github.com/broofa/node-mime