Skip to content

Commit

Permalink
add default value info for params to docs (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft authored Feb 25, 2022
1 parent 058bb3d commit 0e13023
Show file tree
Hide file tree
Showing 915 changed files with 4,380 additions and 3,783 deletions.
14 changes: 14 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Change Log

### 2022-xx-xx - 5.12.7

| Library | Min Version
| --------------- | -------
|`@autorest/core` | `3.6.2`
|`@autorest/modelerfour` | `4.19.1`
|`azure-core` dep of generated code | `1.20.1`
|`msrest` dep of generated code | `0.6.21`
|`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`

**Bug Fixes**

- Add default value consistently for parameters #1164

### 2022-02-09 - 5.12.6

| Library | Min Version
Expand Down
4 changes: 0 additions & 4 deletions autorest/codegen/models/constant_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def get_declaration(self, value: Any):
return "None"
return self.schema.get_declaration(self.value)

@property
def extra_description_information(self) -> str:
return f"The default value is {self.get_declaration(self.value)}."

@property
def serialization_type(self) -> str:
"""Returns the serialization value for msrest.
Expand Down
4 changes: 4 additions & 0 deletions autorest/codegen/models/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def description(self):
if description:
description += " "
description += f"{self.schema.extra_description_information}"
if self.has_default_value and not any(
l for l in ["default value is", "default is"] if l in description.lower()
):
description += f" Default value is {self.default_value_declaration}."
if self.constant:
description += " Note that overriding this default value may result in unsupported behavior."
return description
Expand Down
2 changes: 1 addition & 1 deletion autorest/codegen/models/parameter_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def add_host(self, host_value: Optional[str]) -> None:
schema=StringSchema(namespace="", yaml_data={"type": "str"}),
rest_api_name=self.host_variable_name,
serialized_name=self.host_variable_name,
description=f"Service URL. Default value is '{host_value}'.",
description=f"Service URL.",
implementation="Client",
required=True,
location=ParameterLocation.Other,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AutoRestHeadTestService(object):
:vartype http_success: azure.key.credential.sample.operations.HttpSuccessOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.AzureKeyCredential
:param base_url: Service URL. Default value is 'http://localhost:3000'.
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AutoRestHeadTestService:
:vartype http_success: azure.key.credential.sample.aio.operations.HttpSuccessOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.AzureKeyCredential
:param base_url: Service URL. Default value is 'http://localhost:3000'.
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AutoRestHeadTestService(object):
:ivar http_success: HttpSuccessOperations operations
:vartype http_success: azure.basic.sample.operations.HttpSuccessOperations
:param base_url: Service URL. Default value is 'http://localhost:3000'.
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AutoRestHeadTestService:
:ivar http_success: HttpSuccessOperations operations
:vartype http_success: azure.basic.sample.aio.operations.HttpSuccessOperations
:param base_url: Service URL. Default value is 'http://localhost:3000'.
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class PollingPagingExample(PollingPagingExampleOperationsMixin):
"""Show polling and paging generation.
:param base_url: Service URL. Default value is 'http://localhost:3000'.
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class PollingPagingExample(PollingPagingExampleOperationsMixin):
"""Show polling and paging generation.
:param base_url: Service URL. Default value is 'http://localhost:3000'.
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def begin_basic_polling(
) -> AsyncCustomPoller["_models.Product"]:
"""A simple polling operation.
:param product: Product to put.
:param product: Product to put. Default value is None.
:type product: ~azure.directives.sample.models.Product
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def begin_basic_polling(
# type: (...) -> CustomPoller["_models.Product"]
"""A simple polling operation.
:param product: Product to put.
:param product: Product to put. Default value is None.
:type product: ~azure.directives.sample.models.Product
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AutoRestHeadTestService(object):
:vartype http_success: azure.mgmt.sample.operations.HttpSuccessOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param base_url: Service URL. Default value is 'http://localhost:3000'.
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AutoRestHeadTestService:
:vartype http_success: azure.mgmt.sample.aio.operations.HttpSuccessOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param base_url: Service URL. Default value is 'http://localhost:3000'.
:param base_url: Service URL. Default value is "http://localhost:3000".
:type base_url: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def begin_test_lro(
# type: (...) -> LROPoller["_models.Product"]
"""Put in whatever shape of Product you want, will return a Product with id equal to 100.
:param product: Product to put.
:param product: Product to put. Default value is None.
:type product: ~azure.multiapi.sample.v1.models.Product
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
Expand Down Expand Up @@ -65,9 +65,9 @@ def begin_test_lro_and_paging(
# type: (...) -> LROPoller[ItemPaged["_models.PagingResult"]]
"""A long-running paging operation that includes a nextLink that has 10 pages.
:param client_request_id:
:param client_request_id: Default value is None.
:type client_request_id: str
:param test_lro_and_paging_options: Parameter group.
:param test_lro_and_paging_options: Parameter group. Default value is None.
:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
Expand Down Expand Up @@ -108,9 +108,9 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements
:param greeting_in_english: pass in 'hello' to pass test.
:type greeting_in_english: str
:param greeting_in_chinese: pass in 'nihao' to pass test.
:param greeting_in_chinese: pass in 'nihao' to pass test. Default value is None.
:type greeting_in_chinese: str
:param greeting_in_french: pass in 'bonjour' to pass test.
:param greeting_in_french: pass in 'bonjour' to pass test. Default value is None.
:type greeting_in_french: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_one( # pylint: disable=inconsistent-return-statements
:param id: An int parameter.
:type id: int
:param message: An optional string parameter.
:param message: An optional string parameter. Default value is None.
:type message: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def begin_test_lro(
) -> AsyncLROPoller["_models.Product"]:
"""Put in whatever shape of Product you want, will return a Product with id equal to 100.
:param product: Product to put.
:param product: Product to put. Default value is None.
:type product: ~azure.multiapi.sample.v1.models.Product
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
Expand Down Expand Up @@ -60,9 +60,9 @@ async def begin_test_lro_and_paging(
) -> AsyncLROPoller[AsyncItemPaged["_models.PagingResult"]]:
"""A long-running paging operation that includes a nextLink that has 10 pages.
:param client_request_id:
:param client_request_id: Default value is None.
:type client_request_id: str
:param test_lro_and_paging_options: Parameter group.
:param test_lro_and_paging_options: Parameter group. Default value is None.
:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
Expand Down Expand Up @@ -102,9 +102,9 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement
:param greeting_in_english: pass in 'hello' to pass test.
:type greeting_in_english: str
:param greeting_in_chinese: pass in 'nihao' to pass test.
:param greeting_in_chinese: pass in 'nihao' to pass test. Default value is None.
:type greeting_in_chinese: str
:param greeting_in_french: pass in 'bonjour' to pass test.
:param greeting_in_french: pass in 'bonjour' to pass test. Default value is None.
:type greeting_in_french: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
Expand Down Expand Up @@ -138,7 +138,7 @@ async def test_one( # pylint: disable=inconsistent-return-statements
:param id: An int parameter.
:type id: int
:param message: An optional string parameter.
:param message: An optional string parameter. Default value is None.
:type message: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class MultiapiServiceClientConfiguration(Configuration): # pylint: disable=too-
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:keyword api_version: Api Version. The default value is "1.0.0". Note that overriding this
default value may result in unsupported behavior.
:keyword api_version: Api Version. Default value is "1.0.0". Note that overriding this default
value may result in unsupported behavior.
:paramtype api_version: str
"""

Expand Down
Loading

0 comments on commit 0e13023

Please sign in to comment.