question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TestServer inconsistency on "null" test

See original GitHub issue

Let’s take this file: https://github.com/Azure/autorest.testserver/blob/master/swagger/body-integer.json

And the int_getNull operation. Doing a call actually return no body with a 200: image

The Swagger explains that it produces “application/json”, but an empty content is not a valid JSON, meaning the Swagger does not reflect the RestAPI… Solution is to either change the testserver to put content-type “text/plain”, or to put the four characters null (valid JSON).

I try to tighten a little my deserialisation, just to start thinking about future XML parsing in Python, and this kind of details blocks me 😦

Not urgent, but should be addressed.

FYI @amarzavery

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
lmazuelcommented, Nov 29, 2017

@olydis Spec update https://tools.ietf.org/html/rfc7159

A JSON text is a serialized value. Note that certain previous specifications of JSON constrained a JSON text to be an object or an array. Implementations that generate only objects or arrays where a JSON text is called for will be interoperable in the sense that all implementations will accept these as conforming JSON texts.

A JSON value MUST be an object, array, number, or string, or one of the following three literal names:

  false null true
1reaction
olydiscommented, Sep 22, 2017

yep I wondered WTF that empty content instead of null is all about but the hard truth is that the C# generated code has encoded null as empty string since I got here, I have no clue why this was done like that. At this point, it would be a slightly unpredicatable breaking change to change that behavior, so not sure what we can do… but I agree 100% that the testserver should test for the right thing, even if that means C# tests have to be skipped or changed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Integration test for ASP.NET Core 6 web API throws System ...
Solution: This was due to the Microsoft.AspNetCore.Mvc.Testing package for the test project using the wrong version (it was using version 5.
Read more >
Route parameter with urlencoded slash. Inconsistency ...
Having a route parameter that includes a urlencoded / character produces inconsistent results between TestServer and Kestrel behavior.
Read more >
Testing - Spring
This chapter covers Spring's support for integration testing and best practices for unit testing. The Spring team advocates test-driven ...
Read more >
Testing an API In Memory in ASP.NET Core
This is long post that describes how to setup an in-memory test harness for testing an entire ASP.NET Core API with lots of...
Read more >
Should you unit-test API/MVC controllers in ASP.NET Core?
You could have a method argument that's impossible to bind to a request, and unit tests won't identify that. Effectively, you may be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found