microsoft / microsoft/typespec

[python] Accept ref to azure.core.exceptions.OdataV4Format in model definition.

Open
#5,781 0 comments 0 reactions 1 assignee Claimed by @tadelesh View on GitHub
emitter:client:python
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

transferred from https://github.com/Azure/autorest.python/issues/2853

We know for quite some time that at some point, we would need to support a way to have codegen ref an externally defined type, and not generate code for a model. This could be used to point to an azure-core type, or to a patched type.

Part of this, we discussed with @iscai-msft to support an update in rest_field that would look like this:
```python
details: List[ODataV4Frmat] = rest_field(ref=azure.core.exceptions.OdataV4Format)
```

IOW, a way to explain that this `rest_field` points to something else.

The scope of this issue is to support the first scenario that `Fundations.Error` will ref to `azure.core.exceptions.ODataV4Format`. In the particular case of that class, since `azure.core.exceptions.ODataV4Format` do not support a common deserilization contract, we should have a `if` statement in model base to deserilize properly by calling the constructor.

Long term, we should conclude on the deserialization contract required for ref, and update azure-core ODataV4Format acordingly, but short term a quick hack wouldn't hurt anyone, and it will be transparent for users.

This particular isue, we initiate the ref because we recognized a known type from TSP Azure.Core. Long term, we likely would need a decorator like this:
```
@ref("azure.service.MyType")
property: TypeWeDontGenerate
```
But it's another story for later, and doesn't impact what we're doing here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.