-
Notifications
You must be signed in to change notification settings - Fork 47
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
support shorthand syntax in example generation #326
support shorthand syntax in example generation #326
Conversation
@@ -0,0 +1,19 @@ | |||
def serialize(obj): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shorthand syntax should be belong to Command module not Swagger module.
@@ -106,7 +106,7 @@ def mapping(self, example_dict): | |||
val=value | |||
) | |||
if item and item.is_top_level: | |||
self.example_items.append((item.arg_option, json.dumps(value))) | |||
self.example_items.append((item.arg_option, serialize(value))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The final output serialization no matter to json string or shorthand syntax string, should be implemented in Command module.
if any(char in escaped for char in (" ", "null", "??", ":", ",", "{", "}", "[", "]")): | ||
escaped = "'" + escaped + "'" | ||
|
||
return repr(escaped)[1:-1] # ignore quotes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should replace None
by null
in shorthand syntax expression
|
||
|
||
def test_with_special_characters(): | ||
obj = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add tests for None value
Co-authored-by: kai ru <69238381+kairu-ms@users.noreply.github.com>
No description provided.