Azure / Azure/azure-libraries-for-java

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

オープン
#683 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
App Services Service Attention
主要言語
Java
スター
97
フォーク
102
PR マージ指標
30日以内にマージされた PR はありません

説明

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)

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Provider.json の availableStacks GET 定義から始め、そのスキーマを issue に示されているレスポンスペイロード、および AzureStoragePropertyDictionaryResource、BackupItems、BackupItemCollection の例と比較してください。生成された ApplicationStackInner.java モデルと、参照されている parsing の変更を確認してください。完了とは、swagger モデルが返された properties 構造を正しくデシリアライズする Java クラスを生成することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
azure, java
領域
api
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。