Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 2.05 KB

get-collection-response-schema.md

File metadata and controls

76 lines (56 loc) · 2.05 KB

GetCollectionResponseSchema

Category

ARM Error

Applies to

ARM OpenAPI(swagger) specs

Related ARM Guideline Code

  • RPC-Get-V1-10

Output Message

The response model in the GET collection operation "{0}" does not match with the response model in the individual GET operation "{1}".

Description

Per ARM guidelines, for all resources (top-level and nested), collection GETs should have a response definition with a property "value" containing an array of the "resource" schema.The definition returned in the collection "value" array should be the same as the response body for the individual GET.

CreatedAt

July 13, 2020

LastModifiedAt

July 13, 2020

How to fix the violation

Make sure the collection GETs return an array and its items schema the same as the response schema in corresponding individual GET.

The following response is a good example:

...

 "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MyNameSpace/MyResourceType/{Name}": {
      "get": {
        ...
        ...
        "responses": {
          "200": {
            "description": "Success. The response describes the corresponding Service.",
            "schema": {
              "$ref": "#/definitions/MyResourceSchema"
            }
          }

...
...

 "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MyNameSpace/MyResourceType": {
      "get": {
        .....
        "responses": {
          "200": {
            "description": "Success. The response describes the list of Services in the resource group.",
            "schema": {
              "$ref": "#/definitions/MyResourceList"
            }
          },
...
...
"MyResourceList":{
   "type": "object", 
     "properties": { 
       "value": { 
           "type": "array", 
           "items": { 
               "$ref": "#/definitions/MyResourceSchema" 
           } 
       },
...