Skip to content

Commit

Permalink
3.1.5: add nosink on validator, up reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Apr 30, 2020
1 parent be5061c commit fa14318
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
25 changes: 21 additions & 4 deletions openapi.nimble
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
version = "3.1.4"
version = "3.1.5"
author = "disruptek"
description = "OpenAPI Code Generator"
license = "MIT"
requires "nim >= 0.20.0"
requires "npeg >= 0.19.0"
requires "nim >= 1.0.6"
requires "npeg >= 0.23.0"
requires "foreach >= 1.0.1"
requires "https://github.com/disruptek/rest.git >= 1.0.0"
requires "https://github.com/disruptek/rest.git >= 1.0.3"

srcDir = "src"

proc execCmd(cmd: string) =
echo "execCmd:" & cmd
exec cmd

proc execTest(test: string) =
execCmd "nim c -f -r " & test
execCmd "nim c -d:release -r " & test
execCmd "nim c -d:danger -r " & test
execCmd "nim cpp -r " & test
execCmd "nim cpp -d:danger -r " & test
when NimMajor >= 1 and NimMinor >= 1:
execCmd "nim c --gc:arc --exceptions:goto -r " & test
execCmd "nim cpp --gc:arc --exceptions:goto -r " & test

task test, "run tests for travis":
execTest("tests/tests.nim")
8 changes: 7 additions & 1 deletion src/openapi/codegen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ proc maybeAddExternalDocs(node: var NimNode; js: JsonNode) =
if comment.isSome:
node.add newCommentStmtNode(comment.get)

proc addNoSink(validator: NimNode): NimNode =
result = validator
validator.addPragma ident"nosinks"

proc maybeDeprecate(name: NimNode; params: seq[NimNode]; body: NimNode;
deprecate: bool): NimNode =
## make a proc and maybe deprecate it
Expand Down Expand Up @@ -746,7 +750,9 @@ proc makeValidator(op: Operation; name: NimNode; root: JsonNode): Option[NimNode
var params = @[ident"JsonNode"]
params.add op.locationParamDefs(nillable = false)
params.add newIdentDefs(ident"_", ident"string", newStrLitNode"")
result = some(maybeDeprecate(name, params, body, deprecate=op.deprecated))
let
maybe = maybeDeprecate(name, params, body, deprecate=op.deprecated)
result = addNoSink(maybe).some

proc usesJsonWhenNative(param: Parameter): bool =
## simple test to see if a parameter should use a json type
Expand Down

0 comments on commit fa14318

Please sign in to comment.