mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-10 10:46:11 +03:00
CHANGELOG_BEGIN (#3969)
- [JSON API - Experimental] When contract is not found, ``/contracts/lookup`` endpoint returns ``{"status":200,"result":null}`` instead of ``{"status":200,"result":{}}``. This is consistent with how DAML-LF JSON Encoding spec treats Optional. CHANGELOG_END
This commit is contained in:
parent
a8b4a84b08
commit
29d5995454
@ -152,7 +152,7 @@ class Endpoints(
|
||||
): ET[Option[domain.ActiveContract[LfValue]]]
|
||||
|
||||
jsVal <- either(
|
||||
ac.cata(x => lfAcToJsValue(x).leftMap(e => ServerError(e.shows)), \/-(JsObject()))
|
||||
ac.cata(x => lfAcToJsValue(x).leftMap(e => ServerError(e.shows)), \/-(JsNull))
|
||||
): ET[JsValue]
|
||||
|
||||
} yield jsVal
|
||||
|
@ -536,6 +536,25 @@ abstract class AbstractHttpServiceIntegrationTest
|
||||
}: Future[Assertion]
|
||||
}
|
||||
|
||||
"contracts/lookup returns {status:200, result:null} when contract is not found" in withHttpService {
|
||||
(uri, _, _) =>
|
||||
val owner = domain.Party("Alice")
|
||||
val accountNumber = "abc123"
|
||||
val locator = domain.EnrichedContractKey(
|
||||
domain.TemplateId(None, "Account", "Account"),
|
||||
JsArray(JsString(owner.unwrap), JsString(accountNumber))
|
||||
)
|
||||
postContractsLookup(locator, uri.withPath(Uri.Path("/contracts/lookup"))).flatMap {
|
||||
case (status, output) =>
|
||||
status shouldBe StatusCodes.OK
|
||||
assertStatus(output, StatusCodes.OK)
|
||||
output
|
||||
.asJsObject(s"expected JsObject, got: $output")
|
||||
.fields
|
||||
.get("result") shouldBe Some(JsNull)
|
||||
}: Future[Assertion]
|
||||
}
|
||||
|
||||
"contracts/lookup by contractKey" in withHttpService { (uri, encoder, decoder) =>
|
||||
val owner = domain.Party("Alice")
|
||||
val accountNumber = "abc123"
|
||||
@ -803,9 +822,8 @@ abstract class AbstractHttpServiceIntegrationTest
|
||||
|
||||
output
|
||||
.asJsObject(errorMsg)
|
||||
.getFields("result")
|
||||
.headOption
|
||||
.getOrElse(fail(errorMsg))
|
||||
.fields
|
||||
.getOrElse("result", fail(errorMsg))
|
||||
.asJsObject(errorMsg)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user