﻿{
  "swagger": "2.0",
  "info": {
    "title": "AutoRest Resource Flattening Test Service",
    "description": "Resource Flattening for AutoRest",
    "version": "1.0.0"
  },
  "host": "localhost:3000",
  "schemes": [
    "http"
  ],
  "produces": [
    "application/json"
  ],
  "consumes": [
    "application/json"
  ],
  "paths": {
    "/azure/resource-flatten/array": {
      "put": {
        "operationId": "putArray",
        "description": "Put External Resource as an Array",
        "externalDocs": {
          "url": "http://tempuri.org"
        },
        "parameters": [
          {
            "name": "ResourceArray",
            "description": "External Resource as an Array to put",
            "in": "body",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Resource"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response"
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "get": {
        "operationId": "getArray",
        "description": "Get External Resource as an Array",
        "externalDocs": {
          "url": "http://tempuri.org"
        },
        "responses": {
          "200": {
            "description": "External Resource as an Array from get",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/FlattenedProduct"
              }
            }
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/azure/resource-flatten/dictionary": {
      "put": {
        "operationId": "putDictionary",
        "description": "Put External Resource as a Dictionary",
        "externalDocs": {
          "url": "http://tempuri.org"
        },
        "parameters": [
          {
            "name": "ResourceDictionary",
            "description": "External Resource as a Dictionary to put",
            "in": "body",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/FlattenedProduct"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response"
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "get": {
        "operationId": "getDictionary",
        "description": "Get External Resource as a Dictionary",
        "externalDocs": {
          "url": "http://tempuri.org"
        },
        "responses": {
          "200": {
            "description": "External Resource as a Dictionary from get",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/FlattenedProduct"
              }
            }
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/azure/resource-flatten/resourcecollection": {
      "put": {
        "operationId": "putResourceCollection",
        "description": "Put External Resource as a ResourceCollection",
        "externalDocs": {
          "url": "http://tempuri.org"
        },
        "parameters": [
          {
            "name": "ResourceComplexObject",
            "description": "External Resource as a ResourceCollection to put",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/ResourceCollection"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response"
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "get": {
        "operationId": "getResourceCollection",
        "description": "Get External Resource as a ResourceCollection",
        "externalDocs": {
          "url": "http://tempuri.org"
        },
        "responses": {
          "200": {
            "description": "External Resource as a ResourceCollection from get",
            "schema": {
              "$ref": "#/definitions/ResourceCollection"
            }
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          } 
        }
      }
    }
  },
  "definitions": {
    "Error": {
      "type":  "object",
      "properties": {
        "status": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "Resource": {
      "type":  "object",
      "x-ms-azure-resource": true,
      "description": "Some resource",
      "externalDocs": {
        "url": "http://tempuri.org"
      },
      "properties": {
        "id": {
          "type": "string",
          "description": "Resource Id",
          "readOnly": true
        },
        "type": {
          "type": "string",
          "description": "Resource Type",
          "readOnly": true
        },
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "location": {
          "type": "string",
          "description": "Resource Location"
        },
        "name": {
          "type": "string",
          "description": "Resource Name",
          "readOnly": true
        }
      }
    },
    "FlattenedProduct": {
      "allOf": [
        {
          "$ref": "#/definitions/Resource"
        }
      ],
      "type":  "object",
      "properties": {
        "properties": {
          "x-ms-client-flatten": true,
          "$ref": "#/definitions/FlattenedResourceProperties"
        }
      }
    },
    "FlattenedResourceProperties": {
      "type":  "object",
      "properties": {
        "pname": {
          "type": "string"
        },
        "lsize": {
          "type": "integer",
          "format": "int32"
        },
        "provisioningState": {
          "type": "string"
        }
      }
    },
    "ResourceCollection": {
      "type":  "object",
      "properties": {
        "productresource": {
          "type": "object",
          "$ref": "#/definitions/FlattenedProduct"
        },
        "arrayofresources": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/FlattenedProduct"
          }
        },
        "dictionaryofresources": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/FlattenedProduct"
          }
        }
      }
    }
  }
}
