Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Fix import when body parameter is union of models
4 changes: 2 additions & 2 deletions packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "~0.20.3",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTU4NDM4MS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.20.3.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand All @@ -47,4 +47,4 @@
"requirements.txt",
"generator/"
]
}
}
4 changes: 2 additions & 2 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "~0.20.3",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTU4NDM4MS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.20.3.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand Down Expand Up @@ -103,4 +103,4 @@
"chalk": "5.3.0",
"@types/fs-extra": "11.0.4"
}
}
}
6 changes: 5 additions & 1 deletion packages/typespec-python/scripts/eng/regenerate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface TspCommand {
}

// Add this near the top with other constants
const SKIP_SPECS = ["type/union/discriminated"];
const SKIP_SPECS: string[] = [];

const AZURE_EMITTER_OPTIONS: Record<string, Record<string, string> | Record<string, string>[]> = {
"azure/client-generator-core/access": {
Expand Down Expand Up @@ -257,6 +257,10 @@ const EMITTER_OPTIONS: Record<string, Record<string, string> | Record<string, st
"package-name": "typetest-union",
"namespace": "typetest.union",
},
"type/union/discriminated": {
"package-name": "typetest-union-discriminated",
"namespace": "typetest.union.discriminated",
},
"client/structure/client-operation-group": {
"package-name": "client-structure-clientoperationgroup",
"namespace": "client.structure.clientoperationgroup",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Release History

## 1.0.0b1 (1970-01-01)

### Other Changes

- Initial version
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include *.md
include LICENSE
include typetest/union/discriminated/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include typetest/__init__.py
include typetest/union/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Typetest Union Discriminated client library for Python
<!-- write necessary description of service -->

## Getting started

### Install the package

```bash
python -m pip install typetest-union-discriminated
```

#### Prequisites

- Python 3.9 or later is required to use this package.
- You need an [Azure subscription][azure_sub] to use this package.
- An existing Typetest Union Discriminated instance.


## Contributing

This project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
the right to, and actually do, grant us the rights to use your contribution.
For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether
you need to provide a CLA and decorate the PR appropriately (e.g., label,
comment). Simply follow the instructions provided by the bot. You will only
need to do this once across all repos using our CLA.

This project has adopted the
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
see the Code of Conduct FAQ or contact opencode@microsoft.com with any
additional questions or comments.

<!-- LINKS -->
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
[azure_identity_pip]: https://pypi.org/project/azure-identity/
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
[pip]: https://pypi.org/project/pip/
[azure_sub]: https://azure.microsoft.com/free/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"CrossLanguagePackageId": "Type.Union.Discriminated",
"CrossLanguageDefinitionId": {
"typetest.union.discriminated.models.Cat": "Type.Union.Discriminated.Cat",
"typetest.union.discriminated.models.Dog": "Type.Union.Discriminated.Dog"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-e ../../../eng/tools/azure-sdk-tools
../../core/azure-core
aiohttp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import os
import pytest
from dotenv import load_dotenv
from devtools_testutils import (
test_proxy,
add_general_regex_sanitizer,
add_body_key_sanitizer,
add_header_regex_sanitizer,
)

load_dotenv()


# For security, please avoid record sensitive identity information in recordings
@pytest.fixture(scope="session", autouse=True)
def add_sanitizers(test_proxy):
discriminated_subscription_id = os.environ.get(
"DISCRIMINATED_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000"
)
discriminated_tenant_id = os.environ.get("DISCRIMINATED_TENANT_ID", "00000000-0000-0000-0000-000000000000")
discriminated_client_id = os.environ.get("DISCRIMINATED_CLIENT_ID", "00000000-0000-0000-0000-000000000000")
discriminated_client_secret = os.environ.get("DISCRIMINATED_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=discriminated_subscription_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=discriminated_tenant_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=discriminated_client_id, value="00000000-0000-0000-0000-000000000000")
add_general_regex_sanitizer(regex=discriminated_client_secret, value="00000000-0000-0000-0000-000000000000")

add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
add_header_regex_sanitizer(key="Cookie", value="cookie;")
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import pytest
from devtools_testutils import recorded_by_proxy
from testpreparer import DiscriminatedClientTestBase, DiscriminatedPreparer


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestDiscriminatedEnvelopeOperations(DiscriminatedClientTestBase):
@DiscriminatedPreparer()
@recorded_by_proxy
def test_envelope_object_default_get(self, discriminated_endpoint):
client = self.create_client(endpoint=discriminated_endpoint)
response = client.envelope.object.default.get()

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy
def test_envelope_object_default_put(self, discriminated_endpoint):
client = self.create_client(endpoint=discriminated_endpoint)
response = client.envelope.object.default.put(
input={"meow": bool, "name": "str"},
)

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy
def test_envelope_object_custom_properties_get(self, discriminated_endpoint):
client = self.create_client(endpoint=discriminated_endpoint)
response = client.envelope.object.custom_properties.get()

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy
def test_envelope_object_custom_properties_put(self, discriminated_endpoint):
client = self.create_client(endpoint=discriminated_endpoint)
response = client.envelope.object.custom_properties.put(
input={"meow": bool, "name": "str"},
)

# please add some check logic here by yourself
# ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import pytest
from devtools_testutils.aio import recorded_by_proxy_async
from testpreparer import DiscriminatedPreparer
from testpreparer_async import DiscriminatedClientTestBaseAsync


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestDiscriminatedEnvelopeOperationsAsync(DiscriminatedClientTestBaseAsync):
@DiscriminatedPreparer()
@recorded_by_proxy_async
async def test_envelope_object_default_get(self, discriminated_endpoint):
client = self.create_async_client(endpoint=discriminated_endpoint)
response = await client.envelope.object.default.get()

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy_async
async def test_envelope_object_default_put(self, discriminated_endpoint):
client = self.create_async_client(endpoint=discriminated_endpoint)
response = await client.envelope.object.default.put(
input={"meow": bool, "name": "str"},
)

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy_async
async def test_envelope_object_custom_properties_get(self, discriminated_endpoint):
client = self.create_async_client(endpoint=discriminated_endpoint)
response = await client.envelope.object.custom_properties.get()

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy_async
async def test_envelope_object_custom_properties_put(self, discriminated_endpoint):
client = self.create_async_client(endpoint=discriminated_endpoint)
response = await client.envelope.object.custom_properties.put(
input={"meow": bool, "name": "str"},
)

# please add some check logic here by yourself
# ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import pytest
from devtools_testutils import recorded_by_proxy
from testpreparer import DiscriminatedClientTestBase, DiscriminatedPreparer


@pytest.mark.skip("you may need to update the auto-generated test case before run it")
class TestDiscriminatedNoEnvelopeOperations(DiscriminatedClientTestBase):
@DiscriminatedPreparer()
@recorded_by_proxy
def test_no_envelope_default_get(self, discriminated_endpoint):
client = self.create_client(endpoint=discriminated_endpoint)
response = client.no_envelope.default.get()

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy
def test_no_envelope_default_put(self, discriminated_endpoint):
client = self.create_client(endpoint=discriminated_endpoint)
response = client.no_envelope.default.put(
input={"meow": bool, "name": "str"},
)

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy
def test_no_envelope_custom_discriminator_get(self, discriminated_endpoint):
client = self.create_client(endpoint=discriminated_endpoint)
response = client.no_envelope.custom_discriminator.get()

# please add some check logic here by yourself
# ...

@DiscriminatedPreparer()
@recorded_by_proxy
def test_no_envelope_custom_discriminator_put(self, discriminated_endpoint):
client = self.create_client(endpoint=discriminated_endpoint)
response = client.no_envelope.custom_discriminator.put(
input={"meow": bool, "name": "str"},
)

# please add some check logic here by yourself
# ...
Loading
Loading