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:
Ben Bierens 2024-03-26 16:12:15 +01:00 committed by GitHub
parent 4038eed3c9
commit 8378ac4dac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 7 deletions

View File

@ -60,7 +60,7 @@ proc formatManifestBlocks(node: CodexNodeRef): Future[JsonNode] {.async.} =
content.add(restContent)
await node.iterateManifests(formatManifest)
return %content
return %RestContentList.init(content)
proc retrieveCid(
node: CodexNodeRef,

View File

@ -42,6 +42,9 @@ type
cid* {.serialize.}: Cid
manifest* {.serialize.}: Manifest
RestContentList* = object
content* {.serialize.}: seq[RestContent]
RestNode* = object
nodeId* {.serialize.}: RestNodeId
peerId* {.serialize.}: PeerId
@ -67,6 +70,11 @@ type
quotaUsedBytes* {.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 =
RestContent(
cid: cid,

View File

@ -357,9 +357,8 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/DataList"
$ref: "#/components/schemas/DataList"
"400":
description: Invalid CID is specified
"404":
@ -632,6 +631,10 @@ paths:
responses:
"200":
description: Returns the Request ID as decimal string
content:
text/plain:
schema:
type: string
"400":
description: Invalid or missing Request ID
"404":

View File

@ -45,14 +45,14 @@ proc download*(client: CodexClient, cid: Cid, local = false): ?!string =
success response.body
proc list*(client: CodexClient): ?!seq[RestContent] =
proc list*(client: CodexClient): ?!RestContentList =
let url = client.baseurl & "/data"
let response = client.http.get(url)
if response.status != "200 OK":
return failure(response.status)
seq[RestContent].fromJson(response.body)
RestContentList.fromJson(response.body)
proc space*(client: CodexClient): ?!RestRepoStore =
let url = client.baseurl & "/space"

View File

@ -100,7 +100,7 @@ twonodessuite "Integration tests", debug1 = false, debug2 = false:
let list = client1.list().get
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":
let availability1 = client1.postAvailability(totalSize=1.u256, duration=2.u256, minPrice=3.u256, maxCollateral=4.u256).get