Skip to content

Commit

Permalink
seastar-json2code: collect required_query_params using a list
Browse files Browse the repository at this point in the history
use `join()` to simplify the implementation to print the names of
required query parameters, simpler this way. this change also
prepares for scylladb#2082.

Refs scylladb#2082

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov authored and hurricane1026 committed Feb 19, 2024
1 parent c6843c6 commit 3cffe2f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions scripts/seastar-json2code.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ def add_operation(hfile, ccfile, path, oper):
fprint(ccfile, '{', '"', path_param , '", path_description::url_component_type::PARAM', '}')
fprint(ccfile, '}')
fprint(ccfile, ',{')
first = True
enum_definitions = ""
if "enum" in oper:
nickname = oper["nickname"]
Expand All @@ -315,20 +314,17 @@ def add_operation(hfile, ccfile, path, oper):
}
''').substitute(nickname=nickname, enum_wrapper=enum_wrapper.rstrip())
funcs = ""
required_query_params = []
for param in oper.get("parameters", []):
if is_required_query_param(param):
if first:
first = False
else:
fprint(ccfile, "\n,")
fprint(ccfile, '"', param["name"], '"')
required_query_params.append(param["name"])
if "enum" in param:
enum_decl, parse_func = generate_code_from_enum(oper["nickname"],
param["name"],
param["enum"])
enum_definitions += enum_decl
funcs += parse_func

fprint(ccfile, '\n,'.join(f'"{name}"' for name in required_query_params))
fprintln(ccfile, '});')
fprintln(hfile, enum_definitions)
open_namespace(ccfile, 'ns_' + oper["nickname"])
Expand Down

0 comments on commit 3cffe2f

Please sign in to comment.