Openapi mismatches (#754)
* Aligns response with openapi spec * Fixes json serialization for local content response * Review comments by Mark * Fixes missed rename * Removes array type for dataList
This commit is contained in:
parent
4038eed3c9
commit
8378ac4dac
|
@ -60,7 +60,7 @@ proc formatManifestBlocks(node: CodexNodeRef): Future[JsonNode] {.async.} =
|
||||||
content.add(restContent)
|
content.add(restContent)
|
||||||
|
|
||||||
await node.iterateManifests(formatManifest)
|
await node.iterateManifests(formatManifest)
|
||||||
return %content
|
return %RestContentList.init(content)
|
||||||
|
|
||||||
proc retrieveCid(
|
proc retrieveCid(
|
||||||
node: CodexNodeRef,
|
node: CodexNodeRef,
|
||||||
|
|
|
@ -42,6 +42,9 @@ type
|
||||||
cid* {.serialize.}: Cid
|
cid* {.serialize.}: Cid
|
||||||
manifest* {.serialize.}: Manifest
|
manifest* {.serialize.}: Manifest
|
||||||
|
|
||||||
|
RestContentList* = object
|
||||||
|
content* {.serialize.}: seq[RestContent]
|
||||||
|
|
||||||
RestNode* = object
|
RestNode* = object
|
||||||
nodeId* {.serialize.}: RestNodeId
|
nodeId* {.serialize.}: RestNodeId
|
||||||
peerId* {.serialize.}: PeerId
|
peerId* {.serialize.}: PeerId
|
||||||
|
@ -67,6 +70,11 @@ type
|
||||||
quotaUsedBytes* {.serialize.}: uint
|
quotaUsedBytes* {.serialize.}: uint
|
||||||
quotaReservedBytes* {.serialize.}: uint
|
quotaReservedBytes* {.serialize.}: uint
|
||||||
|
|
||||||
|
proc init*(_: type RestContentList, content: seq[RestContent]): RestContentList =
|
||||||
|
RestContentList(
|
||||||
|
content: content
|
||||||
|
)
|
||||||
|
|
||||||
proc init*(_: type RestContent, cid: Cid, manifest: Manifest): RestContent =
|
proc init*(_: type RestContent, cid: Cid, manifest: Manifest): RestContent =
|
||||||
RestContent(
|
RestContent(
|
||||||
cid: cid,
|
cid: cid,
|
||||||
|
|
|
@ -357,9 +357,8 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: array
|
$ref: "#/components/schemas/DataList"
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/DataList"
|
|
||||||
"400":
|
"400":
|
||||||
description: Invalid CID is specified
|
description: Invalid CID is specified
|
||||||
"404":
|
"404":
|
||||||
|
@ -632,6 +631,10 @@ paths:
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Returns the Request ID as decimal string
|
description: Returns the Request ID as decimal string
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
"400":
|
"400":
|
||||||
description: Invalid or missing Request ID
|
description: Invalid or missing Request ID
|
||||||
"404":
|
"404":
|
||||||
|
|
|
@ -45,14 +45,14 @@ proc download*(client: CodexClient, cid: Cid, local = false): ?!string =
|
||||||
|
|
||||||
success response.body
|
success response.body
|
||||||
|
|
||||||
proc list*(client: CodexClient): ?!seq[RestContent] =
|
proc list*(client: CodexClient): ?!RestContentList =
|
||||||
let url = client.baseurl & "/data"
|
let url = client.baseurl & "/data"
|
||||||
let response = client.http.get(url)
|
let response = client.http.get(url)
|
||||||
|
|
||||||
if response.status != "200 OK":
|
if response.status != "200 OK":
|
||||||
return failure(response.status)
|
return failure(response.status)
|
||||||
|
|
||||||
seq[RestContent].fromJson(response.body)
|
RestContentList.fromJson(response.body)
|
||||||
|
|
||||||
proc space*(client: CodexClient): ?!RestRepoStore =
|
proc space*(client: CodexClient): ?!RestRepoStore =
|
||||||
let url = client.baseurl & "/space"
|
let url = client.baseurl & "/space"
|
||||||
|
|
|
@ -100,7 +100,7 @@ twonodessuite "Integration tests", debug1 = false, debug2 = false:
|
||||||
let list = client1.list().get
|
let list = client1.list().get
|
||||||
|
|
||||||
check:
|
check:
|
||||||
[cid1, cid2].allIt(it in list.mapIt(it.cid))
|
[cid1, cid2].allIt(it in list.content.mapIt(it.cid))
|
||||||
|
|
||||||
test "node handles new storage availability":
|
test "node handles new storage availability":
|
||||||
let availability1 = client1.postAvailability(totalSize=1.u256, duration=2.u256, minPrice=3.u256, maxCollateral=4.u256).get
|
let availability1 = client1.postAvailability(totalSize=1.u256, duration=2.u256, minPrice=3.u256, maxCollateral=4.u256).get
|
||||||
|
|
Loading…
Reference in New Issue