Skip to content

Commit

Permalink
fix: Format boolean options to lowercase string in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed May 24, 2024
1 parent cb4a75a commit 049c2e4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions karapace/protobuf/option_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,23 @@ def __init__(self, name: str, kind: Kind, value, is_parenthesized: bool = False)
self.formattedName = f"({self.name})" if is_parenthesized else self.name

def to_schema(self) -> str:
aline = None
aline = ""
if self.kind == self.Kind.STRING:
aline = f'{self.formattedName} = "{self.value}"'
elif self.kind in [self.Kind.BOOLEAN, self.Kind.NUMBER, self.Kind.ENUM]:
elif self.kind == self.Kind.BOOLEAN:
aline = f"{self.formattedName} = {str(self.value).lower()}"
elif self.kind == self.Kind.NUMBER:
aline = f"{self.formattedName} = {self.value}"
elif self.kind == self.Kind.ENUM:
aline = f"{self.formattedName} = {self.value}"
elif self.kind == self.Kind.OPTION:
aline = f"{self.formattedName}.{try_to_schema(self.value)}"
elif self.kind == self.Kind.MAP:
aline = [f"{self.formattedName} = {{\n", self.format_option_map(self.value), "}"]
elif self.kind == self.Kind.LIST:
aline = [f"{self.formattedName} = ", self.append_options(self.value)]
else:
raise ValueError("Unknown value Kind.")

if isinstance(aline, list):
return "".join(aline)
Expand Down

0 comments on commit 049c2e4

Please sign in to comment.