Azure / autorest.java

Extension for AutoRest (https://github.com/Azure/autorest) that generates Java code
MIT License
33 stars 80 forks source link

all client, support basic versioning for Operation, ModelProperty and Parameter #2653

Closed XiaofeiCao closed 3 months ago

XiaofeiCao commented 3 months ago

fix https://github.com/Azure/autorest.java/issues/2644

code in https://github.com/Azure/autorest.java/pull/2653/commits/01536598dde7316759619016dc3076c486d070cb

Support basic versioning senarios for @added and @removed when dev-option.supports-versioning is false(default mode)

1. On Operation

@removed(ApiVersions.v2022_12_01_preview)
create is ResourceOperations.ResourceCreateOrReplace<Resource>;

2. On ModelProperty

@added(Versions.v2022_06_01_preview)
@removed(Versions.v2023_11_01)
@added(Versions.v2023_12_01_preview)
propertyRemovedInStable: string;

3. On Parameter

model ListQueryParams {
  @removed(ApiVersions.v2022_12_01_preview)
  @query
  expand?: string;
}

op list is ResourceOperations.ResourceList<Resource, ListQueryParametersTrait<ListQueryParams>>;
haolingdong-msft commented 3 months ago

double confirm my understanding: current support is to generate removed operations, which means even user switch to an old service version which contains a removed operation, they can still not call the newly removed operation?

weidongxu-microsoft commented 3 months ago

Yes.

For mgmt, this is same behavior of current Swagger, and there is no "switch to an old service version". (we may support it in future, as typespec should be on same api-version -- but for Swagger it could be all mixed)

For data-plane, we don't plan to address the "remove" in near future. Service should not "remove" anything that GAed. For the preview api-versions before API, current guideline is to delete them in typespec (as preview api-version should only live for about 3 months in data-plane -- there is not much benefit to keep them after a new GA api-version).