Skip to content

Commit

Permalink
Fix example primitive oneOf variants getting option wrapped (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzou authored Dec 12, 2024
1 parent 0fb8148 commit 4d03450
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions .generator/src/generator/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def _format_oneof(schema, data, name, replace_values, imports, **kwargs):

one_of_schema_name = schema_name(one_of_schema)
if not one_of_schema_name:
one_of_schema_name = simple_type(one_of_schema).title()
one_of_schema_name = simple_type(one_of_schema, render_option=False).title()

if not is_primitive(one_of_schema) and one_of_schema.get("type") != "array":
# TODO: revisit possibility of removing all boxes
Expand Down Expand Up @@ -491,7 +491,6 @@ def open_file(x):
parameters = f"{parameters}"
return parameters, imports


if (not required or schema.get("nullable")) and schema.get("type") is not None:
imports.update(extra_imports)
return reference_to_value(schema, parameters, print_nullable=True, **kwargs), imports
Expand All @@ -500,7 +499,7 @@ def open_file(x):
if default_name and schema_name(schema) is None:
return _format_oneof(schema, data, default_name+"Item", replace_values, imports, **kwargs)
return _format_oneof(schema, data, schema_name(schema), replace_values, imports, **kwargs)

imports.update(extra_imports)
return parameters, imports

Expand Down
2 changes: 1 addition & 1 deletion .generator/src/generator/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def type_to_rust(schema, alternative_name=None, render_nullable=False, render_op
else:
type_ = "object"
warnings.warn(f"Unknown type for schema: {schema} ({name or alternative_name})")
return option_wrapper(f"serde_json::Value", render_option, render_nullable)
return option_wrapper("serde_json::Value", render_option, render_nullable)

if type_ == "array":
if name or alternative_name:
Expand Down
2 changes: 1 addition & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pre_commit_wrapper () {
echo "command 'pre-commit run --all-files --hook-stage=manual ${1}' success"
}

cargo install --git https://github.com/skarimo/genemichaels.git --rev 82e25fc0f70acb4bd7568ff803f643996d629727
cargo install genemichaels@0.5.11
cargo install dd-rust-license-tool --quiet

rm -rf src/*
Expand Down

0 comments on commit 4d03450

Please sign in to comment.