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

support shorthand syntax in example generation #326

Merged
merged 8 commits into from
Jan 11, 2024

Conversation

necusjz
Copy link
Member

@necusjz necusjz commented Jan 10, 2024

No description provided.

@necusjz necusjz requested a review from kairu-ms January 10, 2024 07:16
@necusjz necusjz self-assigned this Jan 10, 2024
@@ -0,0 +1,19 @@
def serialize(obj):
Copy link
Collaborator

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)))
Copy link
Collaborator

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
Copy link
Collaborator

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 = {
Copy link
Collaborator

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>
@necusjz necusjz merged commit ea54c4b into Azure:example-generation Jan 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants