Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: add openapi3 schema #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/openapi/codegen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import parser
import paths

from schema2 import OpenApi2
from schema3 import OpenApi3

const MAKETYPES = false
when MAKETYPES:
Expand Down Expand Up @@ -1259,6 +1260,10 @@ proc init*(generator: var Generator; content: string) =
if generator.js["swagger"].getStr != "2.0":
error "we only know how to parse openapi-2.0 atm"
generator.schema = OpenApi2
elif "openapi" in generator.js:
if not generator.js["openapi"].getStr.startsWith("3."):
error "we only know how to parse openapi-3.xxx atm"
generator.schema = OpenApi3
else:
error "no swagger version found in the input"

Expand Down
2 changes: 1 addition & 1 deletion src/openapi/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ proc parseField*(ftype: FieldTypeDef; js: JsonNode): ParserResult =
result = ftype.a.parseField(js)
if not result.ok:
result = ftype.b.parseField(js)
of List:
of List, Map:
foreach j in js.items of JsonNode:
result = ftype.member.parseField(j)
if not result.ok:
Expand Down
Loading