Skip to content

Commit

Permalink
support varied json types & jarray as query string
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Aug 8, 2021
1 parent 5a797bc commit b08c412
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/openapi/codegen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1231,11 +1231,25 @@ type
"""
result.add parseStmt """
proc queryString(query: JsonNode): string {.used.} =
proc toString(js: JsonNode): string =
case js.kind
of JNull: ""
of JInt: $(getInt js)
of JFloat: $(getFloat js)
of JBool: $(getBool js)
else: getStr js
if query.isNil: return ""
var qs: seq[KeyVal]
if query == nil:
return ""
for k, v in query.pairs:
qs.add (key: k, val: v.getStr)
if not v.isNil and v.kind == JArray:
if v.len == 0:
qs.add (key: k, val: "")
else:
for v in v.items:
qs.add (key: k, val: v.toString)
else:
qs.add (key: k, val: v.toString)
result = encodeQuery(qs)
proc hydratePath(input: JsonNode; segments: seq[PathToken]): Option[string] {.used.} =
Expand Down

0 comments on commit b08c412

Please sign in to comment.