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

Fix example primitive oneOf variants getting option wrapped #427

Merged
merged 3 commits into from
Dec 12, 2024
Merged
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: 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
Loading