Skip to content

Commit

Permalink
fix request models sequences and arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethosa committed Oct 26, 2024
1 parent cac77f0 commit 75e27d7
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/happyx/ssr/request_models.nim
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,17 @@ proc modelImpl(modelName: NimNode, enableOptions: bool, options: seq[string], ge
modelFields[$modelName].add(newStmtList(argName.toStrLit, argType.toStrLit, newLit(true)))
let argStr = $argType.toStrLit
if argStr.toLower notin builtinTypes and argType.typeKind != ntyNone:
let typeImpl = argType.getTypeImpl()[1].getImpl
if typeImpl[2].kind == nnkEnumTy:
let name = typeImpl[0].toStrLit
modelFields[$name] = newStmtList()
modelFieldsGenerics[$name] = newLit(true)
for i in 1..<typeImpl[2].len:
if typeImpl[2][i].len == 2:
modelFields[$name].add(newStmtList(typeImpl[2][i][0].toStrLit, typeImpl[2][i][1]))
else:
modelFields[$name].add(newStmtList(typeImpl[2][i].toStrLit, typeImpl[2][i].toStrLit))
if argType.getTypeImpl()[1].kind == nnkSym:
let typeImpl = argType.getTypeImpl()[1].getImpl
if typeImpl[2].kind == nnkEnumTy:
let name = typeImpl[0].toStrLit
modelFields[$name] = newStmtList()
modelFieldsGenerics[$name] = newLit(true)
for i in 1..<typeImpl[2].len:
if typeImpl[2][i].len == 2:
modelFields[$name].add(newStmtList(typeImpl[2][i][0].toStrLit, typeImpl[2][i][1]))
else:
modelFields[$name].add(newStmtList(typeImpl[2][i].toStrLit, typeImpl[2][i].toStrLit))
if argStr.toLower() != "formdataitem":
# JSON raw data
asgnStmt.add(newNimNode(nnkIfStmt).add(
Expand Down Expand Up @@ -267,16 +268,17 @@ proc modelImpl(modelName: NimNode, enableOptions: bool, options: seq[string], ge
modelFields[$modelName].add(newStmtList(argName.toStrLit, argType.toStrLit))
let argStr = $argType.toStrLit
if argStr.toLower notin builtinTypes and argType.typeKind != ntyNone:
let typeImpl = argType.getTypeImpl()[1].getImpl
if typeImpl[2].kind == nnkEnumTy:
let name = typeImpl[0].toStrLit
modelFields[$name] = newStmtList()
modelFieldsGenerics[$name] = newLit(true)
for i in 1..<typeImpl[2].len:
if typeImpl[2][i].len == 2:
modelFields[$name].add(newStmtList(typeImpl[2][i][0].toStrLit, typeImpl[2][i][1]))
else:
modelFields[$name].add(newStmtList(typeImpl[2][i].toStrLit, typeImpl[2][i].toStrLit))
if argType.getTypeImpl()[1].kind == nnkSym:
let typeImpl = argType.getTypeImpl()[1].getImpl
if typeImpl[2].kind == nnkEnumTy:
let name = typeImpl[0].toStrLit
modelFields[$name] = newStmtList()
modelFieldsGenerics[$name] = newLit(true)
for i in 1..<typeImpl[2].len:
if typeImpl[2][i].len == 2:
modelFields[$name].add(newStmtList(typeImpl[2][i][0].toStrLit, typeImpl[2][i][1]))
else:
modelFields[$name].add(newStmtList(typeImpl[2][i].toStrLit, typeImpl[2][i].toStrLit))
if ($argType.toStrLit).toLower() != "formdataitem":
# JSON raw data
asgnStmt.add(newNimNode(nnkIfStmt).add(
Expand Down

0 comments on commit 75e27d7

Please sign in to comment.