Azure / Azure/azure-libraries-for-java

Appservice response for the `availableStacks` API does not match the swagger model

Đang mở
#683 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
App Services Service Attention
Ngôn ngữ chính
Java
Star
97
Fork
102
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The [swagger spec](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/web/resource-manager/Microsoft.Web/stable/2018-02-01/Provider.json#L146) for the `get` operation for [`availableStacks`](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/web/resource-manager/Microsoft.Web/stable/2018-02-01/Provider.json#L19) API does not match the data on the wire.

Here is what I see returned by the service :
```
[main] INFO com.microsoft.azure.management.appservice.Providers getAvailableStacks - --> GET https://management.azure.com/providers/Microsoft.Web/availableStacks?osTypeSelected=Windows&api-version=2018-02-01

[main] INFO com.microsoft.azure.management.appservice.Providers getAvailableStacks - 1650-byte body:
{
"value": [{
"id": null,
"name": "aspnet",
"type": "Microsoft.Web/availableStacks?osTypeSelected=Windows",
"properties": {
"name": "aspnet",
"display": "Net Framework Version",
"dependency": null,
"majorVersions": [{
"displayVersion": "v4.7",
"runtimeVersion": "v4.0",
"isDefault": true,
"minorVersions": [],
"applicationInsights": false
}, {
"displayVersion": "v3.5",
"runtimeVersion": "v2.0",
"isDefault": false,
"minorVersions": [],
"applicationInsights": false
}],
"frameworks": []
}
},

...
],
"nextLink": null,
"id": null
}
```

The swagger declaration is causing the classes in the java SDK to be created like [this](https://github.com/Azure/azure-libraries-for-java/blob/master/azure-mgmt-appservice/src/main/java/com/microsoft/azure/management/appservice/implementation/ApplicationStackInner.java) :
```java
public class ApplicationStackInner {

/**
* Application stack name.
*/
@JsonProperty(value = "name")
private String name;

/**
* Application stack display name.
*/
@JsonProperty(value = "display")
private String display;

/**
* Application stack dependency.
*/
@JsonProperty(value = "dependency")
private String dependency;

/**
* List of major versions available.
*/
@JsonProperty(value = "majorVersions")
private List majorVersions;
….
```

Which breaks when we try tp parse the data that is returned by the server.

In order to correctly get the data out, I have to now [edit the autogenerated class](https://github.com/Azure/azure-libraries-for-java/pull/680/files#diff-c2b9d9bfd15c0ba1fae0d3425d63cefbR20) to add the `properties` sub class...

The service needs to change the on the swagger modelling.

### Suggested Fix
Change the swagger model.

Good examples of what needs to be done, model like the following
* [`AzureStoragePropertyDictionaryResource`](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/web/resource-manager/Microsoft.Web/stable/2018-02-01/WebApps.json#L18058)
* A little more relevant example id [`BackupItems`](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/web/resource-manager/Microsoft.Web/stable/2018-02-01/WebApps.json#L18105) and [`BackupItemCollection`](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/web/resource-manager/Microsoft.Web/stable/2018-02-01/WebApps.json#L18218)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với định nghĩa GET của availableStacks trong Provider.json và so sánh schema của nó với payload phản hồi được hiển thị trong issue cũng như các ví dụ AzureStoragePropertyDictionaryResource, BackupItems và BackupItemCollection. Kiểm tra model ApplicationStackInner.java được tạo và thay đổi parsing được tham chiếu; hoàn tất nghĩa là model swagger tạo ra một lớp Java có thể deserialize chính xác cấu trúc properties được trả về.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
azure, java
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.