Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and improve Spray JSON docs #330

Merged
merged 6 commits into from
Sep 20, 2016
Merged

Fix and improve Spray JSON docs #330

merged 6 commits into from
Sep 20, 2016

Conversation

jonas
Copy link
Member

@jonas jonas commented Sep 18, 2016

  • CompactPrinter is now the default so change the JSON printer example to mention PrettyPrinter
  • Replace project version in the SBT snippet.
  • Reformat Markdown

NOTE: the last point is something we might want to raise upstream in Paradox, to see if we can make it optional whether line breaks are honours in the Markdown rendering. Alternatively, we can reformat all docs to not use new lines inside paragraphs.

@akka-ci
Copy link

akka-ci commented Sep 18, 2016

Can one of the repo owners verify this patch?


// format: OFF
val route =
get {
pathSingleSlash {
complete {
// should complete with spray.json.JsValue = {"name":"akka","id":42}
CompactPrintedItem("akka", 42) // will render as JSON
// should complete with spray.json.JsValue = { "name": "akka", "id": 42 }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, I didn't actually test this.

Copy link
Member

@ktoso ktoso Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR pretty is:

{ 
  "name": "akka",
  "id": 42
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add

Get("/") ~> route ~> check {
  responseAs[String] shouldEqual """..."""
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, added a test to the example.

@ktoso
Copy link
Member

ktoso commented Sep 19, 2016

OK TO TEST

Copy link
Member

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good changes overall, thanks. LGTM

```sbt
"com.typesafe.akka" %% "akka-http-spray-json-experimental" % "$project.version$"`
```
@@@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


```scala
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good


// format: OFF
val route =
get {
pathSingleSlash {
complete {
// should complete with spray.json.JsValue = {"name":"akka","id":42}
CompactPrintedItem("akka", 42) // will render as JSON
// should complete with spray.json.JsValue = { "name": "akka", "id": 42 }
Copy link
Member

@ktoso ktoso Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR pretty is:

{ 
  "name": "akka",
  "id": 42
}

@ktoso
Copy link
Member

ktoso commented Sep 19, 2016

@akka/akka-http-team, @jrudolph please feel free to LGTM and merge once PR hits 2 LGTMs (anyone within http-team is welcome to do so) :-)

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed validating PR that is currently being validated by Jenkins labels Sep 19, 2016
@akka-ci
Copy link

akka-ci commented Sep 19, 2016

Test PASSed.

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed tested PR that was successfully built and tested by Jenkins validating PR that is currently being validated by Jenkins labels Sep 19, 2016
@akka-ci
Copy link

akka-ci commented Sep 19, 2016

Test FAILed.

@jonas
Copy link
Member Author

jonas commented Sep 19, 2016

The failure looks unrelated:

[info]   - the config setting (chunked entity) *** FAILED ***
[info]     null did not equal EntityStreamSizeException: actual entity size (None) exceeded content length limit (10 bytes)! You can configure this by setting `akka.http.[server|client].parsing.max-content-length` or calling `HttpEntity.withSizeLimit` before materializing the dataBytes stream.,
[info]     inside HttpResponse(200 OK,List(),HttpEntity.Chunked(application/octet-stream),HttpProtocol(HTTP/1.1)) (LowLevelOutgoingConnectionSpec.scala:564)

@jypma
Copy link
Member

jypma commented Sep 19, 2016

Mmm, we just had the exact same test failure over at #323. Coincidence? I think NOT! :)

@jonas
Copy link
Member Author

jonas commented Sep 20, 2016

Is there a way to ask @akka-ci to rebuild?

@ktoso
Copy link
Member

ktoso commented Sep 20, 2016

PLS BUILD

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins labels Sep 20, 2016
@akka-ci
Copy link

akka-ci commented Sep 20, 2016

Test FAILed.

@jonas
Copy link
Member Author

jonas commented Sep 20, 2016

Thanks. Now it is failing with the error mentioned in #298:

[info]   - a 200 response to a HEAD request *** FAILED ***
[info]     java.util.concurrent.TimeoutException: Futures timed out after [500 milliseconds]
[info]     at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219)
[info]     at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223)
[info]     at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:190)
[info]     at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53)
[info]     at scala.concurrent.Await$.result(package.scala:190)
[info]     at akka.http.impl.engine.parsing.ResponseParserSpec$Test.collectBlocking(ResponseParserSpec.scala:321)

and

[info] - must not reset the connection when no data are flowing and the connection is closed from the client *** FAILED ***
[info]   java.lang.AssertionError: assertion failed: expected OnNext(TextMessage.Strict(hello)), found OnComplete
[info]   at scala.Predef$.assert(Predef.scala:170)
[info]   at akka.testkit.TestKitBase$class.expectMsg_internal(TestKit.scala:388)
[info]   at akka.testkit.TestKitBase$class.expectMsg(TestKit.scala:364)
[info]   at akka.testkit.TestKit.expectMsg(TestKit.scala:814)
[info]   at akka.stream.testkit.TestSubscriber$ManualProbe.expectNext(StreamTestKit.scala:280)
[info]   at akka.http.impl.engine.ws.WebSocketIntegrationSpec$$anonfun$1$$anonfun$apply$mcV$sp$2$$anonfun$apply$3.apply(WebSocketIntegrationSpec.scala:123)
[info]   at akka.http.impl.engine.ws.WebSocketIntegrationSpec$$anonfun$1$$anonfun$apply$mcV$sp$2$$anonfun$apply$3.apply(WebSocketIntegrationSpec.scala:68)
[info]   at akka.stream.testkit.Utils$.assertAllStagesStopped(Utils.scala:25)
[info]   at akka.http.impl.engine.ws.WebSocketIntegrationSpec$$anonfun$1$$anonfun$apply$mcV$sp$2.apply(WebSocketIntegrationSpec.scala:68)
[info]   at akka.http.impl.engine.ws.WebSocketIntegrationSpec$$anonfun$1$$anonfun$apply$mcV$sp$2.apply(WebSocketIntegrationSpec.scala:68)
[info]   ...

@ktoso
Copy link
Member

ktoso commented Sep 20, 2016

That's too tight timeouts IMO,

By default the CompactPrinter is used, so change the example to show how
to use the PrettyPrinter.
…kka#318)

This allows to use `@@vars` to replace the project version in the SBT
snippet.
Paradox currently honours new lines which breaks formatting.
@jonas
Copy link
Member Author

jonas commented Sep 20, 2016

Rebased to see if this will trigger a rebuild now that jenkins.akka.io seems more quiet.

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins labels Sep 20, 2016
@akka-ci
Copy link

akka-ci commented Sep 20, 2016

Test PASSed.

@jonas
Copy link
Member Author

jonas commented Sep 20, 2016

🎱

@ktoso
Copy link
Member

ktoso commented Sep 20, 2016

LGTM, thanks!

@ktoso ktoso merged commit 10b3ca2 into akka:master Sep 20, 2016
@jonas jonas deleted the json-support-docs branch September 21, 2016 00:04
jedrekn pushed a commit to jedrekn/akka-http that referenced this pull request Nov 17, 2016
* =doc Use reference-style links for linking to the spray-json site

* =doc Create section on changing the JSON format and reflect reality

By default the CompactPrinter is used, so change the example to show how
to use the PrettyPrinter.

* =doc Rewrite the spray-json section to spell out the list of steps (akka#318)

This allows to use `@@vars` to replace the project version in the SBT
snippet.

* =doc Format spray JSON docs on single lines

Paradox currently honours new lines which breaks formatting.

* =doc Bring back "automatic support for ..."

* Verify the pretty printed JSON output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants