Skip to content
This repository was archived by the owner on May 22, 2026. It is now read-only.

add feature --generate-sample - #1275

Closed
Yuchao Yan (msyyc) wants to merge 67 commits into
autorestv3from
generate-sample
Closed

add feature --generate-sample#1275
Yuchao Yan (msyyc) wants to merge 67 commits into
autorestv3from
generate-sample

Conversation

@msyyc

@msyyc Yuchao Yan (msyyc) commented Jun 2, 2022

Copy link
Copy Markdown
Member

Comment thread autorest/codegen/serializers/__init__.py Outdated
Comment thread autorest/codegen/serializers/__init__.py
Comment thread autorest/codegen/serializers/sample_serializer.py Outdated
Comment thread autorest/codegen/serializers/sample_serializer.py Outdated
Comment thread tasks.py Outdated
body_param["clientDefaultValue"] = body_type["value"]
body_param["flattened"] = flattened
body_param["isPartialBody"] = is_partial_body
body_param["restApiName"] = body_param["restApiName"] or to_lower_camel_case(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelerfour does not output serializedName but it is needed when generating sample so we have to convert it by ourselves:
image

@msyyc

Copy link
Copy Markdown
Member Author

Hi iscai-msft I fix the review comment and please review again.

@danaelhe

Copy link
Copy Markdown

Cool feature- Any update on merging this?

import logging
import re

_LOGGER = logging.getLogger(__name__)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imported but not used

def main():
client = AutoRestDurationTestService()

response = client.duration.get_null()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the samples can be picked up at doc site, the "--include-x-ms-examples-original-file" should be enabled as modelerfour option, and the "x-ms-original-file" of the example should be shown as comment in the generated sample file.

@msyyc
Yuchao Yan (msyyc) deleted the generate-sample branch October 12, 2022 07:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Sample] Generate sample with swagger examples: --generate-sample

4 participants