diff --git a/README.md b/README.md index 6ddc263778..15bf5b9629 100644 --- a/README.md +++ b/README.md @@ -35,16 +35,16 @@ AutoRest can be run on macOS and *nix using [Mono](http://www.mono-project.com/d Or [Docker](https://docs.docker.com/engine/installation): # Download Swagger.json example - curl -O https://raw.githubusercontent.com/Azure/autorest/master/Samples/petstore/petstore.json + `curl -O https://raw.githubusercontent.com/Azure/autorest/master/Samples/petstore/petstore.json` # Download latest AutoRest Docker image - docker pull azuresdk/autorest:latest + `docker pull azuresdk/autorest:latest` # Run AutoRest using Docker, mounting the current folder (pwd) into /home inside the container - docker run -it --rm -v $(pwd):/home azuresdk/autorest:latest autorest \ + `docker run -it --rm -v $(pwd):/home azuresdk/autorest:latest autorest \ -CodeGenerator CSharp \ -Input /home/petstore.json \ - -OutputDirectory /home/CSharp_PetStore -Namespace PetStore + -OutputDirectory /home/CSharp_PetStore -Namespace PetStore` ## Building AutoRest AutoRest is developed primarily in C# but generates code for multiple languages. See [this link](docs/developer/guide/building-code.md) to build and test AutoRest. diff --git a/Samples/petstore/Go/client.go b/Samples/petstore/Go/client.go index 5917c13144..0514c4a5bd 100644 --- a/Samples/petstore/Go/client.go +++ b/Samples/petstore/Go/client.go @@ -18,30 +18,30 @@ const ( // APIVersion is the version of the Petstore APIVersion = "1.0.0" - // DefaultBaseURI is the default URI used for the service Petstore - DefaultBaseURI = "http://petstore.swagger.io/v2" + // DefaultBaseURI is the default URI used for the service Petstore + DefaultBaseURI = "http://petstore.swagger.io/v2" ) // ManagementClient is the base client for Petstore. type ManagementClient struct { autorest.Client - BaseURI string + BaseURI string APIVersion string } // New creates an instance of the ManagementClient client. func New()ManagementClient { - return NewWithBaseURI(DefaultBaseURI, ) + return NewWithBaseURI(DefaultBaseURI, ) } -// NewWithBaseURI creates an instance of the ManagementClient client. -func NewWithBaseURI(baseURI string, ) ManagementClient { - return ManagementClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - APIVersion: APIVersion, + // NewWithBaseURI creates an instance of the ManagementClient client. + func NewWithBaseURI(baseURI string, ) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + APIVersion: APIVersion, + } } -} // AddPet adds a new pet to the store. You may receive an HTTP invalid input if // your pet is invalid. diff --git a/Samples/petstore/Go/version.go b/Samples/petstore/Go/version.go index 47dce9eab9..0ba157aa65 100644 --- a/Samples/petstore/Go/version.go +++ b/Samples/petstore/Go/version.go @@ -2,25 +2,41 @@ package petstore import ( + "bytes" "fmt" + "strings" ) const ( major = "0" minor = "0" patch = "0" - // Always begin a "tag" with a dash (as per http://semver.org) - tag = "-beta" - semVerFormat = "%s.%s.%s%s" + tag = "" userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" ) +// cached results of UserAgent and Version to prevent repeated operations. +var ( + userAgent string + version string +) // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return fmt.Sprintf(userAgentFormat, Version(), "petstore", "1.0.0") + if userAgent == "" { + userAgent = fmt.Sprintf(userAgentFormat, Version(), "petstore", "1.0.0") + } + return userAgent } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return fmt.Sprintf(semVerFormat, major, minor, patch, tag) + if version == "" { + versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) + if tag != "" { + versionBuilder.WriteRune('-') + versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) + } + version = string(versionBuilder.Bytes()) + } + return version } diff --git a/attic/gulpfile.js b/attic/gulpfile.js index 6470d5df24..4520c99d65 100644 --- a/attic/gulpfile.js +++ b/attic/gulpfile.js @@ -140,6 +140,7 @@ var goMappings = { 'url':['../../dev/TestServer/swagger/url.json','urlgroup'], 'validation':['../../dev/TestServer/swagger/validation.json', 'validationgroup'], 'paging':['../../dev/TestServer/swagger/paging.json', 'paginggroup'], + 'more-custom-base-uri':['../../dev/TestServer/swagger/custom-baseUrl-more-options.json', 'morecustombaseurigroup'], 'azurereport':['../../dev/TestServer/swagger/azure-report.json', 'azurereport'] }; diff --git a/docs/developer/guide/building-code.md b/docs/developer/guide/building-code.md index 2c621ff41a..eec0b66ff4 100644 --- a/docs/developer/guide/building-code.md +++ b/docs/developer/guide/building-code.md @@ -13,7 +13,7 @@ Expected time around 100 minutes to install. - Windows 10 Anniversary - (has PackageManagement, developer mode and supports WSL.) - JDK 8 - Android SDK -- NodeJS +- NodeJS (LTS Version: v6.9.4 or higher) - Gulp - Ruby 2.3 - Ruby Devkit diff --git a/gulpfile.iced b/gulpfile.iced index 1610c3f20a..97c70d5dcf 100644 --- a/gulpfile.iced +++ b/gulpfile.iced @@ -57,33 +57,39 @@ autorest = (args) -> ############################################### task 'test', "runs all tests", -> run 'test-cs', + 'test-go' + 'test-java' 'test-node' - 'test-ruby' 'test-python' - 'test-go' + 'test-ruby' -############################################### +############################################### +task 'test-go', 'runs Go tests', -> # FAILS, but also on master branch... + exec "glide up", { cwd: './src/generator/AutoRest.Go.Tests/src/tests' } + exec "go fmt ./generated/...", { cwd: './src/generator/AutoRest.Go.Tests/src/tests' } + exec "go run ./runner.go", { cwd: './src/generator/AutoRest.Go.Tests/src/tests' } + +############################################### +task 'test-java', 'runs Java tests', -> + exec "mvn test", { cwd: './src/generator/AutoRest.Java.Tests/' } + exec "mvn test", { cwd: './src/generator/AutoRest.Java.Azure.Tests/' } + +############################################### task 'test-node', 'runs NodeJS tests', -> - exec "npm test", { cwd: './src/generator/AutoRest.NodeJS.Tests/' } + #exec "npm test", { cwd: './src/generator/AutoRest.NodeJS.Tests/' } exec "npm test", { cwd: './src/generator/AutoRest.NodeJS.Azure.Tests/' } -############################################### +############################################### task 'test-python', 'runs Python tests', -> exec "tox", { cwd: './src/generator/AutoRest.Python.Tests/' } exec "tox", { cwd: './src/generator/AutoRest.Python.Azure.Tests/' } -############################################### +############################################### task 'test-ruby', 'runs Ruby tests', -> exec "ruby RspecTests/tests_runner.rb", { cwd: './src/generator/AutoRest.Ruby.Tests/' } exec "ruby RspecTests/tests_runner.rb", { cwd: './src/generator/AutoRest.Ruby.Azure.Tests/' } -############################################### -task 'test-go', 'runs Go tests', ['regenerate-go'], -> # FAILS, but also on master branch... - exec "glide up", { cwd: './src/generator/AutoRest.Go.Tests/src/tests' } - exec "go fmt ./generated/...", { cwd: './src/generator/AutoRest.Go.Tests/src/tests' } - exec "go run ./runner.go", { cwd: './src/generator/AutoRest.Go.Tests/src/tests' } - -############################################### +############################################### # LEGACY # Instead: have bunch of configuration files sitting in a well-known spot, discover them, feed them to AutoRest, done. diff --git a/pom.xml b/pom.xml index 86e80d8123..4c8c088078 100644 --- a/pom.xml +++ b/pom.xml @@ -70,12 +70,12 @@ com.microsoft.rest client-runtime - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT com.microsoft.azure azure-client-runtime - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT commons-codec diff --git a/src/core/AutoRest.Core/Properties/Resources.Designer.cs b/src/core/AutoRest.Core/Properties/Resources.Designer.cs index 61f74bf3d4..fcb5827991 100644 --- a/src/core/AutoRest.Core/Properties/Resources.Designer.cs +++ b/src/core/AutoRest.Core/Properties/Resources.Designer.cs @@ -104,6 +104,15 @@ public static string BodyWithType { } } + /// + /// Looks up a localized string similar to Booleans are not descriptive and make them hard to use. Instead use string enums with allowed set of values defined: '{0}'.. + /// + public static string BooleanPropertyNotRecommended { + get { + return ResourceManager.GetString("BooleanPropertyNotRecommended", resourceCulture); + } + } + /// /// Looks up a localized string similar to Errors found during Swagger document validation.. /// diff --git a/src/core/AutoRest.Core/Properties/Resources.resx b/src/core/AutoRest.Core/Properties/Resources.resx index a8b608747e..b54dca221c 100644 --- a/src/core/AutoRest.Core/Properties/Resources.resx +++ b/src/core/AutoRest.Core/Properties/Resources.resx @@ -323,4 +323,7 @@ When property is modeled as "readOnly": true then x-ms-mutability extension can only have "read" value. When property is modeled as "readOnly": false then applying x-ms-mutability extension with only "read" value is not allowed. Extension contains invalid values: '{0}'. + + Booleans are not descriptive and make them hard to use. Instead use string enums with allowed set of values defined: '{0}'. + \ No newline at end of file diff --git a/src/core/AutoRest/Simplify/CSharpSimplifier.cs b/src/core/AutoRest/Simplify/CSharpSimplifier.cs index cb78770b0e..699e3db9b4 100644 --- a/src/core/AutoRest/Simplify/CSharpSimplifier.cs +++ b/src/core/AutoRest/Simplify/CSharpSimplifier.cs @@ -16,7 +16,6 @@ using Newtonsoft.Json; using AutoRest.Core.Utilities; using System.Net; -using System.Reflection; namespace AutoRest.Simplify { diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ApiManagement/2016-07-07/Microsoft.ApiManagement.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ApiManagement/2016-07-07/Microsoft.ApiManagement.json index b0c77a3ac6..aa01936876 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ApiManagement/2016-07-07/Microsoft.ApiManagement.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ApiManagement/2016-07-07/Microsoft.ApiManagement.json @@ -7,6 +7,18 @@ "service": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "The name of the Api Management service." + }, "type": { "type": "string", "enum": [ @@ -98,6 +110,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -109,6 +122,18 @@ "service_apis": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "API identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -144,6 +169,7 @@ } }, "required": [ + "name", "type", "apiVersion", "ApiContract" @@ -153,6 +179,9 @@ "service_apis_operations": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -178,6 +207,7 @@ } }, "required": [ + "name", "type", "apiVersion", "OperationContract" @@ -187,6 +217,9 @@ "service_authorizationServers": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -212,6 +245,7 @@ } }, "required": [ + "name", "type", "apiVersion", "OAuth2AuthorizationServerContract" @@ -221,6 +255,9 @@ "service_certificates": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -243,6 +280,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -251,6 +289,18 @@ "service_groups": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Group identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -263,12 +313,6 @@ "2016-07-07" ] }, - "name": { - "type": "string", - "minLength": 1, - "maxLength": 300, - "description": "Group name." - }, "description": { "type": "string", "description": "Group description." @@ -289,15 +333,27 @@ } }, "required": [ + "name", "type", - "apiVersion", - "name" + "apiVersion" ], "description": "Microsoft.ApiManagement/service/groups" }, "service_groups_users": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "User identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -312,6 +368,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -320,6 +377,9 @@ "service_loggers": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -363,6 +423,7 @@ } }, "required": [ + "name", "type", "apiVersion", "credentials" @@ -372,6 +433,9 @@ "service_openidConnectProviders": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -384,11 +448,6 @@ "2016-07-07" ] }, - "name": { - "type": "string", - "maxLength": 50, - "description": "User-friendly OpenID Connect Provider name." - }, "description": { "type": "string", "description": "User-friendly description of OpenID Connect Provider." @@ -407,9 +466,9 @@ } }, "required": [ + "name", "type", "apiVersion", - "name", "metadataEndpoint", "clientId" ], @@ -418,6 +477,18 @@ "service_products": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Product identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -455,6 +526,7 @@ } }, "required": [ + "name", "type", "apiVersion", "ProductContract" @@ -464,6 +536,18 @@ "service_products_apis": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "API identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -478,6 +562,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -486,6 +571,18 @@ "service_products_groups": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Group identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -500,6 +597,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -508,6 +606,9 @@ "service_properties": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -520,12 +621,6 @@ "2016-07-07" ] }, - "name": { - "type": "string", - "minLength": 1, - "maxLength": 256, - "description": "Unique name of Property." - }, "value": { "type": "string", "minLength": 1, @@ -559,9 +654,9 @@ } }, "required": [ + "name", "type", "apiVersion", - "name", "value" ], "description": "Microsoft.ApiManagement/service/properties" @@ -569,6 +664,9 @@ "service_subscriptions": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -589,10 +687,6 @@ "type": "string", "description": "Product (product id path) for which subscription is being created in form /products/{productid}" }, - "name": { - "type": "string", - "description": "Subscription name." - }, "primaryKey": { "type": "string", "minLength": 1, @@ -626,17 +720,29 @@ } }, "required": [ + "name", "type", "apiVersion", "userId", - "productId", - "name" + "productId" ], "description": "Microsoft.ApiManagement/service/subscriptions" }, "service_users": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "User identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -690,6 +796,7 @@ } }, "required": [ + "name", "type", "apiVersion", "email", @@ -1559,6 +1666,18 @@ "service_apis_childResource": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "API identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -1594,6 +1713,7 @@ } }, "required": [ + "name", "type", "apiVersion", "ApiContract" @@ -1603,6 +1723,9 @@ "service_apis_operations_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1628,6 +1751,7 @@ } }, "required": [ + "name", "type", "apiVersion", "OperationContract" @@ -1637,6 +1761,9 @@ "service_authorizationServers_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1662,6 +1789,7 @@ } }, "required": [ + "name", "type", "apiVersion", "OAuth2AuthorizationServerContract" @@ -1671,6 +1799,9 @@ "service_certificates_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1693,6 +1824,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -1701,6 +1833,18 @@ "service_groups_childResource": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Group identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -1713,10 +1857,6 @@ "2016-07-07" ] }, - "name": { - "type": "string", - "description": "Group name." - }, "description": { "type": "string", "description": "Group description." @@ -1737,15 +1877,27 @@ } }, "required": [ + "name", "type", - "apiVersion", - "name" + "apiVersion" ], "description": "Microsoft.ApiManagement/service/groups" }, "service_groups_users_childResource": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "User identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -1760,6 +1912,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -1768,6 +1921,9 @@ "service_loggers_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1811,6 +1967,7 @@ } }, "required": [ + "name", "type", "apiVersion", "credentials" @@ -1820,6 +1977,9 @@ "service_openidConnectProviders_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1832,10 +1992,6 @@ "2016-07-07" ] }, - "name": { - "type": "string", - "description": "User-friendly OpenID Connect Provider name." - }, "description": { "type": "string", "description": "User-friendly description of OpenID Connect Provider." @@ -1854,9 +2010,9 @@ } }, "required": [ + "name", "type", "apiVersion", - "name", "metadataEndpoint", "clientId" ], @@ -1865,6 +2021,18 @@ "service_products_apis_childResource": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "API identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -1879,6 +2047,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -1887,6 +2056,18 @@ "service_products_childResource": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Product identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -1924,6 +2105,7 @@ } }, "required": [ + "name", "type", "apiVersion", "ProductContract" @@ -1933,6 +2115,18 @@ "service_products_groups_childResource": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Group identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -1947,6 +2141,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -1955,6 +2150,9 @@ "service_properties_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1967,10 +2165,6 @@ "2016-07-07" ] }, - "name": { - "type": "string", - "description": "Unique name of Property." - }, "value": { "type": "string", "description": "The Value of the Property." @@ -2002,9 +2196,9 @@ } }, "required": [ + "name", "type", "apiVersion", - "name", "value" ], "description": "Microsoft.ApiManagement/service/properties" @@ -2012,6 +2206,9 @@ "service_subscriptions_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -2032,10 +2229,6 @@ "type": "string", "description": "Product (product id path) for which subscription is being created in form /products/{productid}" }, - "name": { - "type": "string", - "description": "Subscription name." - }, "primaryKey": { "type": "string", "description": "Primary subscription key. If not specified during request key will be generated automatically." @@ -2065,17 +2258,29 @@ } }, "required": [ + "name", "type", "apiVersion", "userId", - "productId", - "name" + "productId" ], "description": "Microsoft.ApiManagement/service/subscriptions" }, "service_users_childResource": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[^*#&+:<>?]+$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "User identifier. Must be unique in the current API Management service instance." + }, "type": { "type": "string", "enum": [ @@ -2125,6 +2330,7 @@ } }, "required": [ + "name", "type", "apiVersion", "email", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ApiManagement/2016-07-07b/Microsoft.ApiManagement.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ApiManagement/2016-07-07b/Microsoft.ApiManagement.json index 3ad405bc9e..8656790fce 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ApiManagement/2016-07-07b/Microsoft.ApiManagement.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ApiManagement/2016-07-07b/Microsoft.ApiManagement.json @@ -7,6 +7,18 @@ "service": { "type": "object", "properties": { + "name": { + "oneOf": [ + { + "type": "string", + "pattern": "^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "The name of the Api Management service." + }, "type": { "type": "string", "enum": [ @@ -61,6 +73,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Batch/2015-12-01/Microsoft.Batch.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Batch/2015-12-01/Microsoft.Batch.json index 919093e851..9e7c76e130 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Batch/2015-12-01/Microsoft.Batch.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Batch/2015-12-01/Microsoft.Batch.json @@ -7,6 +7,9 @@ "batchAccounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -60,6 +63,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -69,6 +73,9 @@ "batchAccounts_applications": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -108,6 +115,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -116,6 +124,9 @@ "batchAccounts_applications_versions": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -130,6 +141,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -170,6 +182,9 @@ "batchAccounts_applications_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -209,6 +224,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -217,6 +233,9 @@ "batchAccounts_applications_versions_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -231,6 +250,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CDN/2015-06-01/Microsoft.Cdn.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CDN/2015-06-01/Microsoft.Cdn.json index 8f5ba0b846..c820d7d05c 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CDN/2015-06-01/Microsoft.Cdn.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CDN/2015-06-01/Microsoft.Cdn.json @@ -7,6 +7,9 @@ "profiles": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -59,6 +62,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -69,6 +73,9 @@ "profiles_endpoints": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -124,6 +131,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -134,6 +142,9 @@ "profiles_endpoints_customDomains": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -158,6 +169,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -167,6 +179,9 @@ "profiles_endpoints_origins": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -191,6 +206,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -419,6 +435,9 @@ "profiles_endpoints_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -474,6 +493,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -484,6 +504,9 @@ "profiles_endpoints_customDomains_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -508,6 +531,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -517,6 +541,9 @@ "profiles_endpoints_origins_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -541,6 +568,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CDN/2016-04-02/Microsoft.Cdn.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CDN/2016-04-02/Microsoft.Cdn.json index 5c9d5c86e3..36db2f53a4 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CDN/2016-04-02/Microsoft.Cdn.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CDN/2016-04-02/Microsoft.Cdn.json @@ -7,6 +7,9 @@ "profiles": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -60,6 +63,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -70,6 +74,9 @@ "profiles_endpoints": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -125,6 +132,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -135,6 +143,9 @@ "profiles_endpoints_customDomains": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -159,6 +170,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -168,6 +180,9 @@ "profiles_endpoints_origins": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -192,6 +207,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -401,6 +417,9 @@ "profiles_endpoints_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -456,6 +475,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -466,6 +486,9 @@ "profiles_endpoints_customDomains_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -490,6 +513,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -499,6 +523,9 @@ "profiles_endpoints_origins_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -523,6 +550,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CognitiveServices/2016-02-01-preview/Microsoft.CognitiveServices.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CognitiveServices/2016-02-01-preview/Microsoft.CognitiveServices.json index 36ebc62b3b..8219dc3fa2 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CognitiveServices/2016-02-01-preview/Microsoft.CognitiveServices.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/CognitiveServices/2016-02-01-preview/Microsoft.CognitiveServices.json @@ -7,6 +7,9 @@ "accounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -69,18 +72,11 @@ "description": "Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters." }, "properties": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Must exist in the request. Must not be null." } }, "required": [ + "name", "type", "apiVersion", "sku", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Compute/2015-06-15/Microsoft.Compute.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Compute/2015-06-15/Microsoft.Compute.json index e39b90a1dd..1ee3427eb0 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Compute/2015-06-15/Microsoft.Compute.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Compute/2015-06-15/Microsoft.Compute.json @@ -7,6 +7,9 @@ "availabilitySets": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -49,6 +52,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -59,6 +63,9 @@ "virtualMachines": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -122,6 +129,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -132,6 +140,9 @@ "virtualMachines_extensions": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -174,6 +185,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -184,6 +196,9 @@ "virtualMachineScaleSets": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -237,6 +252,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1263,25 +1279,9 @@ "description": "Gets or sets whether the extension handler should be automatically upgraded across minor versions." }, "settings": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Gets or sets Json formatted public settings for the extension." }, "protectedSettings": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Gets or sets Json formatted protected settings for the extension." }, "provisioningState": { @@ -1385,6 +1385,9 @@ "virtualMachines_extensions_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1427,6 +1430,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1505,25 +1509,9 @@ "description": "Gets or sets whether the extension handler should be automatically upgraded across minor versions." }, "settings": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Gets or sets Json formatted public settings for the extension." }, "protectedSettings": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Gets or sets Json formatted protected settings for the extension." } }, diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Compute/2016-03-30/Microsoft.Compute.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Compute/2016-03-30/Microsoft.Compute.json index 9961a4efd5..f48c882e04 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Compute/2016-03-30/Microsoft.Compute.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Compute/2016-03-30/Microsoft.Compute.json @@ -7,6 +7,9 @@ "availabilitySets": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -49,6 +52,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -59,6 +63,9 @@ "virtualMachines": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -122,6 +129,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -132,6 +140,9 @@ "virtualMachines_extensions": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -174,6 +185,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -184,6 +196,9 @@ "virtualMachineScaleSets": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -237,6 +252,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1261,25 +1277,9 @@ "description": "whether the extension handler should be automatically upgraded across minor versions." }, "settings": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Json formatted public settings for the extension." }, "protectedSettings": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Json formatted protected settings for the extension." }, "instanceView": { @@ -1375,6 +1375,9 @@ "virtualMachines_extensions_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1417,6 +1420,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1495,25 +1499,9 @@ "description": "whether the extension handler should be automatically upgraded across minor versions." }, "settings": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Json formatted public settings for the extension." }, "protectedSettings": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Json formatted protected settings for the extension." } }, diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ContainerService/2016-03-30/Microsoft.ContainerService.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ContainerService/2016-03-30/Microsoft.ContainerService.json index 04a814cdfb..5bf0475152 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ContainerService/2016-03-30/Microsoft.ContainerService.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ContainerService/2016-03-30/Microsoft.ContainerService.json @@ -7,6 +7,9 @@ "containerServices": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -49,6 +52,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DNS/2015-05-04-preview/Microsoft.Network.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DNS/2015-05-04-preview/Microsoft.Network.json index c06f5906a6..445cd2b1cf 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DNS/2015-05-04-preview/Microsoft.Network.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DNS/2015-05-04-preview/Microsoft.Network.json @@ -7,6 +7,9 @@ "dnszones": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -88,6 +91,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -98,6 +102,9 @@ "dnszones_A": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -145,6 +152,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -155,6 +163,9 @@ "dnszones_AAAA": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -202,6 +213,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -212,6 +224,9 @@ "dnszones_CNAME": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -259,6 +274,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -269,6 +285,9 @@ "dnszones_MX": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -316,6 +335,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -326,6 +346,9 @@ "dnszones_NS": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -373,6 +396,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -383,6 +407,9 @@ "dnszones_PTR": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -430,6 +457,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -440,6 +468,9 @@ "dnszones_SOA": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -487,6 +518,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -497,6 +529,9 @@ "dnszones_SRV": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -544,6 +579,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -554,6 +590,9 @@ "dnszones_TXT": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -601,6 +640,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -643,6 +683,9 @@ "dnszones_A_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -690,6 +733,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -700,6 +744,9 @@ "dnszones_AAAA_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -747,6 +794,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -757,6 +805,9 @@ "dnszones_CNAME_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -804,6 +855,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -814,6 +866,9 @@ "dnszones_MX_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -861,6 +916,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -871,6 +927,9 @@ "dnszones_NS_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -918,6 +977,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -928,6 +988,9 @@ "dnszones_PTR_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -975,6 +1038,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -985,6 +1049,9 @@ "dnszones_SOA_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1032,6 +1099,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1042,6 +1110,9 @@ "dnszones_SRV_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1089,6 +1160,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1099,6 +1171,9 @@ "dnszones_TXT_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1146,6 +1221,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DNS/2016-04-01/Microsoft.Network.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DNS/2016-04-01/Microsoft.Network.json index d4147174b7..3ee92f83ca 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DNS/2016-04-01/Microsoft.Network.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DNS/2016-04-01/Microsoft.Network.json @@ -7,6 +7,9 @@ "dnszones": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -88,6 +91,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -98,6 +102,9 @@ "dnszones_A": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -114,10 +121,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -139,6 +142,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -148,6 +152,9 @@ "dnszones_AAAA": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -164,10 +171,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -189,6 +192,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -198,6 +202,9 @@ "dnszones_CNAME": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -214,10 +221,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -239,6 +242,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -248,6 +252,9 @@ "dnszones_MX": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -264,10 +271,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -289,6 +292,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -298,6 +302,9 @@ "dnszones_NS": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -314,10 +321,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -339,6 +342,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -348,6 +352,9 @@ "dnszones_PTR": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -364,10 +371,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -389,6 +392,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -398,6 +402,9 @@ "dnszones_SOA": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -414,10 +421,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -439,6 +442,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -448,6 +452,9 @@ "dnszones_SRV": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -464,10 +471,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -489,6 +492,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -498,6 +502,9 @@ "dnszones_TXT": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -514,10 +521,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -539,6 +542,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -580,6 +584,9 @@ "dnszones_A_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -596,10 +603,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -621,6 +624,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -630,6 +634,9 @@ "dnszones_AAAA_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -646,10 +653,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -671,6 +674,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -680,6 +684,9 @@ "dnszones_CNAME_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -696,10 +703,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -721,6 +724,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -730,6 +734,9 @@ "dnszones_MX_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -746,10 +753,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -771,6 +774,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -780,6 +784,9 @@ "dnszones_NS_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -796,10 +803,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -821,6 +824,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -830,6 +834,9 @@ "dnszones_PTR_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -846,10 +853,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -871,6 +874,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -880,6 +884,9 @@ "dnszones_SOA_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -896,10 +903,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -921,6 +924,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -930,6 +934,9 @@ "dnszones_SRV_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -946,10 +953,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -971,6 +974,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -980,6 +984,9 @@ "dnszones_TXT_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -996,10 +1003,6 @@ "type": "string", "description": "Gets or sets the ID of the resource." }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource." - }, "etag": { "type": "string", "description": "Gets or sets the ETag of the RecordSet." @@ -1021,6 +1024,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DataLakeAnalytics/2015-10-01-preview/Microsoft.DataLakeAnalytics.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DataLakeAnalytics/2015-10-01-preview/Microsoft.DataLakeAnalytics.json index c6fc02151e..77226cb638 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DataLakeAnalytics/2015-10-01-preview/Microsoft.DataLakeAnalytics.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DataLakeAnalytics/2015-10-01-preview/Microsoft.DataLakeAnalytics.json @@ -7,6 +7,9 @@ "accounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -23,10 +26,6 @@ "type": "string", "description": "Gets or sets the account regional location." }, - "name": { - "type": "string", - "description": "Gets or sets the account name." - }, "tags": { "oneOf": [ { @@ -67,6 +66,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -76,6 +76,9 @@ "accounts_DataLakeStoreAccounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -101,6 +104,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -110,6 +114,9 @@ "accounts_StorageAccounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -135,6 +142,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -146,6 +154,9 @@ "accounts_DataLakeStoreAccounts_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -171,6 +182,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -180,6 +192,9 @@ "accounts_StorageAccounts_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -205,6 +220,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DataLakeStore/2015-10-01-preview/Microsoft.DataLakeStore.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DataLakeStore/2015-10-01-preview/Microsoft.DataLakeStore.json index 41f0734ae9..886ef1fb66 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DataLakeStore/2015-10-01-preview/Microsoft.DataLakeStore.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/DataLakeStore/2015-10-01-preview/Microsoft.DataLakeStore.json @@ -7,6 +7,9 @@ "accounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -23,10 +26,6 @@ "type": "string", "description": "Gets or sets the account regional location." }, - "name": { - "type": "string", - "description": "Gets or sets the account name." - }, "tags": { "oneOf": [ { @@ -64,6 +63,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -73,6 +73,9 @@ "accounts_firewallRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -85,10 +88,6 @@ "2015-10-01-preview" ] }, - "name": { - "type": "string", - "description": "Gets or sets the firewall rule's name." - }, "id": { "type": "string", "description": "Gets or sets the firewall rule's subscription ID." @@ -110,6 +109,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -121,6 +121,9 @@ "accounts_firewallRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -133,10 +136,6 @@ "2015-10-01-preview" ] }, - "name": { - "type": "string", - "description": "Gets or sets the firewall rule's name." - }, "id": { "type": "string", "description": "Gets or sets the firewall rule's subscription ID." @@ -158,6 +157,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Logic/2015-02-01-preview/Microsoft.Logic.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Logic/2015-02-01-preview/Microsoft.Logic.json index 968687ef29..edd3ac0cfb 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Logic/2015-02-01-preview/Microsoft.Logic.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Logic/2015-02-01-preview/Microsoft.Logic.json @@ -7,6 +7,9 @@ "workflows": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -23,10 +26,6 @@ "type": "string", "description": "Gets or sets the resource id." }, - "name": { - "type": "string", - "description": "Gets the resource name." - }, "location": { "type": "string", "description": "Gets or sets the resource location." @@ -68,6 +67,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -77,6 +77,9 @@ "workflows_accessKeys": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -106,6 +109,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -161,14 +165,6 @@ "description": "Gets or sets the content hash." }, "metadata": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Gets or sets the metadata." } } @@ -251,25 +247,9 @@ "description": "Gets or sets the type." }, "value": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Gets or sets the value." }, "metadata": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Gets or sets the metadata." } } @@ -318,14 +298,6 @@ "description": "Gets or sets the link to definition." }, "definition": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Gets or sets the definition." }, "parametersLink": { @@ -358,6 +330,9 @@ "workflows_accessKeys_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -387,6 +362,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Logic/2016-06-01/Microsoft.Logic.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Logic/2016-06-01/Microsoft.Logic.json index ed7fe99113..11e738b633 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Logic/2016-06-01/Microsoft.Logic.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Logic/2016-06-01/Microsoft.Logic.json @@ -7,6 +7,9 @@ "workflows": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -23,10 +26,6 @@ "type": "string", "description": "The resource id." }, - "name": { - "type": "string", - "description": "Gets the resource name." - }, "location": { "type": "string", "description": "The resource location." @@ -58,6 +57,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -129,25 +129,9 @@ "description": "The type." }, "value": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "The value." }, "metadata": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "The metadata." }, "description": { @@ -201,14 +185,6 @@ "description": "The integration account." }, "definition": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "The definition." }, "parameters": { diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/MachineLearning/2016-05-01-preview/Microsoft.MachineLearning.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/MachineLearning/2016-05-01-preview/Microsoft.MachineLearning.json index 8acd9f16de..7d61f27adb 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/MachineLearning/2016-05-01-preview/Microsoft.MachineLearning.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/MachineLearning/2016-05-01-preview/Microsoft.MachineLearning.json @@ -7,6 +7,9 @@ "webServices": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -19,10 +22,6 @@ "2016-05-01-preview" ] }, - "name": { - "type": "string", - "description": "Resource Name" - }, "location": { "type": "string", "description": "Resource Location" @@ -54,6 +53,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -219,9 +219,7 @@ "oneOf": [ { "type": "array", - "items": { - "type": "object" - } + "items": {} }, { "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" @@ -311,9 +309,7 @@ "type": "array", "items": { "type": "array", - "items": { - "type": "object" - } + "items": {} } } }, @@ -327,9 +323,7 @@ "oneOf": [ { "type": "object", - "additionalProperties": { - "type": "object" - } + "additionalProperties": {} }, { "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" @@ -727,164 +721,194 @@ }, "WebServiceProperties": { "type": "object", - "properties": { - "title": { - "type": "string", - "description": "The title of the Azure ML web service." - }, - "description": { - "type": "string", - "description": "The description of the Azure ML web service." - }, - "keys": { - "oneOf": [ - { - "$ref": "#/definitions/WebServiceKeys" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "The set of access keys for the web service. If not specified at creation time (PUT), they will be generated automatically by the resource provider." - }, - "readOnly": { - "oneOf": [ - { - "type": "boolean" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "If true, the web service can no longer be updated / patched, only removed. Otherwise, the service resource supports changes." - }, - "exposeSampleData": { - "oneOf": [ - { - "type": "boolean" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "Flag that controls whether to expose sample data or not in the web service's swagger definition." - }, - "realtimeConfiguration": { - "oneOf": [ - { - "$ref": "#/definitions/RealtimeConfiguration" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "Configuration for the service's realtime endpoint." - }, - "diagnostics": { - "oneOf": [ - { - "$ref": "#/definitions/DiagnosticsConfiguration" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "Settings controlling the diagnostics traces collection for the web service." - }, - "storageAccount": { - "oneOf": [ - { - "$ref": "#/definitions/StorageAccount" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "The storage account associated with the service. This is used to store both datasets and diagnostic traces. This information is required at creation time (PUT) and only the key is updateable after that. The account credentials are hidden on a GET web service call." - }, - "machineLearningWorkspace": { - "oneOf": [ - { - "$ref": "#/definitions/MachineLearningWorkspace" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "This is only populated at creation time (PUT) for web services originating from an AzureML Studio experiment." - }, - "commitmentPlan": { - "oneOf": [ - { - "$ref": "#/definitions/CommitmentPlan" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "The commitment plan associated with this web service. This is required to be specified at creation time (PUT) and is not updateable afterwards." - }, - "input": { - "oneOf": [ - { - "$ref": "#/definitions/ServiceInputOutputSpecification" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "Swagger schema for the service's input(s), as applicable." - }, - "output": { - "oneOf": [ - { - "$ref": "#/definitions/ServiceInputOutputSpecification" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "Swagger schema for the service's output(s), as applicable." - }, - "exampleRequest": { - "oneOf": [ - { - "$ref": "#/definitions/ExampleRequest" + "allOf": [ + { + "properties": { + "packageType": { + "oneOf": [ + { + "type": "string", + "enum": [ + "Graph" + ] + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ] }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], - "description": "Sample request data for each of the service's inputs, as applicable." - }, - "assets": { - "oneOf": [ - { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/AssetItem" - } + "title": { + "type": "string", + "description": "The title of the Azure ML web service." }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + "description": { + "type": "string", + "description": "The description of the Azure ML web service." + }, + "keys": { + "oneOf": [ + { + "$ref": "#/definitions/WebServiceKeys" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "The set of access keys for the web service. If not specified at creation time (PUT), they will be generated automatically by the resource provider." + }, + "readOnly": { + "oneOf": [ + { + "type": "boolean" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "If true, the web service can no longer be updated / patched, only removed. Otherwise, the service resource supports changes." + }, + "exposeSampleData": { + "oneOf": [ + { + "type": "boolean" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Flag that controls whether to expose sample data or not in the web service's swagger definition." + }, + "realtimeConfiguration": { + "oneOf": [ + { + "$ref": "#/definitions/RealtimeConfiguration" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Configuration for the service's realtime endpoint." + }, + "diagnostics": { + "oneOf": [ + { + "$ref": "#/definitions/DiagnosticsConfiguration" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Settings controlling the diagnostics traces collection for the web service." + }, + "storageAccount": { + "oneOf": [ + { + "$ref": "#/definitions/StorageAccount" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "The storage account associated with the service. This is used to store both datasets and diagnostic traces. This information is required at creation time (PUT) and only the key is updateable after that. The account credentials are hidden on a GET web service call." + }, + "machineLearningWorkspace": { + "oneOf": [ + { + "$ref": "#/definitions/MachineLearningWorkspace" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "This is only populated at creation time (PUT) for web services originating from an AzureML Studio experiment." + }, + "commitmentPlan": { + "oneOf": [ + { + "$ref": "#/definitions/CommitmentPlan" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "The commitment plan associated with this web service. This is required to be specified at creation time (PUT) and is not updateable afterwards." + }, + "input": { + "oneOf": [ + { + "$ref": "#/definitions/ServiceInputOutputSpecification" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Swagger schema for the service's input(s), as applicable." + }, + "output": { + "oneOf": [ + { + "$ref": "#/definitions/ServiceInputOutputSpecification" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Swagger schema for the service's output(s), as applicable." + }, + "exampleRequest": { + "oneOf": [ + { + "$ref": "#/definitions/ExampleRequest" + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Sample request data for each of the service's inputs, as applicable." + }, + "assets": { + "oneOf": [ + { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/AssetItem" + } + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "Set of assets associated with the web service." + }, + "parameters": { + "oneOf": [ + { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + { + "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + } + ], + "description": "The set of global parameters values defined for the web service, given as a global parameter name to default value map. If no default value is specified, the parameter is considered to be required." } - ], - "description": "Set of assets associated with the web service." + } }, - "parameters": { - "oneOf": [ - { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, + { + "anyOf": [ { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" + "$ref": "#/definitions/WebServicePropertiesForGraph" } - ], - "description": "The set of global parameters values defined for the web service, given as a global parameter name to default value map. If no default value is specified, the parameter is considered to be required." - }, + ] + } + ], + "description": "The set of properties specific to the Azure ML web service resource." + }, + "WebServicePropertiesForGraph": { + "type": "object", + "properties": { "package": { "oneOf": [ { @@ -895,22 +919,9 @@ } ], "description": "The definition of the graph package making up this web service." - }, - "packageType": { - "oneOf": [ - { - "type": "string", - "enum": [ - "Graph" - ] - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ] } }, - "description": "The set of properties specific to the Azure ML web service resource." + "description": "Properties specific to a Graph based web service." } } } diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2015-05-01-preview/Microsoft.Network.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2015-05-01-preview/Microsoft.Network.json index 44f1d48cad..68b3daa4c3 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2015-05-01-preview/Microsoft.Network.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2015-05-01-preview/Microsoft.Network.json @@ -7,6 +7,9 @@ "applicationGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -53,6 +56,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -63,6 +67,9 @@ "connections": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -109,6 +116,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -119,6 +127,9 @@ "expressRouteCircuits_authorizations": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -145,16 +156,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -164,6 +172,9 @@ "expressRouteCircuits_peerings": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -190,16 +201,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -209,6 +217,9 @@ "loadBalancers": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -255,6 +266,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -265,6 +277,9 @@ "localNetworkGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -311,6 +326,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -321,6 +337,9 @@ "networkInterfaces": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -367,6 +386,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -377,6 +397,9 @@ "networkSecurityGroups": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -433,6 +456,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -443,6 +467,9 @@ "networkSecurityGroups_securityRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -469,16 +496,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -488,6 +512,9 @@ "routeTables": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -544,6 +571,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -554,6 +582,9 @@ "routeTables_routes": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -580,16 +611,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -599,6 +627,9 @@ "virtualnetworkgateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -645,6 +676,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -655,6 +687,9 @@ "virtualnetworks": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -711,6 +746,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -721,6 +757,9 @@ "virtualnetworks_subnets": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -747,16 +786,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -2851,6 +2887,9 @@ "networkSecurityGroups_securityRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -2877,16 +2916,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -3186,6 +3222,9 @@ "routeTables_routes_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3212,16 +3251,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -3816,6 +3852,9 @@ "virtualnetworks_subnets_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3842,16 +3881,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2015-06-15/Microsoft.Network.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2015-06-15/Microsoft.Network.json index 7d75d533c4..de29eff6ad 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2015-06-15/Microsoft.Network.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2015-06-15/Microsoft.Network.json @@ -7,6 +7,9 @@ "applicationGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -57,6 +60,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -66,6 +70,9 @@ "connections": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -116,6 +123,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -125,6 +133,9 @@ "expressRouteCircuits_authorizations": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -151,16 +162,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -170,6 +178,9 @@ "expressRouteCircuits_peerings": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -196,16 +207,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -215,6 +223,9 @@ "loadBalancers": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -265,6 +276,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -274,6 +286,9 @@ "localNetworkGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -324,6 +339,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -333,6 +349,9 @@ "networkInterfaces": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -383,6 +402,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -392,6 +412,9 @@ "networkSecurityGroups": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -452,6 +475,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -461,6 +485,9 @@ "networkSecurityGroups_securityRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -487,16 +514,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -506,6 +530,9 @@ "publicIPAddresses": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -556,6 +583,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -565,6 +593,9 @@ "routeTables": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -625,6 +656,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -634,6 +666,9 @@ "routeTables_routes": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -660,16 +695,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -679,6 +711,9 @@ "virtualnetworkgateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -729,6 +764,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -738,6 +774,9 @@ "virtualnetworks": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -798,6 +837,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -807,6 +847,9 @@ "virtualnetworks_subnets": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -833,16 +876,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -3451,6 +3491,9 @@ "networkSecurityGroups_securityRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3477,16 +3520,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -3951,6 +3991,9 @@ "routeTables_routes_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3977,16 +4020,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -4676,6 +4716,9 @@ "virtualnetworks_subnets_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4702,16 +4745,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2016-03-30/Microsoft.Network.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2016-03-30/Microsoft.Network.json index 1998db8083..6742a2a723 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2016-03-30/Microsoft.Network.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2016-03-30/Microsoft.Network.json @@ -7,6 +7,9 @@ "applicationGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -57,6 +60,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -66,6 +70,9 @@ "connections": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -116,6 +123,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -125,6 +133,9 @@ "expressRouteCircuits": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -199,6 +210,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -208,6 +220,9 @@ "expressRouteCircuits_authorizations": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -234,16 +249,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -253,6 +265,9 @@ "expressRouteCircuits_peerings": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -279,16 +294,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -298,6 +310,9 @@ "loadBalancers": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -348,6 +363,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -357,6 +373,9 @@ "localNetworkGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -407,6 +426,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -416,6 +436,9 @@ "networkInterfaces": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -466,6 +489,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -475,6 +499,9 @@ "networkSecurityGroups": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -535,6 +562,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -544,6 +572,9 @@ "networkSecurityGroups_securityRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -570,16 +601,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -589,6 +617,9 @@ "publicIPAddresses": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -639,6 +670,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -648,6 +680,9 @@ "routeTables": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -708,6 +743,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -717,6 +753,9 @@ "routeTables_routes": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -743,16 +782,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -762,6 +798,9 @@ "virtualnetworkgateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -812,6 +851,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -821,6 +861,9 @@ "virtualnetworks": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -881,6 +924,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -890,6 +934,9 @@ "virtualnetworks_subnets": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -916,16 +963,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -2485,6 +2529,9 @@ "expressRouteCircuits_authorizations_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -2511,16 +2558,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -2530,6 +2574,9 @@ "expressRouteCircuits_peerings_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -2556,16 +2603,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -3889,6 +3933,9 @@ "networkSecurityGroups_securityRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3915,16 +3962,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -4404,6 +4448,9 @@ "routeTables_routes_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4430,16 +4477,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -5129,6 +5173,9 @@ "virtualnetworks_subnets_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -5155,16 +5202,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2016-09-01/Microsoft.Network.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2016-09-01/Microsoft.Network.json index 9e159b6249..2bca7c858b 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2016-09-01/Microsoft.Network.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Network/2016-09-01/Microsoft.Network.json @@ -7,6 +7,9 @@ "applicationGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -57,6 +60,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -66,6 +70,9 @@ "connections": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -116,6 +123,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -125,6 +133,9 @@ "expressRouteCircuits": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -199,6 +210,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -208,6 +220,9 @@ "expressRouteCircuits_authorizations": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -234,16 +249,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -253,6 +265,9 @@ "expressRouteCircuits_peerings": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -279,16 +294,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -298,6 +310,9 @@ "loadBalancers": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -348,6 +363,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -357,6 +373,9 @@ "localNetworkGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -407,6 +426,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -416,6 +436,9 @@ "networkInterfaces": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -466,6 +489,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -475,6 +499,9 @@ "networkSecurityGroups": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -535,6 +562,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -544,6 +572,9 @@ "networkSecurityGroups_securityRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -570,16 +601,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -589,6 +617,9 @@ "publicIPAddresses": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -639,6 +670,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -648,6 +680,9 @@ "routeTables": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -708,6 +743,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -717,6 +753,9 @@ "routeTables_routes": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -743,16 +782,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -762,6 +798,9 @@ "virtualNetworkGateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -812,6 +851,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -821,6 +861,9 @@ "virtualNetworks": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -884,6 +927,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -893,6 +937,9 @@ "virtualNetworks_subnets": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -919,16 +966,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -938,6 +982,9 @@ "virtualNetworks_virtualNetworkPeerings": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -964,16 +1011,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -2661,6 +2705,9 @@ "expressRouteCircuits_authorizations_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -2687,16 +2734,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -2706,6 +2750,9 @@ "expressRouteCircuits_peerings_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -2732,16 +2779,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -3871,6 +3915,9 @@ "networkSecurityGroups_securityRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3897,16 +3944,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -4386,6 +4430,9 @@ "routeTables_routes_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4412,16 +4459,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -5242,6 +5286,9 @@ "virtualNetworks_subnets_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -5268,16 +5315,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -5287,6 +5331,9 @@ "virtualNetworks_virtualNetworkPeerings_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -5313,16 +5360,13 @@ } ] }, - "name": { - "type": "string", - "description": "Gets or sets the name of the resource that is unique within a resource group. This name can be used to access the resource" - }, "etag": { "type": "string", "description": "A unique read-only string that changes whenever the resource is updated" } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/NotificationHubs/2016-03-01/Microsoft.NotificationHubs.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/NotificationHubs/2016-03-01/Microsoft.NotificationHubs.json index be93d27a1e..6742c9985e 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/NotificationHubs/2016-03-01/Microsoft.NotificationHubs.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/NotificationHubs/2016-03-01/Microsoft.NotificationHubs.json @@ -7,6 +7,9 @@ "namespaces": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -74,6 +77,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -84,6 +88,9 @@ "namespaces_AuthorizationRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -138,6 +145,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -148,6 +156,9 @@ "namespaces_notificationHubs": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -212,6 +223,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -222,6 +234,9 @@ "namespaces_notificationHubs_AuthorizationRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -276,6 +291,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -539,6 +555,9 @@ "namespaces_AuthorizationRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -593,6 +612,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -603,6 +623,9 @@ "namespaces_notificationHubs_AuthorizationRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -657,6 +680,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -667,6 +691,9 @@ "namespaces_notificationHubs_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -731,6 +758,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/PowerBIEmbedded/2016-01-29/Microsoft.PowerBI.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/PowerBIEmbedded/2016-01-29/Microsoft.PowerBI.json index b7b4c9e0c3..0952f82d2f 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/PowerBIEmbedded/2016-01-29/Microsoft.PowerBI.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/PowerBIEmbedded/2016-01-29/Microsoft.PowerBI.json @@ -7,6 +7,9 @@ "workspaceCollections": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -48,6 +51,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/RecoveryServices/2016-06-01/Microsoft.RecoveryServices.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/RecoveryServices/2016-06-01/Microsoft.RecoveryServices.json index 1d98a862a4..5c865a9b5f 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/RecoveryServices/2016-06-01/Microsoft.RecoveryServices.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/RecoveryServices/2016-06-01/Microsoft.RecoveryServices.json @@ -7,6 +7,10 @@ "vaults": { "type": "object", "properties": { + "name": { + "type": "string", + "description": "The name of the recovery services vault." + }, "type": { "type": "string", "enum": [ @@ -59,6 +63,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -92,7 +97,6 @@ "description": "Identifies the unique system identifier for each Azure resource." }, "VaultProperties": { - "type": "object", "description": "Properties of the vault." } } diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Redis/2016-04-01/Microsoft.Cache.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Redis/2016-04-01/Microsoft.Cache.json index f74a7f3f77..74a59b8713 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Redis/2016-04-01/Microsoft.Cache.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Redis/2016-04-01/Microsoft.Cache.json @@ -7,6 +7,9 @@ "Redis": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -50,6 +53,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Resources/Locks/2016-09-01/Microsoft.Authorization.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Resources/Locks/2016-09-01/Microsoft.Authorization.json index 1efb549abc..6542f564dd 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Resources/Locks/2016-09-01/Microsoft.Authorization.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Resources/Locks/2016-09-01/Microsoft.Authorization.json @@ -7,6 +7,9 @@ "locks": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -29,13 +32,10 @@ } ], "description": "The properties of the lock." - }, - "name": { - "type": "string", - "description": "The name of the lock." } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Resources/Resources/2016-09-01/Microsoft.Resources.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Resources/Resources/2016-09-01/Microsoft.Resources.json index 625d86f2b8..db29f51fbf 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Resources/Resources/2016-09-01/Microsoft.Resources.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Resources/Resources/2016-09-01/Microsoft.Resources.json @@ -7,6 +7,9 @@ "deployments": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -32,6 +35,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -53,14 +57,6 @@ "type": "object", "properties": { "template": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "The template content. It can be a JObject or a well formed JSON string. Use only one of Template or TemplateLink." }, "templateLink": { @@ -75,14 +71,6 @@ "description": "The template URI. Use only one of Template or TemplateLink." }, "parameters": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Deployment parameters. It can be a JObject or a well formed JSON string. Use only one of Parameters or ParametersLink." }, "parametersLink": { diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Scheduler/2016-03-01/Microsoft.Scheduler.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Scheduler/2016-03-01/Microsoft.Scheduler.json index 7b4a0ca54d..b9277dfd1b 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Scheduler/2016-03-01/Microsoft.Scheduler.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Scheduler/2016-03-01/Microsoft.Scheduler.json @@ -7,6 +7,9 @@ "jobCollections": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -19,10 +22,6 @@ "2016-03-01" ] }, - "name": { - "type": "string", - "description": "Gets or sets the job collection resource name." - }, "location": { "type": "string", "description": "Gets or sets the storage account location." @@ -64,6 +63,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -73,6 +73,9 @@ "jobCollections_jobs": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -98,6 +101,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -330,6 +334,9 @@ "jobCollections_jobs_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -355,6 +362,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Search/2015-02-28/Microsoft.Search.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Search/2015-02-28/Microsoft.Search.json index d8d58857f0..a827357790 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Search/2015-02-28/Microsoft.Search.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Search/2015-02-28/Microsoft.Search.json @@ -7,6 +7,9 @@ "searchServices": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -50,6 +53,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ServerManagement/2016-07-01-preview/Microsoft.ServerManagement.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ServerManagement/2016-07-01-preview/Microsoft.ServerManagement.json index 6aa9fe6937..038a510bcf 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ServerManagement/2016-07-01-preview/Microsoft.ServerManagement.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ServerManagement/2016-07-01-preview/Microsoft.ServerManagement.json @@ -7,6 +7,9 @@ "gateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -24,14 +27,6 @@ "description": "location of the resource" }, "tags": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "resource tags" }, "properties": { @@ -47,6 +42,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -56,6 +52,9 @@ "nodes": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -73,14 +72,6 @@ "description": "location of the resource?" }, "tags": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "resource tags" }, "properties": { @@ -106,6 +97,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -115,6 +107,9 @@ "nodes_sessions": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -140,6 +135,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -149,6 +145,9 @@ "nodes_sessions_features_pssessions": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -163,6 +162,7 @@ } }, "required": [ + "name", "type", "apiVersion" ], @@ -217,6 +217,9 @@ "nodes_sessions_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -242,6 +245,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ServiceBus/2015-08-01/Microsoft.ServiceBus.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ServiceBus/2015-08-01/Microsoft.ServiceBus.json index 36be307546..35c2b673dd 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ServiceBus/2015-08-01/Microsoft.ServiceBus.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/ServiceBus/2015-08-01/Microsoft.ServiceBus.json @@ -7,6 +7,9 @@ "namespaces": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -75,6 +78,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -85,6 +89,9 @@ "namespaces_AuthorizationRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -101,10 +108,6 @@ "type": "string", "description": "data center location." }, - "name": { - "type": "string", - "description": "Name of the AuthorizationRule." - }, "properties": { "oneOf": [ { @@ -117,6 +120,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -126,6 +130,9 @@ "namespaces_queues": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -138,10 +145,6 @@ "2015-08-01" ] }, - "name": { - "type": "string", - "description": "Queue name." - }, "location": { "type": "string", "description": "location of the resource." @@ -168,6 +171,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -178,6 +182,9 @@ "namespaces_queues_authorizationRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -194,10 +201,6 @@ "type": "string", "description": "data center location." }, - "name": { - "type": "string", - "description": "Name of the AuthorizationRule." - }, "properties": { "oneOf": [ { @@ -210,6 +213,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -219,6 +223,9 @@ "namespaces_topics": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -231,10 +238,6 @@ "2015-08-01" ] }, - "name": { - "type": "string", - "description": "Topic name." - }, "location": { "type": "string", "description": "Location of the resource." @@ -264,6 +267,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -274,6 +278,9 @@ "namespaces_topics_authorizationRules": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -290,10 +297,6 @@ "type": "string", "description": "data center location." }, - "name": { - "type": "string", - "description": "Name of the AuthorizationRule." - }, "properties": { "oneOf": [ { @@ -306,6 +309,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -315,6 +319,9 @@ "namespaces_topics_subscriptions": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -343,6 +350,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -488,6 +496,9 @@ "namespaces_AuthorizationRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -504,10 +515,6 @@ "type": "string", "description": "data center location." }, - "name": { - "type": "string", - "description": "Name of the AuthorizationRule." - }, "properties": { "oneOf": [ { @@ -520,6 +527,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -529,6 +537,9 @@ "namespaces_queues_authorizationRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -545,10 +556,6 @@ "type": "string", "description": "data center location." }, - "name": { - "type": "string", - "description": "Name of the AuthorizationRule." - }, "properties": { "oneOf": [ { @@ -561,6 +568,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -570,6 +578,9 @@ "namespaces_queues_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -582,10 +593,6 @@ "2015-08-01" ] }, - "name": { - "type": "string", - "description": "Queue name." - }, "location": { "type": "string", "description": "location of the resource." @@ -612,6 +619,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -622,6 +630,9 @@ "namespaces_topics_authorizationRules_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -638,10 +649,6 @@ "type": "string", "description": "data center location." }, - "name": { - "type": "string", - "description": "Name of the AuthorizationRule." - }, "properties": { "oneOf": [ { @@ -654,6 +661,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -663,6 +671,9 @@ "namespaces_topics_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -675,10 +686,6 @@ "2015-08-01" ] }, - "name": { - "type": "string", - "description": "Topic name." - }, "location": { "type": "string", "description": "Location of the resource." @@ -708,6 +715,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -718,6 +726,9 @@ "namespaces_topics_subscriptions_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -746,6 +757,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2015-05-01-preview/Microsoft.Storage.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2015-05-01-preview/Microsoft.Storage.json index 317190ea7a..ce30c81517 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2015-05-01-preview/Microsoft.Storage.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2015-05-01-preview/Microsoft.Storage.json @@ -7,6 +7,9 @@ "storageAccounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -49,6 +52,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2015-06-15/Microsoft.Storage.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2015-06-15/Microsoft.Storage.json index cac87b99d6..90663709a6 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2015-06-15/Microsoft.Storage.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2015-06-15/Microsoft.Storage.json @@ -7,6 +7,9 @@ "storageAccounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -49,6 +52,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2016-01-01/Microsoft.Storage.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2016-01-01/Microsoft.Storage.json index 9c330986a3..cf597c93d1 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2016-01-01/Microsoft.Storage.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Storage/2016-01-01/Microsoft.Storage.json @@ -7,6 +7,9 @@ "storageAccounts": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -75,6 +78,7 @@ } }, "required": [ + "name", "type", "apiVersion", "sku", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/TrafficManager/2015-11-01/Microsoft.Network.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/TrafficManager/2015-11-01/Microsoft.Network.json index e4ccd105ae..21d0954fdd 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/TrafficManager/2015-11-01/Microsoft.Network.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/TrafficManager/2015-11-01/Microsoft.Network.json @@ -7,6 +7,9 @@ "trafficmanagerprofiles": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -49,6 +52,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.CertificateRegistration.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.CertificateRegistration.json index 3225e61305..73532497cc 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.CertificateRegistration.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.CertificateRegistration.json @@ -7,6 +7,9 @@ "certificateOrders": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -23,10 +26,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -71,6 +70,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -81,6 +81,9 @@ "certificateOrders_certificates": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -97,10 +100,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -135,6 +134,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -506,6 +506,9 @@ "certificateOrders_certificates_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -522,10 +525,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -560,6 +559,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.DomainRegistration.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.DomainRegistration.json index 9b3959f559..82c44f158a 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.DomainRegistration.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.DomainRegistration.json @@ -7,6 +7,9 @@ "domains": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -23,10 +26,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -61,6 +60,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.Web.json b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.Web.json index e29fc540bd..f8292f4c40 100644 --- a/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.Web.json +++ b/src/generator/AutoRest.AzureResourceSchema.Tests/Resource/Expected/Web/2015-08-01/Microsoft.Web.json @@ -7,6 +7,9 @@ "certificates": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -23,10 +26,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -61,6 +60,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -71,6 +71,9 @@ "csrs": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -87,10 +90,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -125,6 +124,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -135,6 +135,9 @@ "hostingEnvironments": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -151,10 +154,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -199,6 +198,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -209,6 +209,9 @@ "hostingEnvironments_workerPools": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -225,10 +228,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -273,6 +272,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -283,6 +283,9 @@ "managedHostingEnvironments": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -299,10 +302,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -337,6 +336,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -347,6 +347,9 @@ "serverfarms": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -363,10 +366,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -411,6 +410,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -421,6 +421,9 @@ "serverfarms_virtualNetworkConnections_gateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -437,10 +440,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -475,6 +474,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -485,6 +485,9 @@ "serverfarms_virtualNetworkConnections_routes": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -501,10 +504,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -539,6 +538,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -549,6 +549,9 @@ "sites": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -565,10 +568,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -628,6 +627,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -638,6 +638,9 @@ "sites_deployments": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -654,10 +657,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -692,6 +691,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -702,6 +702,9 @@ "sites_hostNameBindings": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -718,10 +721,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -756,6 +755,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -766,6 +766,9 @@ "sites_hybridconnection": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -782,10 +785,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -820,6 +819,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -830,6 +830,9 @@ "sites_instances_deployments": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -846,10 +849,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -884,6 +883,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -894,6 +894,9 @@ "sites_premieraddons": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -936,14 +939,6 @@ "description": "Azure resource manager plan" }, "properties": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Resource specific properties" }, "sku": { @@ -959,6 +954,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -968,6 +964,9 @@ "sites_slots": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -984,10 +983,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1044,6 +1039,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1054,6 +1050,9 @@ "sites_slots_deployments": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1070,10 +1069,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1108,6 +1103,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1118,6 +1114,9 @@ "sites_slots_hostNameBindings": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1134,10 +1133,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1172,6 +1167,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1182,6 +1178,9 @@ "sites_slots_hybridconnection": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1198,10 +1197,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1236,6 +1231,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1246,6 +1242,9 @@ "sites_slots_instances_deployments": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1262,10 +1261,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1300,6 +1295,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1310,6 +1306,9 @@ "sites_slots_premieraddons": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1352,14 +1351,6 @@ "description": "Azure resource manager plan" }, "properties": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Resource specific properties" }, "sku": { @@ -1375,6 +1366,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -1384,6 +1376,9 @@ "sites_slots_virtualNetworkConnections": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1400,10 +1395,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1448,6 +1439,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1458,6 +1450,9 @@ "sites_slots_virtualNetworkConnections_gateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1474,10 +1469,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1512,6 +1503,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1522,6 +1514,9 @@ "sites_virtualNetworkConnections": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1538,10 +1533,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1586,6 +1577,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -1596,6 +1588,9 @@ "sites_virtualNetworkConnections_gateways": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -1612,10 +1607,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -1650,6 +1641,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -2476,6 +2468,9 @@ "hostingEnvironments_workerPools_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -2492,10 +2487,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -2540,6 +2531,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -3512,6 +3504,9 @@ "sites_deployments_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3528,10 +3523,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -3566,6 +3557,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -3576,6 +3568,9 @@ "sites_hostNameBindings_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3592,10 +3587,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -3630,6 +3621,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -3640,6 +3632,9 @@ "sites_hybridconnection_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3656,10 +3651,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -3694,6 +3685,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -3704,6 +3696,9 @@ "sites_premieraddons_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3746,14 +3741,6 @@ "description": "Azure resource manager plan" }, "properties": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Resource specific properties" }, "sku": { @@ -3769,6 +3756,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -3778,6 +3766,9 @@ "sites_slots_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3794,10 +3785,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -3851,6 +3838,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -3861,6 +3849,9 @@ "sites_slots_deployments_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3877,10 +3868,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -3915,6 +3902,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -3925,6 +3913,9 @@ "sites_slots_hostNameBindings_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -3941,10 +3932,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -3979,6 +3966,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -3989,6 +3977,9 @@ "sites_slots_hybridconnection_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4005,10 +3996,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -4043,6 +4030,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -4053,6 +4041,9 @@ "sites_slots_premieraddons_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4095,14 +4086,6 @@ "description": "Azure resource manager plan" }, "properties": { - "oneOf": [ - { - "type": "object" - }, - { - "$ref": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression" - } - ], "description": "Resource specific properties" }, "sku": { @@ -4118,6 +4101,7 @@ } }, "required": [ + "name", "type", "apiVersion", "properties" @@ -4127,6 +4111,9 @@ "sites_slots_virtualNetworkConnections_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4143,10 +4130,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -4191,6 +4174,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -4201,6 +4185,9 @@ "sites_slots_virtualNetworkConnections_gateways_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4217,10 +4204,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -4255,6 +4238,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -4265,6 +4249,9 @@ "sites_virtualNetworkConnections_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4281,10 +4268,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -4329,6 +4312,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", @@ -4339,6 +4323,9 @@ "sites_virtualNetworkConnections_gateways_childResource": { "type": "object", "properties": { + "name": { + "type": "string" + }, "type": { "type": "string", "enum": [ @@ -4355,10 +4342,6 @@ "type": "string", "description": "Resource Id" }, - "name": { - "type": "string", - "description": "Resource Name" - }, "kind": { "type": "string", "description": "Kind of resource" @@ -4393,6 +4376,7 @@ } }, "required": [ + "name", "type", "apiVersion", "location", diff --git a/src/generator/AutoRest.CSharp.Azure.Fluent/TransformerCsaf.cs b/src/generator/AutoRest.CSharp.Azure.Fluent/TransformerCsaf.cs index 1cee553fd9..c0301487f9 100644 --- a/src/generator/AutoRest.CSharp.Azure.Fluent/TransformerCsaf.cs +++ b/src/generator/AutoRest.CSharp.Azure.Fluent/TransformerCsaf.cs @@ -19,12 +19,12 @@ CodeModelCsaf ITransformer.TransformCodeModel(CodeModel cs) var codeModel = cs as CodeModelCsaf; Settings.Instance.AddCredentials = true; - // Do parameter transformations - TransformParameters(codeModel); - // todo: these should be turned into individual transformers AzureExtensions.NormalizeAzureClientModel(codeModel); + // Do parameter transformations + TransformParameters(codeModel); + // Fluent Specific stuff. NormalizeResourceTypes(codeModel); NormalizeTopLevelTypes(codeModel); diff --git a/src/generator/AutoRest.CSharp.Azure/TransformerCsa.cs b/src/generator/AutoRest.CSharp.Azure/TransformerCsa.cs index 7cde0c8dce..0f21331590 100644 --- a/src/generator/AutoRest.CSharp.Azure/TransformerCsa.cs +++ b/src/generator/AutoRest.CSharp.Azure/TransformerCsa.cs @@ -41,12 +41,12 @@ CodeModelCsa ITransformer.TransformCodeModel(CodeModel cs) // add the Credentials // PopulateAdditionalProperties(codeModel); - // Do parameter transformations - TransformParameters(codeModel); - // todo: these should be turned into individual transformers AzureExtensions.NormalizeAzureClientModel(codeModel); + // Do parameter transformations + TransformParameters(codeModel); + NormalizePaginatedMethods(codeModel); NormalizeODataMethods(codeModel); diff --git a/src/generator/AutoRest.CSharp.Unit.Tests/Bug1763.cs b/src/generator/AutoRest.CSharp.Unit.Tests/Bug1763.cs new file mode 100644 index 0000000000..f222d772ae --- /dev/null +++ b/src/generator/AutoRest.CSharp.Unit.Tests/Bug1763.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// + +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using System.Text.RegularExpressions; +using Microsoft.CodeAnalysis; +using Xunit; +using Xunit.Abstractions; + +namespace AutoRest.CSharp.Unit.Tests +{ + public class Bug1763 : BugTest + { + public Bug1763(ITestOutputHelper output) : base(output) + { + } + + /// + /// https://github.com/Azure/autorest/issues/1763 + /// Verifies autorest succesfully generates code for models with properties starting with '_' + /// + [Fact] + public async Task VerifyUnderscoredClassMembers() + { + using (var fileSystem = GenerateCodeForTestFromSpec()) + { + var result = await Compile(fileSystem); + + // Expected Files + Assert.True(fileSystem.FileExists(@"GeneratedCode\Models\Pet.cs")); + + // filter the warnings + var warnings = result.Messages.Where( + each => each.Severity == DiagnosticSeverity.Warning + && !SuppressWarnings.Contains(each.Id)).ToArray(); + + // filter the errors + var errors = result.Messages.Where(each => each.Severity == DiagnosticSeverity.Error).ToArray(); + + Write(warnings, fileSystem); + Write(errors, fileSystem); + + // Don't proceed unless we have zero warnings. + Assert.Empty(warnings); + // Don't proceed unless we have zero Errors. + Assert.Empty(errors); + + // Should also succeed. + Assert.True(result.Succeeded); + + // try to load the assembly + var asm = Assembly.Load(result.Output.GetBuffer()); + Assert.NotNull(asm); + var petModel = asm.ExportedTypes.First(type => type.FullName == "Test.Models.Pet" ); + var idMember = petModel.GetMembers().First(member => member.Name == "_id" ); + Assert.NotNull(idMember); + + // now read from the file to ensure we use this. to access the members + var codeText = fileSystem.ReadFileAsText(@"GeneratedCode\Models\Pet.cs"); + // get hold of the ctor + var regex = new Regex(Regex.Escape("public Pet(int _id, string name = default(string))") + @"[^}]+"); + var match = regex.Match(codeText); + Assert.NotNull(match); + // verify the ctor has proper assignments + Assert.True(match.Groups[0].Value.Contains("this._id = _id")); + Assert.True(match.Groups[0].Value.Contains("this.Name = name")); + } + } + } +} \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp.Unit.Tests/Resource/Bug1763/Bug1763.yaml b/src/generator/AutoRest.CSharp.Unit.Tests/Resource/Bug1763/Bug1763.yaml new file mode 100644 index 0000000000..67e241b1f4 --- /dev/null +++ b/src/generator/AutoRest.CSharp.Unit.Tests/Resource/Bug1763/Bug1763.yaml @@ -0,0 +1,31 @@ +--- +swagger: '2.0' +info: + title: TestAPI + description: test api + version: 0.0.0 +paths: + "/SimpleAPI/Pets": + put: + operationId: test_PutPet + description: Put pet with name + parameters: + - in: body + name: pet + description: pet to put + required: true + schema: + "$ref": "#/definitions/Pet" + responses: + '200': + description: Pet added to system +definitions: + Pet: + description: simple pet to add + required: + - _id + properties: + _id: + type: integer + name: + type: string \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp/Templates/Rest/Common/ModelTemplate.cshtml b/src/generator/AutoRest.CSharp/Templates/Rest/Common/ModelTemplate.cshtml index 8f29c3e9cc..e09d990acb 100644 --- a/src/generator/AutoRest.CSharp/Templates/Rest/Common/ModelTemplate.cshtml +++ b/src/generator/AutoRest.CSharp/Templates/Rest/Common/ModelTemplate.cshtml @@ -55,7 +55,7 @@ namespace @(Settings.Namespace).@(Settings.ModelsName) && p.IsRequired && ((CompositeType)p.ModelType).ContainsConstantProperties)) { - @:@(property.Name) = new @(property.ModelTypeName)(); + @:this.@(property.Name) = new @(property.ModelTypeName)(); } } @@ -88,7 +88,7 @@ namespace @(Settings.Namespace).@(Settings.ModelsName) && p.IsRequired && ((CompositeType)p.ModelType).ContainsConstantProperties)) { - @:@(property.Name) = new @(property.ModelTypeName)(); + @:this.@(property.Name) = new @(property.ModelTypeName)(); } foreach (var property in Model.Properties.Where(p => !p.IsConstant)) @@ -100,7 +100,7 @@ namespace @(Settings.Namespace).@(Settings.ModelsName) } else { - @:@(property.Name) = @propName; + @:this.@(property.Name) = @propName; } } @@ -208,7 +208,7 @@ namespace @(Settings.Namespace).@(Settings.ModelsName) foreach (PropertyCs property in Model.Properties.Where(p => p.IsRequired && !p.IsReadOnly && !p.IsConstant && p.IsNullable() )) { anythingToValidate = true; - @:if (@property.Name == null) + @:if (this.@property.Name == null) @:{ @:throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "@property.Name"); @:} diff --git a/src/generator/AutoRest.Go.Tests/src/tests/acceptancetests/custombaseurlgrouptest/custom-baseurl_test.go b/src/generator/AutoRest.Go.Tests/src/tests/acceptancetests/custombaseurlgrouptest/custom-baseurl_test.go index 653d857174..91106cc5a8 100644 --- a/src/generator/AutoRest.Go.Tests/src/tests/acceptancetests/custombaseurlgrouptest/custom-baseurl_test.go +++ b/src/generator/AutoRest.Go.Tests/src/tests/acceptancetests/custombaseurlgrouptest/custom-baseurl_test.go @@ -5,7 +5,6 @@ import ( chk "gopkg.in/check.v1" - "tests/acceptancetests/utils" . "tests/generated/custom-baseurl" ) @@ -18,12 +17,20 @@ var _ = chk.Suite(&CustomBaseURLGroupSuite{}) var custombaseuriClient = getCustomBaseURIClient() func getCustomBaseURIClient() PathsClient { - c := NewPathsClient("local") - c.BaseURI = utils.GetBaseURI() - return c + c := NewWithoutDefaults("host:3000") + return PathsClient{ManagementClient: c} } -func (s *CustomBaseURLGroupSuite) TestGetEmpty(c *chk.C) { - _, err := custombaseuriClient.GetEmpty() +func (s *CustomBaseURLGroupSuite) TestCustomBaseUriPositive(c *chk.C) { + _, err := custombaseuriClient.GetEmpty("local") c.Assert(err, chk.IsNil) } + +func (s *CustomBaseURLGroupSuite) TestCustomBaseUriNegative(c *chk.C) { + _, err := custombaseuriClient.GetEmpty("badhost:3000") + c.Assert(err, chk.NotNil) + + custombaseuriClient.RetryAttempts = 0 + _, err = custombaseuriClient.GetEmpty("bad") + c.Assert(err, chk.NotNil) +} diff --git a/src/generator/AutoRest.Go.Tests/src/tests/acceptancetests/morecustombaseurigrouptest/more-custom-base-uri_test.go b/src/generator/AutoRest.Go.Tests/src/tests/acceptancetests/morecustombaseurigrouptest/more-custom-base-uri_test.go new file mode 100644 index 0000000000..372bdbef96 --- /dev/null +++ b/src/generator/AutoRest.Go.Tests/src/tests/acceptancetests/morecustombaseurigrouptest/more-custom-base-uri_test.go @@ -0,0 +1,27 @@ +package morecustombaseurigrouptest + +import ( + "testing" + + chk "gopkg.in/check.v1" + + . "tests/generated/more-custom-base-uri" +) + +func Test(t *testing.T) { chk.TestingT(t) } + +type MoreCustomBaseURIGroupSuite struct{} + +var _ = chk.Suite(&MoreCustomBaseURIGroupSuite{}) + +var custombaseuriClient = getMoreCustomBaseURIClient() + +func getMoreCustomBaseURIClient() PathsClient { + c := NewWithoutDefaults("test12", "host:3000") + return PathsClient{ManagementClient: c} +} + +func (s *MoreCustomBaseURIGroupSuite) TestCustomBaseUriMoreOptions(c *chk.C) { + _, err := custombaseuriClient.GetEmpty("http://lo", "cal", "key1", "v1") + c.Assert(err, chk.IsNil) +} diff --git a/src/generator/AutoRest.Go.Tests/src/tests/runner.go b/src/generator/AutoRest.Go.Tests/src/tests/runner.go index ee92b83f43..04731ee1e7 100644 --- a/src/generator/AutoRest.Go.Tests/src/tests/runner.go +++ b/src/generator/AutoRest.Go.Tests/src/tests/runner.go @@ -66,7 +66,9 @@ func runTests(allPass *bool) { "custombaseurlgroup", "filegroup", // "formdatagroup", - "paginggroup"} + "paginggroup", + "morecustombaseurigroup", + } for _, suite := range testSuites { fmt.Printf("Run test (go test ./acceptancetests/%vtest -v) ...\n", suite) diff --git a/src/generator/AutoRest.Go/CodeNamerGo.cs b/src/generator/AutoRest.Go/CodeNamerGo.cs index 6392646879..0a90dcfd36 100644 --- a/src/generator/AutoRest.Go/CodeNamerGo.cs +++ b/src/generator/AutoRest.Go/CodeNamerGo.cs @@ -11,6 +11,8 @@ using AutoRest.Core.Utilities.Collections; using AutoRest.Core.Model; using AutoRest.Go.Model; +using System.Text; +using System.Text.RegularExpressions; namespace AutoRest.Go { @@ -29,7 +31,7 @@ public class CodeNamerGo : CodeNamer public virtual IEnumerable StandardImports => new string[] { "github.com/Azure/go-autorest/autorest/azure", "net/http" }; public virtual IEnumerable PageableImports => new string[] { "net/http", "github.com/Azure/go-autorest/autorest/to" }; - + public virtual IEnumerable ValidationImport => new string[] { "github.com/Azure/go-autorest/autorest/validation" }; // CommonInitialisms are those "words" within a name that Golint expects to be uppercase. @@ -82,10 +84,14 @@ public class CodeNamerGo : CodeNamer "ManagementClient", "NewWithBaseURI", "New", + "NewWithoutDefaults", }; public IReadOnlyDictionary StatusCodeToGoString; + + private static readonly Regex semVerPattern = new Regex(@"^(?\d+)\.(?\d+)\.(?\d+)(?:-(?\S+))?$", RegexOptions.Compiled); + /// /// Initializes a new instance of CodeNamerGo. /// @@ -412,20 +418,12 @@ public void ReserveNamespace(string ns) // camelCase or PascalCase. private string EnsureNameCase(string name) { - List words = new List(); - new List(name.ToWords()) - .ForEach(s => - { - if (CommonInitialisms.Contains(s)) - { - words.Add(s.ToUpper()); - } - else - { - words.Add(s); - } - }); - return String.Join(String.Empty, words.ToArray()); + var builder = new StringBuilder(); + foreach (var s in name.ToWords()) + { + builder.Append(CommonInitialisms.Contains(s) ? s.ToUpper() : s); + } + return builder.ToString(); } public static string[] SDKVersionFromPackageVersion(string v) @@ -434,12 +432,19 @@ public static string[] SDKVersionFromPackageVersion(string v) { throw new ArgumentNullException("package version"); } - string[] version = v.Split('.'); - if (version.Length != 3) + + var ver = semVerPattern.Match(v); + + if (ver.Success) { - throw new InvalidOperationException("version string should have major, minor and patch versions."); + var tagVal = ver.Groups["tag"].Success ? ver.Groups["tag"].Value : ""; + return new[] { ver.Groups["major"].Value, ver.Groups["minor"].Value, ver.Groups["patch"].Value, tagVal }; + } - return version; + throw new ArgumentException( + paramName: nameof(v), + message: "Version strings should be either of the format \"..\" or \"..-\". Where major, minor, and patch are decimal numbers and tag does not include whitespace."); + } public override string EscapeDefaultValue(string defaultValue, IModelType type) diff --git a/src/generator/AutoRest.Go/Model/CodeModelGo.cs b/src/generator/AutoRest.Go/Model/CodeModelGo.cs index ef81fe719e..3489bf984a 100644 --- a/src/generator/AutoRest.Go/Model/CodeModelGo.cs +++ b/src/generator/AutoRest.Go/Model/CodeModelGo.cs @@ -6,6 +6,7 @@ using AutoRest.Core; using AutoRest.Core.Model; using AutoRest.Core.Utilities; +using AutoRest.Extensions; namespace AutoRest.Go.Model { @@ -48,6 +49,8 @@ public string GetDocumentation() public string BaseClient => "ManagementClient"; + public bool IsCustomBaseUri => Extensions.ContainsKey(SwaggerExtensions.ParameterizedHostExtension); + public IEnumerable ClientImports { get @@ -103,7 +106,7 @@ public string GlobalParameters var declarations = new List(); foreach (var p in Properties) { - if (!p.SerializedName.FixedValue.IsApiVersion()) + if (!p.SerializedName.FixedValue.IsApiVersion() && p.DefaultValue.FixedValue.IsNullOrEmpty()) { declarations.Add( string.Format( @@ -122,7 +125,7 @@ public string HelperGlobalParameters var invocationParams = new List(); foreach (var p in Properties) { - if (!p.SerializedName.Value.IsApiVersion()) + if (!p.SerializedName.Value.IsApiVersion() && p.DefaultValue.FixedValue.IsNullOrEmpty()) { invocationParams.Add(p.Name.Value.ToSentence()); } @@ -130,6 +133,92 @@ public string HelperGlobalParameters return string.Join(", ", invocationParams); } } + public string GlobalDefaultParameters + { + get + { + var declarations = new List(); + foreach (var p in Properties) + { + if (!p.SerializedName.FixedValue.IsApiVersion() && !p.DefaultValue.FixedValue.IsNullOrEmpty()) + { + declarations.Add( + string.Format( + (p.IsRequired || p.ModelType.CanBeEmpty() ? "{0} {1}" : "{0} *{1}"), + p.Name.Value.ToSentence(), p.ModelType.Name.Value.ToSentence())); + } + } + return string.Join(", ", declarations); + } + } + + public string HelperGlobalDefaultParameters + { + get + { + var invocationParams = new List(); + foreach (var p in Properties) + { + if (!p.SerializedName.Value.IsApiVersion() && !p.DefaultValue.FixedValue.IsNullOrEmpty()) + { + invocationParams.Add("Default" + p.Name.Value); + } + } + return string.Join(", ", invocationParams); + } + } + + public string ConstGlobalDefaultParameters + { + get + { + var constDeclaration = new List(); + foreach (var p in Properties) + { + if (!p.SerializedName.Value.IsApiVersion() && !p.DefaultValue.FixedValue.IsNullOrEmpty()) + { + constDeclaration.Add(string.Format("// Default{0} is the default value for {1}\nDefault{0} = {2}", + p.Name.Value, + p.Name.Value.ToPhrase(), + p.DefaultValue.Value)); + } + } + return string.Join("\n", constDeclaration); + } + } + + + public string AllGlobalParameters + { + get + { + if (GlobalParameters.IsNullOrEmpty()) + { + return GlobalDefaultParameters; + } + if (GlobalDefaultParameters.IsNullOrEmpty()) + { + return GlobalParameters; + } + return string.Join(", ", new string[] {GlobalParameters, GlobalDefaultParameters}); + } + } + + public string HelperAllGlobalParameters + { + get + { + if (HelperGlobalParameters.IsNullOrEmpty()) + { + return HelperGlobalDefaultParameters; + } + if (HelperGlobalDefaultParameters.IsNullOrEmpty()) + { + return HelperGlobalParameters; + } + return string.Join(", ", new string[] {HelperGlobalParameters, HelperGlobalDefaultParameters}); + } + } public IEnumerable ClientMethods { diff --git a/src/generator/AutoRest.Go/Model/MethodGo.cs b/src/generator/AutoRest.Go/Model/MethodGo.cs index b8874de48f..7941852c25 100644 --- a/src/generator/AutoRest.Go/Model/MethodGo.cs +++ b/src/generator/AutoRest.Go/Model/MethodGo.cs @@ -4,6 +4,7 @@ using AutoRest.Go.Properties; using AutoRest.Core.Utilities; using AutoRest.Core.Model; +using AutoRest.Extensions; using AutoRest.Extensions.Azure; using AutoRest.Extensions.Azure.Model; using Newtonsoft.Json; @@ -26,6 +27,9 @@ public class MethodGo : Method public bool NextAlreadyDefined { get; private set; } + public bool IsCustomBaseUri + => CodeModel.Extensions.ContainsKey(SwaggerExtensions.ParameterizedHostExtension); + public MethodGo() { NextAlreadyDefined = true; @@ -140,6 +144,10 @@ public IEnumerable LocalParameters public IEnumerable OptionalHeaderParameters => ParametersGo.HeaderParameters(false); + public IEnumerable URLParameters => ParametersGo.URLParameters(); + + public string URLMap => URLParameters.BuildParameterMap("urlParameters"); + public IEnumerable PathParameters => ParametersGo.PathParameters(); public string PathMap => PathParameters.BuildParameterMap("pathParameters"); @@ -184,7 +192,14 @@ public List PrepareDecorators } decorators.Add(HTTPMethodDecorator); - decorators.Add("autorest.WithBaseURL(client.BaseURI)"); + if (!this.IsCustomBaseUri) + { + decorators.Add(string.Format("autorest.WithBaseURL(client.BaseURI)")); + } + else + { + decorators.Add(string.Format("autorest.WithCustomBaseURL(\"{0}\", urlParameters)", CodeModel.BaseUrl)); + } decorators.Add(string.Format(PathParameters.Any() ? "autorest.WithPathParameters(\"{0}\",pathParameters)" diff --git a/src/generator/AutoRest.Go/Model/MethodGroupGo.cs b/src/generator/AutoRest.Go/Model/MethodGroupGo.cs index b51d848efd..fba11e58aa 100644 --- a/src/generator/AutoRest.Go/Model/MethodGroupGo.cs +++ b/src/generator/AutoRest.Go/Model/MethodGroupGo.cs @@ -7,6 +7,7 @@ using AutoRest.Core.Model; using AutoRest.Core.Utilities; using AutoRest.Go; +using AutoRest.Extensions; namespace AutoRest.Go.Model { @@ -17,8 +18,14 @@ public class MethodGroupGo : MethodGroup public string PackageName { get; private set; } public string BaseClient { get; private set; } + public bool IsCustomBaseUri + => CodeModel.Extensions.ContainsKey(SwaggerExtensions.ParameterizedHostExtension); + public string GlobalParameters; public string HelperGlobalParameters; + public string GlobalDefaultParameters; + public string HelperGlobalDefaultParameters; + public string ConstGlobalDefaultParameters; public IEnumerable Imports { get; private set; } public MethodGroupGo(string name): base(name) @@ -58,6 +65,9 @@ internal void Transform(CodeModelGo cmg) BaseClient = cmg.BaseClient; GlobalParameters = cmg.GlobalParameters; HelperGlobalParameters = cmg.HelperGlobalParameters; + GlobalDefaultParameters = cmg.GlobalDefaultParameters; + HelperGlobalDefaultParameters = cmg.HelperGlobalDefaultParameters; + ConstGlobalDefaultParameters = cmg.ConstGlobalDefaultParameters; diff --git a/src/generator/AutoRest.Go/Model/ParameterGo.cs b/src/generator/AutoRest.Go/Model/ParameterGo.cs index d68ed604a2..66c6687192 100644 --- a/src/generator/AutoRest.Go/Model/ParameterGo.cs +++ b/src/generator/AutoRest.Go/Model/ParameterGo.cs @@ -83,7 +83,7 @@ public string ValueForMap() return "client." + ApiVersionName; } var value = IsClientProperty - ? "client." + CodeNamerGo.Instance.PascalCase(Name.Value) + ? "client." + CodeNamerGo.Instance.GetPropertyName(Name.Value) : Name.Value; var format = IsRequired || ModelType.CanBeEmpty() @@ -186,9 +186,30 @@ public static IEnumerable HeaderParameters(this IEnumerable URLParameters(this IEnumerable parameters) + { + var urlParams = new List(); + foreach (ParameterGo p in parameters.ByLocation(ParameterLocation.Path)) + { + if (p.Method.CodeModel.BaseUrl.Contains(p.SerializedName)) + { + urlParams.Add(p); + } + } + return urlParams; + } + public static IEnumerable PathParameters(this IEnumerable parameters) { - return parameters.ByLocation(ParameterLocation.Path); + var pathParams = new List(); + foreach (ParameterGo p in parameters.ByLocation(ParameterLocation.Path)) + { + if (!p.Method.CodeModel.BaseUrl.Contains(p.SerializedName)) + { + pathParams.Add(p); + } + } + return pathParams; } public static IEnumerable QueryParameters(this IEnumerable parameters) diff --git a/src/generator/AutoRest.Go/Templates/MethodGroupTemplate.cshtml b/src/generator/AutoRest.Go/Templates/MethodGroupTemplate.cshtml index 1424340c84..fdae9ac60e 100644 --- a/src/generator/AutoRest.Go/Templates/MethodGroupTemplate.cshtml +++ b/src/generator/AutoRest.Go/Templates/MethodGroupTemplate.cshtml @@ -34,15 +34,31 @@ type @(Model.ClientName) struct { @WrapComment("// ", string.Format("New{0} creates an instance of the {0} client.", Model.ClientName)) func New@(Model.ClientName)(@(Model.GlobalParameters)) @(Model.ClientName) { - return New@(Model.ClientName)WithBaseURI(DefaultBaseURI, @(Model.HelperGlobalParameters)) + @if (!Model.IsCustomBaseUri) + { + + return New@(Model.ClientName)WithBaseURI(DefaultBaseURI, @(Model.HelperGlobalParameters)) + + } + else + { + + return @(Model.ClientName){ New(@(Model.HelperGlobalParameters))} + + } } @EmptyLine -@WrapComment("// ", string.Format("New{0}WithBaseURI creates an instance of the {0} client.", Model.ClientName)) -func New@(Model.ClientName)WithBaseURI(baseURI string, @(Model.GlobalParameters)) @(Model.ClientName) { - return @(Model.ClientName){NewWithBaseURI(baseURI, @(Model.HelperGlobalParameters))} +@if (!Model.IsCustomBaseUri) +{ + @WrapComment("// ", string.Format("New{0}WithBaseURI creates an instance of the {0} client.", Model.ClientName)) + + func New@(Model.ClientName)WithBaseURI(baseURI string, @(Model.GlobalParameters)) @(Model.ClientName) { + return @(Model.ClientName){ NewWithBaseURI(baseURI, @(Model.HelperGlobalParameters))} + } + + @EmptyLine } -@EmptyLine @foreach (var method in methods) { diff --git a/src/generator/AutoRest.Go/Templates/MethodTemplate.cshtml b/src/generator/AutoRest.Go/Templates/MethodTemplate.cshtml index c79aee2d06..78d98de871 100644 --- a/src/generator/AutoRest.Go/Templates/MethodTemplate.cshtml +++ b/src/generator/AutoRest.Go/Templates/MethodTemplate.cshtml @@ -73,6 +73,11 @@ func (client @(Model.Owner)) @(Model.MethodSignature) (@Model.MethodReturnSignat @EmptyLine // @(Model.PreparerMethodName) prepares the @(Model.Name) request. func (client @(Model.Owner)) @(Model.PreparerMethodName)(@(Model.MethodParametersSignature)) (*http.Request, error) { +@if (Model.IsCustomBaseUri && Model.URLParameters.Count() > 0) +{ + @:@(Model.URLMap) + @:@EmptyLine +} @if (Model.PathParameters.Count() > 0) { @:@(Model.PathMap) diff --git a/src/generator/AutoRest.Go/Templates/ServiceClientTemplate.cshtml b/src/generator/AutoRest.Go/Templates/ServiceClientTemplate.cshtml index 3cfa4b9073..328beb5eb5 100644 --- a/src/generator/AutoRest.Go/Templates/ServiceClientTemplate.cshtml +++ b/src/generator/AutoRest.Go/Templates/ServiceClientTemplate.cshtml @@ -28,49 +28,92 @@ import ( const ( // APIVersion is the version of the @(Model.ServiceName) APIVersion = "@Model.ApiVersion" - @EmptyLine - // DefaultBaseURI is the default URI used for the service @(Model.ServiceName) - DefaultBaseURI = "@Model.BaseUrl" + @if (!Model.IsCustomBaseUri) + { + @EmptyLine + @:// DefaultBaseURI is the default URI used for the service @(Model.ServiceName) + @:DefaultBaseURI = "@Model.BaseUrl" + } + else + { + @(Model.ConstGlobalDefaultParameters) + } ) @EmptyLine @WrapComment("// ", Model.ClientDocumentation) type @(Model.BaseClient) struct { autorest.Client - BaseURI string + @if (!Model.IsCustomBaseUri) + { + @:BaseURI string + } APIVersion string @foreach (var p in Model.Properties) { - if (!p.SerializedName.FixedValue.IsApiVersion()) - { - @:@(string.Format((p.IsRequired || p.ModelType.CanBeEmpty() - ? "{0} {1}": "{0} *{1}"), - p.Name, p.ModelType.Name)) - } + if (!p.SerializedName.FixedValue.IsApiVersion()) + { + @:@(string.Format((p.IsRequired || p.ModelType.CanBeEmpty() + ? "{0} {1}" : "{0} *{1}"), + p.Name, p.ModelType.Name)) + } } } + @EmptyLine @WrapComment("// ", string.Format("New creates an instance of the {0} client.", Model.BaseClient)) func New(@(Model.GlobalParameters))@(Model.BaseClient) { - return NewWithBaseURI(DefaultBaseURI, @(Model.HelperGlobalParameters)) + @if (!Model.IsCustomBaseUri) + { + @:return NewWithBaseURI(DefaultBaseURI, @(Model.HelperGlobalParameters)) + } + else + { + @:return NewWithoutDefaults(@(Model.HelperAllGlobalParameters)) + } } -@EmptyLine -@WrapComment("// ", string.Format("NewWithBaseURI creates an instance of the {0} client.", Model.BaseClient)) -func NewWithBaseURI(baseURI string, @(Model.GlobalParameters)) @(Model.BaseClient) { - return @(Model.BaseClient){ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - APIVersion: APIVersion, - @foreach (var p in Model.Properties) - { - if (!p.SerializedName.Value.IsApiVersion()) - { - @:@(string.Format("{0}: {1},", p.Name, p.Name.Value.ToSentence())) +@if (!Model.IsCustomBaseUri) +{ + + @EmptyLine + @WrapComment("// ", string.Format("NewWithBaseURI creates an instance of the {0} client.", Model.BaseClient)) + func NewWithBaseURI(baseURI string, @(Model.GlobalParameters)) @(Model.BaseClient) { + return @(Model.BaseClient){ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + APIVersion: APIVersion, + @foreach (var p in Model.Properties) + { + if (!p.SerializedName.Value.IsApiVersion()) + { + @:@(string.Format("{0}: {1},", p.Name, p.Name.Value.ToSentence())) + } + } } + } + +} +else +{ + + @EmptyLine + @WrapComment("// ", string.Format("NewWithoutDefaults creates an instance of the {0} client.", Model.BaseClient)) + func NewWithoutDefaults(@(Model.AllGlobalParameters)) @(Model.BaseClient) { + return @(Model.BaseClient){ + Client: autorest.NewClientWithUserAgent(UserAgent()), + APIVersion: APIVersion, + @foreach(var p in Model.Properties) + { + if (!p.SerializedName.Value.IsApiVersion()) + { + @:@(string.Format("{0}: {1},", p.Name, p.Name.Value.ToSentence())) + } + } } } + } @EmptyLine diff --git a/src/generator/AutoRest.Go/Templates/VersionTemplate.cshtml b/src/generator/AutoRest.Go/Templates/VersionTemplate.cshtml index 6ba8e4957b..32ce64cad0 100644 --- a/src/generator/AutoRest.Go/Templates/VersionTemplate.cshtml +++ b/src/generator/AutoRest.Go/Templates/VersionTemplate.cshtml @@ -13,7 +13,9 @@ package @Model.Namespace @EmptyLine import ( + "bytes" "fmt" + "strings" ) @EmptyLine @@ -21,21 +23,36 @@ const ( major = "@(Model.Version[0])" minor = "@(Model.Version[1])" patch = "@(Model.Version[2])" - // Always begin a "tag" with a dash (as per http://semver.org) - tag = "-beta" + tag = "@(Model.Version[3])" - semVerFormat = "%s.%s.%s%s" userAgentFormat = "Azure-SDK-For-Go/%s arm-%s/%s" ) +// cached results of UserAgent and Version to prevent repeated operations. +var ( + userAgent string + version string +) + @EmptyLine // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return fmt.Sprintf(userAgentFormat, Version(), "@(Model.Namespace)", "@(Model.ApiVersion)") + if userAgent == "" { + userAgent = fmt.Sprintf(userAgentFormat, Version(), "@(Model.Namespace)", "@(Model.ApiVersion)") + } + return userAgent } @EmptyLine // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return fmt.Sprintf(semVerFormat, major, minor, patch, tag) + if version == "" { + versionBuilder := bytes.NewBufferString(fmt.Sprintf("%s.%s.%s", major, minor, patch)) + if tag != "" { + versionBuilder.WriteRune('-') + versionBuilder.WriteString(strings.TrimPrefix(tag, "-")) + } + version = string(versionBuilder.Bytes()) + } + return version } diff --git a/src/generator/AutoRest.Go/TransformerGo.cs b/src/generator/AutoRest.Go/TransformerGo.cs index 7abb06bb83..ce2507ab54 100644 --- a/src/generator/AutoRest.Go/TransformerGo.cs +++ b/src/generator/AutoRest.Go/TransformerGo.cs @@ -14,6 +14,7 @@ using System.Diagnostics; using System.Globalization; using System.Linq; +using AutoRest.Extensions.Azure; namespace AutoRest.Go { @@ -37,6 +38,7 @@ public override CodeModelGo TransformCodeModel(CodeModel cm) TransformEnumTypes(cmg); TransformMethods(cmg); TransformModelTypes(cmg); + AzureExtensions.ProcessParameterizedHost(cmg); return cmg; } diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azureparametergrouping/ParameterGroupingTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azureparametergrouping/ParameterGroupingTests.java index bc8ca473c8..33fd5cad14 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azureparametergrouping/ParameterGroupingTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azureparametergrouping/ParameterGroupingTests.java @@ -1,5 +1,6 @@ package fixtures.azureparametergrouping; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.BeforeClass; import org.junit.Test; @@ -15,7 +16,7 @@ public class ParameterGroupingTests { @BeforeClass public static void setup() { - client = new AutoRestParameterGroupingTestServiceImpl("http://localhost.:3000", null); + client = new AutoRestParameterGroupingTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurereport/CoverageReporter.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurereport/CoverageReporter.java index 83f3cd1fb0..495bdde955 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurereport/CoverageReporter.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurereport/CoverageReporter.java @@ -4,10 +4,11 @@ import java.util.List; import java.util.Map; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import fixtures.azurereport.implementation.AutoRestReportServiceForAzureImpl; public final class CoverageReporter { - private static AutoRestReportServiceForAzureImpl client = new AutoRestReportServiceForAzureImpl("http://localhost:3000", null); + private static AutoRestReportServiceForAzureImpl client = new AutoRestReportServiceForAzureImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); private CoverageReporter() { } diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/ApiVersionDefaultTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/ApiVersionDefaultTests.java index ddb19d384d..ef33a385c0 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/ApiVersionDefaultTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/ApiVersionDefaultTests.java @@ -1,5 +1,6 @@ package fixtures.azurespecials; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.BeforeClass; import org.junit.Test; @@ -10,7 +11,7 @@ public class ApiVersionDefaultTests { @BeforeClass public static void setup() { - client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost.:3000", null); + client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/ApiVersionLocalTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/ApiVersionLocalTests.java index be8c0ce6fa..70e59503c1 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/ApiVersionLocalTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/ApiVersionLocalTests.java @@ -1,5 +1,6 @@ package fixtures.azurespecials; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.BeforeClass; import org.junit.Test; @@ -10,7 +11,7 @@ public class ApiVersionLocalTests { @BeforeClass public static void setup() { - client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost.:3000", null); + client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java index 41607ef9df..b02e2f43d4 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java @@ -2,6 +2,7 @@ import com.microsoft.rest.ServiceResponseWithHeaders; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -15,13 +16,13 @@ public class HeaderOperationsTests { @BeforeClass public static void setup() { - client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost.:3000", null); + client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test public void customNamedRequestId() throws Exception { ServiceResponseWithHeaders response = client.headers().customNamedRequestIdWithServiceResponseAsync("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0").toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); - Assert.assertEquals("123", response.getHeaders().fooRequestId()); + Assert.assertEquals(200, response.response().code()); + Assert.assertEquals("123", response.headers().fooRequestId()); } } diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SkipUrlEncodingTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SkipUrlEncodingTests.java index c133562146..71c9c58482 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SkipUrlEncodingTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SkipUrlEncodingTests.java @@ -1,5 +1,6 @@ package fixtures.azurespecials; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -16,7 +17,7 @@ public class SkipUrlEncodingTests { @BeforeClass public static void setup() { - client = new AutoRestAzureSpecialParametersTestClientImpl(baseUrl, null).skipUrlEncodings(); + client = new AutoRestAzureSpecialParametersTestClientImpl(baseUrl, new BasicAuthenticationCredentials(null, null)).skipUrlEncodings(); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SubscriptionInCredentialsTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SubscriptionInCredentialsTests.java index 49f4c69989..5261a1fff6 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SubscriptionInCredentialsTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SubscriptionInCredentialsTests.java @@ -1,7 +1,7 @@ package fixtures.azurespecials; -import com.microsoft.azure.RequestIdHeaderInterceptor; -import com.microsoft.azure.RestClient; +import com.microsoft.rest.interceptors.RequestIdHeaderInterceptor; +import com.microsoft.rest.RestClient; import com.microsoft.rest.credentials.TokenCredentials; import org.junit.BeforeClass; diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SubscriptionInMethodTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SubscriptionInMethodTests.java index 7de8a61cf0..4a992705b3 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SubscriptionInMethodTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/azurespecials/SubscriptionInMethodTests.java @@ -1,7 +1,7 @@ package fixtures.azurespecials; -import com.microsoft.azure.RequestIdHeaderInterceptor; -import com.microsoft.azure.RestClient; +import com.microsoft.rest.interceptors.RequestIdHeaderInterceptor; +import com.microsoft.rest.RestClient; import com.microsoft.rest.credentials.TokenCredentials; import org.junit.Assert; diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/head/HttpSuccessTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/head/HttpSuccessTests.java index 61c328c262..b545d5bf45 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/head/HttpSuccessTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/head/HttpSuccessTests.java @@ -1,5 +1,6 @@ package fixtures.head; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -11,7 +12,7 @@ public class HttpSuccessTests { @BeforeClass public static void setup() { - client = new AutoRestHeadTestServiceImpl("http://localhost.:3000", null); + client = new AutoRestHeadTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/headexceptions/HeadExceptionTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/headexceptions/HeadExceptionTests.java index 612a30a0e1..f1b635888c 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/headexceptions/HeadExceptionTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/headexceptions/HeadExceptionTests.java @@ -1,17 +1,17 @@ package fixtures.headexceptions; -import com.microsoft.rest.ServiceException; +import com.microsoft.rest.RestException; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; +import fixtures.headexceptions.implementation.AutoRestHeadExceptionTestServiceImpl; import org.junit.BeforeClass; import org.junit.Test; -import fixtures.headexceptions.implementation.AutoRestHeadExceptionTestServiceImpl; - public class HeadExceptionTests { private static AutoRestHeadExceptionTestServiceImpl client; @BeforeClass public static void setup() { - client = new AutoRestHeadExceptionTestServiceImpl("http://localhost.:3000", null); + client = new AutoRestHeadExceptionTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test @@ -24,7 +24,7 @@ public void headException204() throws Exception { client.headExceptions().head204(); } - @Test(expected = ServiceException.class) + @Test(expected = RestException.class) public void headException404() throws Exception { client.headExceptions().head404(); } diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LRORetrysTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LRORetrysTests.java index 4fb602d603..f71202b055 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LRORetrysTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LRORetrysTests.java @@ -1,5 +1,6 @@ package fixtures.lro; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -13,7 +14,7 @@ public class LRORetrysTests { @BeforeClass public static void setup() { - client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost.:3000", null); + client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); client.getAzureClient().withLongRunningOperationRetryTimeout(0); } diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROSADsTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROSADsTests.java index 71b8473eb5..b42024e0d4 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROSADsTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROSADsTests.java @@ -1,14 +1,13 @@ package fixtures.lro; import com.microsoft.azure.CloudException; - +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; +import fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl; +import fixtures.lro.implementation.ProductInner; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl; -import fixtures.lro.implementation.ProductInner; - import static org.junit.Assert.fail; public class LROSADsTests { @@ -16,7 +15,7 @@ public class LROSADsTests { @BeforeClass public static void setup() { - client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost.:3000", null); + client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); client.getAzureClient().withLongRunningOperationRetryTimeout(0); } @@ -28,7 +27,7 @@ public void putNonRetry400() throws Exception { client.lROSADs().putNonRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -40,7 +39,7 @@ public void putNonRetry201Creating400() throws Exception { client.lROSADs().putNonRetry201Creating400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -52,7 +51,7 @@ public void putAsyncRelativeRetry400() throws Exception { client.lROSADs().putAsyncRelativeRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -62,7 +61,7 @@ public void deleteNonRetry400() throws Exception { client.lROSADs().deleteNonRetry400(); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -72,7 +71,7 @@ public void delete202NonRetry400() throws Exception { client.lROSADs().delete202NonRetry400(); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -82,7 +81,7 @@ public void deleteAsyncRelativeRetry400() throws Exception { client.lROSADs().deleteAsyncRelativeRetry400(); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -94,7 +93,7 @@ public void postNonRetry400() throws Exception { client.lROSADs().postNonRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -106,7 +105,7 @@ public void post202NonRetry400() throws Exception { client.lROSADs().post202NonRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -118,7 +117,7 @@ public void postAsyncRelativeRetry400() throws Exception { client.lROSADs().postAsyncRelativeRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -130,7 +129,7 @@ public void putError201NoProvisioningStatePayload() throws Exception { client.lROSADs().putError201NoProvisioningStatePayload(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } @@ -143,7 +142,7 @@ public void putAsyncRelativeRetryNoStatus() throws Exception { client.lROSADs().putAsyncRelativeRetryNoStatus(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } @@ -156,7 +155,7 @@ public void putAsyncRelativeRetryNoStatusPayload() throws Exception { client.lROSADs().putAsyncRelativeRetryNoStatusPayload(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } @@ -172,7 +171,7 @@ public void deleteAsyncRelativeRetryNoStatus() throws Exception { client.lROSADs().deleteAsyncRelativeRetryNoStatus(); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } @@ -185,7 +184,7 @@ public void post202NoLocation() throws Exception { client.lROSADs().post202NoLocation(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(202, ex.getResponse().code()); + Assert.assertEquals(202, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("Response does not contain an Azure")); } } @@ -198,7 +197,7 @@ public void postAsyncRelativeRetryNoPayload() throws Exception { client.lROSADs().postAsyncRelativeRetryNoPayload(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROsCustomHeaderTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROsCustomHeaderTests.java index 406917d76e..cf13f65d08 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROsCustomHeaderTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROsCustomHeaderTests.java @@ -1,5 +1,6 @@ package fixtures.lro; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -13,7 +14,7 @@ public class LROsCustomHeaderTests { @BeforeClass public static void setup() { - client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost:3000", null); + client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); client.restClient().headers().addHeader("x-ms-client-request-id", "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"); client.getAzureClient().withLongRunningOperationRetryTimeout(0); } diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROsTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROsTests.java index f05b72010d..415eb3f577 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROsTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/lro/LROsTests.java @@ -1,25 +1,22 @@ package fixtures.lro; import com.microsoft.azure.CloudException; -import com.microsoft.azure.RestClient; +import com.microsoft.rest.RestClient; import com.microsoft.rest.ServiceCallback; - +import fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl; +import fixtures.lro.implementation.ProductInner; +import fixtures.lro.implementation.SkuInner; +import fixtures.lro.implementation.SubProductInner; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; +import rx.Observable; +import rx.Subscriber; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl; -import fixtures.lro.implementation.ProductInner; -import fixtures.lro.implementation.SkuInner; -import fixtures.lro.implementation.SubProductInner; -import okhttp3.logging.HttpLoggingInterceptor; -import rx.Observable; -import rx.Subscriber; - import static org.junit.Assert.fail; public class LROsTests { @@ -29,7 +26,6 @@ public class LROsTests { public static void setup() { RestClient restClient = new RestClient.Builder() .withBaseUrl("http://localhost:3000") - .withLogLevel(HttpLoggingInterceptor.Level.NONE) .build(); client = new AutoRestLongRunningOperationTestServiceImpl(restClient); client.getAzureClient().withLongRunningOperationRetryTimeout(0); diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/paging/PagingTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/paging/PagingTests.java index 8c8df001b2..9842755eb8 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/paging/PagingTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/paging/PagingTests.java @@ -2,7 +2,10 @@ import com.microsoft.azure.CloudException; import com.microsoft.azure.ListOperationCallback; - +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; +import fixtures.paging.implementation.AutoRestPagingTestServiceImpl; +import fixtures.paging.implementation.PagingGetMultiplePagesWithOffsetOptionsInner; +import fixtures.paging.implementation.ProductInner; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -11,10 +14,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import fixtures.paging.implementation.AutoRestPagingTestServiceImpl; -import fixtures.paging.implementation.PagingGetMultiplePagesWithOffsetOptionsInner; -import fixtures.paging.implementation.ProductInner; - import static org.junit.Assert.fail; public class PagingTests { @@ -22,7 +21,7 @@ public class PagingTests { @BeforeClass public static void setup() { - client = new AutoRestPagingTestServiceImpl("http://localhost:3000", null); + client = new AutoRestPagingTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test @@ -106,7 +105,7 @@ public void getSinglePagesFailure() throws Exception { List response = client.pagings().getSinglePagesFailure(); fail(); } catch (CloudException ex) { - Assert.assertNotNull(ex.getResponse()); + Assert.assertNotNull(ex.response()); } } @@ -117,18 +116,13 @@ public void getMultiplePagesFailure() throws Exception { response.size(); fail(); } catch (CloudException ex) { - Assert.assertNotNull(ex.getResponse()); + Assert.assertNotNull(ex.response()); } } @Test public void getMultiplePagesFailureUri() throws Exception { - try { - List response = client.pagings().getMultiplePagesFailureUri(); - response.size(); - fail(); - } catch (CloudException ex) { - Assert.assertNotNull(ex.getResponse()); - } + List response = client.pagings().getMultiplePagesFailureUri(); + Assert.assertEquals(1, response.size()); } } diff --git a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/subscriptionidapiversion/GroupTests.java b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/subscriptionidapiversion/GroupTests.java index f2454bba6a..50279a2229 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/subscriptionidapiversion/GroupTests.java +++ b/src/generator/AutoRest.Java.Azure.Fluent.Tests/src/test/java/fixtures/subscriptionidapiversion/GroupTests.java @@ -1,5 +1,6 @@ package fixtures.subscriptionidapiversion; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -14,7 +15,7 @@ public class GroupTests { @BeforeClass public static void setup() { - client = new MicrosoftAzureTestUrlImpl("http://localhost.:3000", null); + client = new MicrosoftAzureTestUrlImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Fluent/CodeGeneratorJvaf.cs b/src/generator/AutoRest.Java.Azure.Fluent/CodeGeneratorJvaf.cs index 4bcb94b218..d8eddfce36 100644 --- a/src/generator/AutoRest.Java.Azure.Fluent/CodeGeneratorJvaf.cs +++ b/src/generator/AutoRest.Java.Azure.Fluent/CodeGeneratorJvaf.cs @@ -21,7 +21,7 @@ namespace AutoRest.Java.Azure.Fluent { public class CodeGeneratorJvaf : CodeGeneratorJva { - private const string ClientRuntimePackage = "com.microsoft.azure:azure-client-runtime:1.0.0-beta5-SNAPSHOT"; + private const string ClientRuntimePackage = "com.microsoft.azure:azure-client-runtime:1.0.0-beta6-SNAPSHOT"; private const string _packageInfoFileName = "package-info.java"; public override bool IsSingleFileGenerationSupported => true; diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azureparametergrouping/ParameterGroupingTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azureparametergrouping/ParameterGroupingTests.java index 820955ff80..ace3881305 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azureparametergrouping/ParameterGroupingTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azureparametergrouping/ParameterGroupingTests.java @@ -1,5 +1,6 @@ package fixtures.azureparametergrouping; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.BeforeClass; import org.junit.Test; @@ -14,7 +15,7 @@ public class ParameterGroupingTests { @BeforeClass public static void setup() { - client = new AutoRestParameterGroupingTestServiceImpl("http://localhost:3000", null); + client = new AutoRestParameterGroupingTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurereport/CoverageReporter.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurereport/CoverageReporter.java index 83f3cd1fb0..495bdde955 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurereport/CoverageReporter.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurereport/CoverageReporter.java @@ -4,10 +4,11 @@ import java.util.List; import java.util.Map; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import fixtures.azurereport.implementation.AutoRestReportServiceForAzureImpl; public final class CoverageReporter { - private static AutoRestReportServiceForAzureImpl client = new AutoRestReportServiceForAzureImpl("http://localhost:3000", null); + private static AutoRestReportServiceForAzureImpl client = new AutoRestReportServiceForAzureImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); private CoverageReporter() { } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/ApiVersionDefaultTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/ApiVersionDefaultTests.java index 6c98d674e1..4814fdc5e6 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/ApiVersionDefaultTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/ApiVersionDefaultTests.java @@ -1,6 +1,7 @@ package fixtures.azurespecials; import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -12,30 +13,30 @@ public class ApiVersionDefaultTests { @BeforeClass public static void setup() { - client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", null); + client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test public void getMethodGlobalValid() throws Exception { ServiceResponse response = client.apiVersionDefaults().getMethodGlobalValidWithServiceResponseAsync().toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } @Test public void getMethodGlobalNotProvidedValid() throws Exception { ServiceResponse response = client.apiVersionDefaults().getMethodGlobalNotProvidedValidWithServiceResponseAsync().toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } @Test public void getPathGlobalValid() throws Exception { ServiceResponse response = client.apiVersionDefaults().getPathGlobalValidWithServiceResponseAsync().toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } @Test public void getSwaggerGlobalValid() throws Exception { ServiceResponse response = client.apiVersionDefaults().getSwaggerGlobalValidWithServiceResponseAsync().toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/ApiVersionLocalTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/ApiVersionLocalTests.java index 98df057fc0..28588b563b 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/ApiVersionLocalTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/ApiVersionLocalTests.java @@ -1,6 +1,7 @@ package fixtures.azurespecials; import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -12,30 +13,30 @@ public class ApiVersionLocalTests { @BeforeClass public static void setup() { - client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", null); + client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test public void getMethodLocalValid() throws Exception { ServiceResponse response = client.apiVersionLocals().getMethodLocalValidWithServiceResponseAsync().toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } @Test public void getMethodGlobalNotProvidedValid() throws Exception { ServiceResponse response = client.apiVersionLocals().getMethodLocalNullWithServiceResponseAsync().toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } @Test public void getPathGlobalValid() throws Exception { ServiceResponse response = client.apiVersionLocals().getPathLocalValidWithServiceResponseAsync().toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } @Test public void getSwaggerGlobalValid() throws Exception { ServiceResponse response = client.apiVersionLocals().getSwaggerLocalValidWithServiceResponseAsync().toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java index 8588441ef2..9ad6db9e52 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/HeaderOperationsTests.java @@ -2,6 +2,7 @@ import com.microsoft.rest.ServiceResponseWithHeaders; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import fixtures.azurespecials.implementation.AutoRestAzureSpecialParametersTestClientImpl; import fixtures.azurespecials.models.HeaderCustomNamedRequestIdHeaders; import fixtures.azurespecials.models.HeaderCustomNamedRequestIdParamGroupingHeaders; @@ -15,14 +16,14 @@ public class HeaderOperationsTests { @BeforeClass public static void setup() { - client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", null); + client = new AutoRestAzureSpecialParametersTestClientImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test public void customNamedRequestId() throws Exception { ServiceResponseWithHeaders response = client.headers().customNamedRequestIdWithServiceResponseAsync("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0").toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); - Assert.assertEquals("123", response.getHeaders().fooRequestId()); + Assert.assertEquals(200, response.response().code()); + Assert.assertEquals("123", response.headers().fooRequestId()); } @Test @@ -30,7 +31,7 @@ public void customNamedRequestIdParamGrouping() throws Exception { HeaderCustomNamedRequestIdParamGroupingParameters group = new HeaderCustomNamedRequestIdParamGroupingParameters(); group.withFooClientRequestId("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"); ServiceResponseWithHeaders response = client.headers().customNamedRequestIdParamGroupingWithServiceResponseAsync(group).toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); - Assert.assertEquals("123", response.getHeaders().fooRequestId()); + Assert.assertEquals(200, response.response().code()); + Assert.assertEquals("123", response.headers().fooRequestId()); } } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SkipUrlEncodingTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SkipUrlEncodingTests.java index b3556cd34c..c689e4b14a 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SkipUrlEncodingTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SkipUrlEncodingTests.java @@ -1,5 +1,6 @@ package fixtures.azurespecials; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -15,7 +16,7 @@ public class SkipUrlEncodingTests { @BeforeClass public static void setup() { - client = new AutoRestAzureSpecialParametersTestClientImpl(baseUrl, null).skipUrlEncodings(); + client = new AutoRestAzureSpecialParametersTestClientImpl(baseUrl, new BasicAuthenticationCredentials(null, null)).skipUrlEncodings(); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SubscriptionInCredentialsTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SubscriptionInCredentialsTests.java index 49f4c69989..5261a1fff6 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SubscriptionInCredentialsTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SubscriptionInCredentialsTests.java @@ -1,7 +1,7 @@ package fixtures.azurespecials; -import com.microsoft.azure.RequestIdHeaderInterceptor; -import com.microsoft.azure.RestClient; +import com.microsoft.rest.interceptors.RequestIdHeaderInterceptor; +import com.microsoft.rest.RestClient; import com.microsoft.rest.credentials.TokenCredentials; import org.junit.BeforeClass; diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SubscriptionInMethodTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SubscriptionInMethodTests.java index 7de8a61cf0..4a992705b3 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SubscriptionInMethodTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/SubscriptionInMethodTests.java @@ -1,7 +1,7 @@ package fixtures.azurespecials; -import com.microsoft.azure.RequestIdHeaderInterceptor; -import com.microsoft.azure.RestClient; +import com.microsoft.rest.interceptors.RequestIdHeaderInterceptor; +import com.microsoft.rest.RestClient; import com.microsoft.rest.credentials.TokenCredentials; import org.junit.Assert; diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/XMsClientRequestIdTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/XMsClientRequestIdTests.java index aedaca543b..662775eb4d 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/XMsClientRequestIdTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/azurespecials/XMsClientRequestIdTests.java @@ -2,15 +2,13 @@ import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.credentials.TokenCredentials; - +import fixtures.azurespecials.implementation.AutoRestAzureSpecialParametersTestClientImpl; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.UUID; -import fixtures.azurespecials.implementation.AutoRestAzureSpecialParametersTestClientImpl; - public class XMsClientRequestIdTests { private static AutoRestAzureSpecialParametersTestClientImpl client; @@ -26,13 +24,13 @@ public void get() throws Exception { client.restClient().headers().addHeader("x-ms-client-request-id", "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"); ServiceResponse response = client.xMsClientRequestIds().getWithServiceResponseAsync().toBlocking().last(); client.restClient().headers().removeHeader("x-ms-client-request-id"); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } @Test public void paramGet() throws Exception { client.restClient().headers().removeHeader("x-ms-client-request-id"); ServiceResponse response = client.xMsClientRequestIds().paramGetWithServiceResponseAsync("9C4D50EE-2D56-4CD3-8152-34347DC9F2B0").toBlocking().last(); - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); } } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/head/HttpSuccessTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/head/HttpSuccessTests.java index 5417c88df1..c83b219c4f 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/head/HttpSuccessTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/head/HttpSuccessTests.java @@ -1,5 +1,7 @@ package fixtures.head; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; +import okhttp3.logging.HttpLoggingInterceptor; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -10,8 +12,8 @@ public class HttpSuccessTests { private static AutoRestHeadTestServiceImpl client; @BeforeClass - public static void setup() { - client = new AutoRestHeadTestServiceImpl("http://localhost:3000", null); + public static void setup() throws Exception { + client = new AutoRestHeadTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/headexceptions/HeadExceptionTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/headexceptions/HeadExceptionTests.java index 6e6e741c2d..d67dfe0d09 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/headexceptions/HeadExceptionTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/headexceptions/HeadExceptionTests.java @@ -1,6 +1,7 @@ package fixtures.headexceptions; -import com.microsoft.rest.ServiceException; +import com.microsoft.rest.RestException; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.BeforeClass; import org.junit.Test; @@ -11,7 +12,7 @@ public class HeadExceptionTests { @BeforeClass public static void setup() { - client = new AutoRestHeadExceptionTestServiceImpl("http://localhost:3000", null); + client = new AutoRestHeadExceptionTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test @@ -24,7 +25,7 @@ public void headException204() throws Exception { client.headExceptions().head204(); } - @Test(expected = ServiceException.class) + @Test(expected = RestException.class) public void headException404() throws Exception { client.headExceptions().head404(); } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LRORetrysTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LRORetrysTests.java index b0ed99e72b..4fb80bb4aa 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LRORetrysTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LRORetrysTests.java @@ -1,15 +1,12 @@ package fixtures.lro; -import com.microsoft.azure.RestClient; - +import com.microsoft.rest.RestClient; +import fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl; +import fixtures.lro.models.Product; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl; -import fixtures.lro.models.Product; -import okhttp3.logging.HttpLoggingInterceptor; - public class LRORetrysTests { private static AutoRestLongRunningOperationTestServiceImpl client; @@ -17,7 +14,6 @@ public class LRORetrysTests { public static void setup() { RestClient restClient = new RestClient.Builder() .withBaseUrl("http://localhost:3000") - .withLogLevel(HttpLoggingInterceptor.Level.NONE) .build(); client = new AutoRestLongRunningOperationTestServiceImpl(restClient); client.getAzureClient().withLongRunningOperationRetryTimeout(0); diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROSADsTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROSADsTests.java index 29c1aa5026..202823bf49 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROSADsTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROSADsTests.java @@ -2,6 +2,7 @@ import com.microsoft.azure.CloudException; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -16,7 +17,7 @@ public class LROSADsTests { @BeforeClass public static void setup() { - client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost:3000", null); + client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); client.getAzureClient().withLongRunningOperationRetryTimeout(0); } @@ -28,7 +29,7 @@ public void putNonRetry400() throws Exception { client.lROSADs().putNonRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -40,7 +41,7 @@ public void putNonRetry201Creating400() throws Exception { client.lROSADs().putNonRetry201Creating400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -52,7 +53,7 @@ public void putAsyncRelativeRetry400() throws Exception { client.lROSADs().putAsyncRelativeRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -62,7 +63,7 @@ public void deleteNonRetry400() throws Exception { client.lROSADs().deleteNonRetry400(); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -72,7 +73,7 @@ public void delete202NonRetry400() throws Exception { client.lROSADs().delete202NonRetry400(); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -82,7 +83,7 @@ public void deleteAsyncRelativeRetry400() throws Exception { client.lROSADs().deleteAsyncRelativeRetry400(); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -94,7 +95,7 @@ public void postNonRetry400() throws Exception { client.lROSADs().postNonRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -106,7 +107,7 @@ public void post202NonRetry400() throws Exception { client.lROSADs().post202NonRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -118,7 +119,7 @@ public void postAsyncRelativeRetry400() throws Exception { client.lROSADs().postAsyncRelativeRetry400(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -130,7 +131,7 @@ public void putError201NoProvisioningStatePayload() throws Exception { client.lROSADs().putError201NoProvisioningStatePayload(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } @@ -143,7 +144,7 @@ public void putAsyncRelativeRetryNoStatus() throws Exception { client.lROSADs().putAsyncRelativeRetryNoStatus(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } @@ -156,7 +157,7 @@ public void putAsyncRelativeRetryNoStatusPayload() throws Exception { client.lROSADs().putAsyncRelativeRetryNoStatusPayload(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } @@ -172,7 +173,7 @@ public void deleteAsyncRelativeRetryNoStatus() throws Exception { client.lROSADs().deleteAsyncRelativeRetryNoStatus(); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } @@ -185,7 +186,7 @@ public void post202NoLocation() throws Exception { client.lROSADs().post202NoLocation(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(202, ex.getResponse().code()); + Assert.assertEquals(202, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("Response does not contain an Azure")); } } @@ -198,7 +199,7 @@ public void postAsyncRelativeRetryNoPayload() throws Exception { client.lROSADs().postAsyncRelativeRetryNoPayload(product); fail(); } catch (CloudException ex) { - Assert.assertEquals(200, ex.getResponse().code()); + Assert.assertEquals(200, ex.response().code()); Assert.assertTrue(ex.getMessage().contains("does not contain a valid body")); } } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROsCustomHeaderTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROsCustomHeaderTests.java index 1d32c7b4ec..29ba83b78a 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROsCustomHeaderTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROsCustomHeaderTests.java @@ -2,6 +2,7 @@ import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -19,7 +20,7 @@ public class LROsCustomHeaderTests { @BeforeClass public static void setup() { - client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost:3000", null); + client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); client.restClient().headers().addHeader("x-ms-client-request-id", "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0"); client.getAzureClient().withLongRunningOperationRetryTimeout(0); } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROsTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROsTests.java index b177d3593d..ada6d1d2dd 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROsTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/lro/LROsTests.java @@ -1,9 +1,13 @@ package fixtures.lro; import com.microsoft.azure.CloudException; -import com.microsoft.azure.RestClient; +import com.microsoft.rest.LogLevel; +import com.microsoft.rest.RestClient; import com.microsoft.rest.ServiceCallback; - +import fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl; +import fixtures.lro.models.Product; +import fixtures.lro.models.Sku; +import fixtures.lro.models.SubProduct; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; @@ -12,12 +16,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl; -import fixtures.lro.models.Product; -import fixtures.lro.models.Sku; -import fixtures.lro.models.SubProduct; -import okhttp3.logging.HttpLoggingInterceptor; - import static org.junit.Assert.fail; public class LROsTests { @@ -26,9 +24,9 @@ public class LROsTests { @BeforeClass public static void setup() { RestClient restClient = new RestClient.Builder() - .withBaseUrl("http://localhost:3000") - .withLogLevel(HttpLoggingInterceptor.Level.NONE) - .build(); + .withBaseUrl("http://localhost:3000") + .withLogLevel(LogLevel.BODY_AND_HEADERS) + .build(); client = new AutoRestLongRunningOperationTestServiceImpl(restClient); client.getAzureClient().withLongRunningOperationRetryTimeout(0); } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/paging/PagingTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/paging/PagingTests.java index d9bae3d9e3..0758311923 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/paging/PagingTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/paging/PagingTests.java @@ -1,8 +1,19 @@ package fixtures.paging; +import com.microsoft.azure.AzureResponseBuilder; import com.microsoft.azure.CloudException; import com.microsoft.azure.ListOperationCallback; - +import com.microsoft.azure.serializer.AzureJacksonAdapter; +import com.microsoft.rest.LogLevel; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; +import com.microsoft.rest.interceptors.LoggingInterceptor; +import fixtures.paging.implementation.AutoRestPagingTestServiceImpl; +import fixtures.paging.models.CustomParameterGroup; +import fixtures.paging.models.PagingGetMultiplePagesWithOffsetOptions; +import fixtures.paging.models.Product; +import fixtures.paging.models.ProductProperties; +import okhttp3.logging.HttpLoggingInterceptor; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -11,11 +22,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import fixtures.paging.implementation.AutoRestPagingTestServiceImpl; -import fixtures.paging.models.PagingGetMultiplePagesWithOffsetOptions; -import fixtures.paging.models.Product; -import fixtures.paging.models.ProductProperties; - import static org.junit.Assert.fail; public class PagingTests { @@ -23,7 +29,13 @@ public class PagingTests { @BeforeClass public static void setup() { - client = new AutoRestPagingTestServiceImpl("http://localhost:3000", null); + RestClient restClient = new RestClient.Builder() + .withBaseUrl("http://localhost:3000") + .withInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS)) + .withSerializerAdapter(new AzureJacksonAdapter()) + .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) + .build(); + client = new AutoRestPagingTestServiceImpl(restClient);; } @Test @@ -112,7 +124,7 @@ public void getSinglePagesFailure() throws Exception { List response = client.pagings().getSinglePagesFailure(); fail(); } catch (CloudException ex) { - Assert.assertNotNull(ex.getResponse()); + Assert.assertNotNull(ex.response()); } } @@ -123,18 +135,25 @@ public void getMultiplePagesFailure() throws Exception { response.size(); fail(); } catch (CloudException ex) { - Assert.assertNotNull(ex.getResponse()); + Assert.assertNotNull(ex.response()); } } @Test public void getMultiplePagesFailureUri() throws Exception { - try { - List response = client.pagings().getMultiplePagesFailureUri(); - response.size(); - fail(); - } catch (CloudException ex) { - Assert.assertNotNull(ex.getResponse()); - } + List response = client.pagings().getMultiplePagesFailureUri(); + Assert.assertEquals(1, response.size()); + } + + @Test + public void getMultiplePagesFragmentNextLink() throws Exception { + List response = client.pagings().getMultiplePagesFragmentNextLink("test_user", "1.6"); + Assert.assertEquals(10, response.size()); + } + + @Test + public void getMultiplePagesFragmentWithGroupingNextLink() throws Exception { + List response = client.pagings().getMultiplePagesFragmentWithGroupingNextLink(new CustomParameterGroup().withTenant("test_user").withApiVersion("1.6")); + Assert.assertEquals(10, response.size()); } } diff --git a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/subscriptionidapiversion/GroupTests.java b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/subscriptionidapiversion/GroupTests.java index 9725da9aa0..059119abed 100644 --- a/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/subscriptionidapiversion/GroupTests.java +++ b/src/generator/AutoRest.Java.Azure.Tests/src/test/java/fixtures/subscriptionidapiversion/GroupTests.java @@ -1,5 +1,6 @@ package fixtures.subscriptionidapiversion; +import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -14,7 +15,7 @@ public class GroupTests { @BeforeClass public static void setup() { - client = new MicrosoftAzureTestUrlImpl("http://localhost:3000", null); + client = new MicrosoftAzureTestUrlImpl("http://localhost:3000", new BasicAuthenticationCredentials(null, null)); } @Test diff --git a/src/generator/AutoRest.Java.Azure/CodeGeneratorJva.cs b/src/generator/AutoRest.Java.Azure/CodeGeneratorJva.cs index 7c0ca07b74..436075fd6f 100644 --- a/src/generator/AutoRest.Java.Azure/CodeGeneratorJva.cs +++ b/src/generator/AutoRest.Java.Azure/CodeGeneratorJva.cs @@ -21,7 +21,7 @@ namespace AutoRest.Java.Azure { public class CodeGeneratorJva : CodeGeneratorJv { - private const string ClientRuntimePackage = "com.microsoft.azure:azure-client-runtime:1.0.0-beta5-SNAPSHOT from snapshot repo https://oss.sonatype.org/content/repositories/snapshots/"; + private const string ClientRuntimePackage = "com.microsoft.azure:azure-client-runtime:1.0.0-beta6-SNAPSHOT from snapshot repo https://oss.sonatype.org/content/repositories/snapshots/"; private const string _packageInfoFileName = "package-info.java"; public override bool IsSingleFileGenerationSupported => true; diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodyarray/ArrayTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodyarray/ArrayTests.java index 06d47daaff..b5215fa450 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodyarray/ArrayTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodyarray/ArrayTests.java @@ -1,591 +1,591 @@ -package fixtures.bodyarray; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.LocalDate; -import org.joda.time.Period; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import fixtures.bodyarray.implementation.AutoRestSwaggerBATArrayServiceImpl; -import fixtures.bodyarray.models.ErrorException; -import fixtures.bodyarray.models.Product; - -public class ArrayTests { - private static AutoRestSwaggerBATArrayService client; - - @BeforeClass - public static void setup() { - client = new AutoRestSwaggerBATArrayServiceImpl("http://localhost:3000"); - } - - @Test - public void getNull() throws Exception { - Assert.assertNull(client.arrays().getNull()); - } - - @Test - public void getInvalid() throws Exception { - try { - List result = client.arrays().getInvalid(); - Assert.assertTrue(false); - } catch (RuntimeException exception) { - // expected - Assert.assertTrue(exception.getMessage().contains("Unexpected end-of-input")); - } - } - - @Test - public void getEmpty() throws Exception { - List result = client.arrays().getEmpty(); - Assert.assertEquals(0, result.size()); - } - - @Test - public void putEmpty() throws Exception { - client.arrays().putEmpty(new ArrayList()); - } - - @Test - public void getBooleanTfft() throws Exception { - List result = client.arrays().getBooleanTfft(); - Object[] exected = new Boolean[] {true, false, false, true}; - Assert.assertArrayEquals(exected, result.toArray()); - } - - @Test - public void putBooleanTfft() throws Exception { - client.arrays().putBooleanTfft(Arrays.asList(true, false, false, true)); - } - - @Test - public void getBooleanInvalidNull() throws Exception { - try { - List result = client.arrays().getBooleanInvalidNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getBooleanInvalidString() throws Exception { - try { - List result = client.arrays().getBooleanInvalidString(); - } catch (RuntimeException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("only \"true\" or \"false\" recognized")); - } - } - - @Test - public void getIntegerValid() throws Exception { - List result = client.arrays().getIntegerValid(); - Object[] expected = new Integer[] {1, -1, 3, 300}; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putIntegerValid() throws Exception { - client.arrays().putIntegerValid(Arrays.asList(1, -1, 3, 300)); - } - - @Test - public void getIntInvalidNull() throws Exception { - try { - List result = client.arrays().getIntInvalidNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getIntInvalidString() throws Exception { - try { - List result = client.arrays().getIntInvalidString(); - } catch (RuntimeException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("not a valid Integer value")); - } - } - - @Test - public void getLongValid() throws Exception { - List result = client.arrays().getLongValid(); - Object[] expected = new Long[] {1L, -1L, 3L, 300L}; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putLongValid() throws Exception { - client.arrays().putLongValid(Arrays.asList(1L, -1L, 3L, 300L)); - } - - @Test - public void getLongInvalidNull() throws Exception { - try { - List result = client.arrays().getLongInvalidNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getLongInvalidString() throws Exception { - try { - List result = client.arrays().getLongInvalidString(); - } catch (RuntimeException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("not a valid Long value")); - } - } - - @Test - public void getFloatValid() throws Exception { - List result = client.arrays().getFloatValid(); - Object[] expected = new Double[] {0d, -0.01, -1.2e20}; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putFloatValid() throws Exception { - client.arrays().putFloatValid(Arrays.asList(0d, -0.01d, -1.2e20d)); - } - - @Test - public void getFloatInvalidNull() throws Exception { - try { - List result = client.arrays().getFloatInvalidNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getFloatInvalidString() throws Exception { - try { - List result = client.arrays().getFloatInvalidString(); - } catch (RuntimeException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("not a valid Double value")); - } - } - - @Test - public void getDoubleValid() throws Exception { - List result = client.arrays().getDoubleValid(); - Object[] expected = new Double[] {0d, -0.01, -1.2e20}; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putDoubleValid() throws Exception { - client.arrays().putDoubleValid(Arrays.asList(0d, -0.01d, -1.2e20d)); - } - - @Test - public void getDoubleInvalidNull() throws Exception { - try { - List result = client.arrays().getDoubleInvalidNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getDoubleInvalidString() throws Exception { - try { - List result = client.arrays().getDoubleInvalidString(); - } catch (RuntimeException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("not a valid Double value")); - } - } - - @Test - public void getStringValid() throws Exception { - List result = client.arrays().getStringValid(); - Object[] expected = new String[] {"foo1", "foo2", "foo3"}; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putStringValid() throws Exception { - client.arrays().putStringValid(Arrays.asList("foo1", "foo2", "foo3")); - } - - @Test - public void getStringWithNull() throws Exception { - try { - List result = client.arrays().getStringWithNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getStringWithInvalid() throws Exception { - try { - List result = client.arrays().getStringWithInvalid(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("InvalidFormatException")); - } - } - - @Test - public void getUuidValid() throws Exception { - List result = client.arrays().getUuidValid(); - Object[] expected = new UUID[] {UUID.fromString("6dcc7237-45fe-45c4-8a6b-3a8a3f625652"), - UUID.fromString("d1399005-30f7-40d6-8da6-dd7c89ad34db"), - UUID.fromString("f42f6aa1-a5bc-4ddf-907e-5f915de43205")}; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putUuidValid() throws Exception { - client.arrays().putUuidValid(Arrays.asList(UUID.fromString("6dcc7237-45fe-45c4-8a6b-3a8a3f625652"), - UUID.fromString("d1399005-30f7-40d6-8da6-dd7c89ad34db"), UUID.fromString("f42f6aa1-a5bc-4ddf-907e-5f915de43205"))); - } - - @Test - public void getUuidInvalidChars() throws Exception { - try { - List result = client.arrays().getUuidInvalidChars(); - Assert.fail(); - } catch (RuntimeException ex) { - // expected - Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("UUID has to be represented")); - } - } - @Test - public void getDateValid() throws Exception { - List result = client.arrays().getDateValid(); - Object[] expected = new LocalDate[] { - new LocalDate(2000, 12, 1), - new LocalDate(1980, 1, 2), - new LocalDate(1492, 10, 12) - }; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putDateValid() throws Exception { - client.arrays().putDateValid(Arrays.asList( - new LocalDate(2000, 12, 1), - new LocalDate(1980, 1, 2), - new LocalDate(1492, 10, 12) - )); - } - - @Test - public void getDateInvalidNull() throws Exception { - try { - List result = client.arrays().getDateInvalidNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getDateInvalidString() throws Exception { - try { - List result = client.arrays().getDateInvalidChars(); - } catch (RuntimeException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("Invalid format: \"date\"")); - } - } - - @Test - public void getDateTimeValid() throws Exception { - List result = client.arrays().getDateTimeValid(); - Object[] expected = new DateTime[] { - new DateTime(2000, 12, 1, 0, 0, 1, DateTimeZone.UTC), - new DateTime(1980, 1, 2, 0, 11, 35, DateTimeZone.UTC), - new DateTime(1492, 10, 12, 10, 15, 1, DateTimeZone.UTC) - }; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putDateTimeValid() throws Exception { - client.arrays().putDateTimeValid(Arrays.asList( - new DateTime(2000, 12, 1, 0, 0, 1, DateTimeZone.UTC), - new DateTime(1980, 1, 2, 0, 11, 35, DateTimeZone.UTC), - new DateTime(1492, 10, 12, 10, 15, 1, DateTimeZone.UTC) - )); - } - - @Test - public void getDateTimeInvalidNull() throws Exception { - try { - List result = client.arrays().getDateTimeInvalidNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getDateTimeInvalidString() throws Exception { - try { - List result = client.arrays().getDateTimeInvalidChars(); - } catch (RuntimeException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("Invalid format: \"date-time\"")); - } - } - - @Test - public void getDateTimeRfc1123Valid() throws Exception { - List result = client.arrays().getDateTimeRfc1123Valid(); - Object[] expected = new DateTime[] { - new DateTime(2000, 12, 1, 0, 0, 1, DateTimeZone.UTC), - new DateTime(1980, 1, 2, 0, 11, 35, DateTimeZone.UTC), - new DateTime(1492, 10, 12, 10, 15, 1, DateTimeZone.UTC) - }; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putDateTimeRfc1123Valid() throws Exception { - client.arrays().putDateTimeRfc1123Valid(Arrays.asList( - new DateTime(2000, 12, 1, 0, 0, 1, DateTimeZone.UTC), - new DateTime(1980, 1, 2, 0, 11, 35, DateTimeZone.UTC), - new DateTime(1492, 10, 12, 10, 15, 1, DateTimeZone.UTC) - )); - } - - @Test - public void getDurationValid() throws Exception { - List result = client.arrays().getDurationValid(); - Object[] expected = new Period[] { - new Period(0, 0, 0, 123, 22, 14, 12, 11), - new Period(0, 0, 0, 5, 1, 0, 0, 0) - }; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putDurationValid() throws Exception { - client.arrays().putDurationValid(Arrays.asList( - new Period(0, 0, 0, 123, 22, 14, 12, 11), - new Period(0, 0, 0, 5, 1, 0, 0, 0))); - } - - @Test - public void getByteValid() throws Exception { - List result = client.arrays().getByteValid(); - Object[] expected = new byte[][] { - new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFA}, - new byte[] {(byte) 0x01, (byte) 0x02, (byte) 0x03}, - new byte[] {(byte) 0x25, (byte) 0x29, (byte) 0x43} - }; - Assert.assertArrayEquals(expected, result.toArray()); - } - - @Test - public void putByteValid() throws Exception { - client.arrays().putByteValid(Arrays.asList( - new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFA}, - new byte[] {(byte) 0x01, (byte) 0x02, (byte) 0x03}, - new byte[] {(byte) 0x25, (byte) 0x29, (byte) 0x43} - )); - } - - @Test - public void getByteInvalidNull() throws Exception { - try { - List result = client.arrays().getByteInvalidNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getBase64Url() throws Exception { - List result = client.arrays().getBase64Url(); - Assert.assertEquals(3, result.size()); - Assert.assertEquals("a string that gets encoded with base64url", new String(result.get(0))); - Assert.assertEquals("test string", new String(result.get(1))); - Assert.assertEquals("Lorem ipsum", new String(result.get(2))); - } - - @Test - public void getComplexNull() throws Exception { - try { - List result = client.arrays().getComplexNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getComplexEmpty() throws Exception { - List result = client.arrays().getComplexEmpty(); - Assert.assertEquals(0, result.size()); - } - - @Test - public void getComplexItemNull() throws Exception { - List result = client.arrays().getComplexItemNull(); - Assert.assertEquals(3, result.size()); - Assert.assertNull(result.get(1)); - } - - @Test - public void getComplexItemEmpty() throws Exception { - List result = client.arrays().getComplexItemEmpty(); - Assert.assertEquals(3, result.size()); - Assert.assertNull(result.get(1).stringProperty()); - } - - @Test - public void getComplexValid() throws Exception { - List result = client.arrays().getComplexValid(); - Assert.assertEquals(3, result.size()); - Assert.assertEquals(5, result.get(2).integer().intValue()); - Assert.assertEquals("6", result.get(2).stringProperty()); - } - - @Test - public void putComplexValid() throws Exception { - List body = new ArrayList(); - Product p1 = new Product(); - p1.withInteger(1); - p1.withStringProperty("2"); - body.add(p1); - Product p2 = new Product(); - p2.withInteger(3); - p2.withStringProperty("4"); - body.add(p2); - Product p3 = new Product(); - p3.withInteger(5); - p3.withStringProperty("6"); - body.add(p3); - client.arrays().putComplexValid(body); - } - - @Test - public void getArrayNull() throws Exception { - try { - List> result = client.arrays().getArrayNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getArrayEmpty() throws Exception { - List> result = client.arrays().getArrayEmpty(); - Assert.assertEquals(0, result.size()); - } - - @Test - public void getArrayItemNull() throws Exception { - List> result = client.arrays().getArrayItemNull(); - Assert.assertEquals(3, result.size()); - Assert.assertNull(result.get(1)); - } - - @Test - public void getArrayItemEmpty() throws Exception { - List> result = client.arrays().getArrayItemEmpty(); - Assert.assertEquals(3, result.size()); - Assert.assertEquals(0, result.get(1).size()); - } - - @Test - public void getArrayValid() throws Exception { - List> result = client.arrays().getArrayValid(); - Assert.assertArrayEquals(new String[]{"1", "2", "3"}, result.get(0).toArray()); - Assert.assertArrayEquals(new String[]{"4", "5", "6"}, result.get(1).toArray()); - Assert.assertArrayEquals(new String[] {"7", "8", "9"}, result.get(2).toArray()); - } - - @Test - public void putArrayValid() throws Exception { - List> body = new ArrayList>(); - body.add(Arrays.asList("1", "2", "3")); - body.add(Arrays.asList("4", "5", "6")); - body.add(Arrays.asList("7", "8", "9")); - client.arrays().putArrayValid(body); - } - - @Test - public void getDictionaryNull() throws Exception { - try { - List> result = client.arrays().getDictionaryNull(); - } catch (ErrorException ex) { - // expected - Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); - } - } - - @Test - public void getDictionaryEmpty() throws Exception { - List> result = client.arrays().getDictionaryEmpty(); - Assert.assertEquals(0, result.size()); - } - - @Test - public void getDictionaryItemNull() throws Exception { - List> result = client.arrays().getDictionaryItemNull(); - Assert.assertEquals(3, result.size()); - Assert.assertNull(result.get(1)); - } - - @Test - public void getDictionaryItemEmpty() throws Exception { - List> result = client.arrays().getDictionaryItemEmpty(); - Assert.assertEquals(3, result.size()); - Assert.assertEquals(0, result.get(1).size()); - } - - @Test - public void getDictionaryValid() throws Exception { - List> result = client.arrays().getDictionaryValid(); - Assert.assertEquals("seven", result.get(2).get("7")); - Assert.assertEquals("five", result.get(1).get("5")); - Assert.assertEquals("three", result.get(0).get("3")); - } - - @Test - public void putDictionaryValid() throws Exception { - List> body = new ArrayList>(); - Map m1 = new HashMap(); - m1.put("1", "one"); - m1.put("2", "two"); - m1.put("3", "three"); - body.add(m1); - Map m2 = new HashMap(); - m2.put("4", "four"); - m2.put("5", "five"); - m2.put("6", "six"); - body.add(m2); - Map m3 = new HashMap(); - m3.put("7", "seven"); - m3.put("8", "eight"); - m3.put("9", "nine"); - body.add(m3); - client.arrays().putDictionaryValid(body); - } -} +package fixtures.bodyarray; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.LocalDate; +import org.joda.time.Period; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import fixtures.bodyarray.implementation.AutoRestSwaggerBATArrayServiceImpl; +import fixtures.bodyarray.models.ErrorException; +import fixtures.bodyarray.models.Product; + +public class ArrayTests { + private static AutoRestSwaggerBATArrayService client; + + @BeforeClass + public static void setup() throws Exception { + client = new AutoRestSwaggerBATArrayServiceImpl("http://localhost:3000"); + } + + @Test + public void getNull() throws Exception { + Assert.assertNull(client.arrays().getNull()); + } + + @Test + public void getInvalid() throws Exception { + try { + List result = client.arrays().getInvalid(); + Assert.assertTrue(false); + } catch (RuntimeException exception) { + // expected + Assert.assertTrue(exception.getMessage().contains("Unexpected end-of-input")); + } + } + + @Test + public void getEmpty() throws Exception { + List result = client.arrays().getEmpty(); + Assert.assertEquals(0, result.size()); + } + + @Test + public void putEmpty() throws Exception { + client.arrays().putEmpty(new ArrayList()); + } + + @Test + public void getBooleanTfft() throws Exception { + List result = client.arrays().getBooleanTfft(); + Object[] exected = new Boolean[] {true, false, false, true}; + Assert.assertArrayEquals(exected, result.toArray()); + } + + @Test + public void putBooleanTfft() throws Exception { + client.arrays().putBooleanTfft(Arrays.asList(true, false, false, true)); + } + + @Test + public void getBooleanInvalidNull() throws Exception { + try { + List result = client.arrays().getBooleanInvalidNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getBooleanInvalidString() throws Exception { + try { + List result = client.arrays().getBooleanInvalidString(); + } catch (RuntimeException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("only \"true\" or \"false\" recognized")); + } + } + + @Test + public void getIntegerValid() throws Exception { + List result = client.arrays().getIntegerValid(); + Object[] expected = new Integer[] {1, -1, 3, 300}; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putIntegerValid() throws Exception { + client.arrays().putIntegerValid(Arrays.asList(1, -1, 3, 300)); + } + + @Test + public void getIntInvalidNull() throws Exception { + try { + List result = client.arrays().getIntInvalidNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getIntInvalidString() throws Exception { + try { + List result = client.arrays().getIntInvalidString(); + } catch (RuntimeException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("not a valid Integer value")); + } + } + + @Test + public void getLongValid() throws Exception { + List result = client.arrays().getLongValid(); + Object[] expected = new Long[] {1L, -1L, 3L, 300L}; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putLongValid() throws Exception { + client.arrays().putLongValid(Arrays.asList(1L, -1L, 3L, 300L)); + } + + @Test + public void getLongInvalidNull() throws Exception { + try { + List result = client.arrays().getLongInvalidNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getLongInvalidString() throws Exception { + try { + List result = client.arrays().getLongInvalidString(); + } catch (RuntimeException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("not a valid Long value")); + } + } + + @Test + public void getFloatValid() throws Exception { + List result = client.arrays().getFloatValid(); + Object[] expected = new Double[] {0d, -0.01, -1.2e20}; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putFloatValid() throws Exception { + client.arrays().putFloatValid(Arrays.asList(0d, -0.01d, -1.2e20d)); + } + + @Test + public void getFloatInvalidNull() throws Exception { + try { + List result = client.arrays().getFloatInvalidNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getFloatInvalidString() throws Exception { + try { + List result = client.arrays().getFloatInvalidString(); + } catch (RuntimeException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("not a valid Double value")); + } + } + + @Test + public void getDoubleValid() throws Exception { + List result = client.arrays().getDoubleValid(); + Object[] expected = new Double[] {0d, -0.01, -1.2e20}; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putDoubleValid() throws Exception { + client.arrays().putDoubleValid(Arrays.asList(0d, -0.01d, -1.2e20d)); + } + + @Test + public void getDoubleInvalidNull() throws Exception { + try { + List result = client.arrays().getDoubleInvalidNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getDoubleInvalidString() throws Exception { + try { + List result = client.arrays().getDoubleInvalidString(); + } catch (RuntimeException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("not a valid Double value")); + } + } + + @Test + public void getStringValid() throws Exception { + List result = client.arrays().getStringValid(); + Object[] expected = new String[] {"foo1", "foo2", "foo3"}; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putStringValid() throws Exception { + client.arrays().putStringValid(Arrays.asList("foo1", "foo2", "foo3")); + } + + @Test + public void getStringWithNull() throws Exception { + try { + List result = client.arrays().getStringWithNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getStringWithInvalid() throws Exception { + try { + List result = client.arrays().getStringWithInvalid(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("InvalidFormatException")); + } + } + + @Test + public void getUuidValid() throws Exception { + List result = client.arrays().getUuidValid(); + Object[] expected = new UUID[] {UUID.fromString("6dcc7237-45fe-45c4-8a6b-3a8a3f625652"), + UUID.fromString("d1399005-30f7-40d6-8da6-dd7c89ad34db"), + UUID.fromString("f42f6aa1-a5bc-4ddf-907e-5f915de43205")}; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putUuidValid() throws Exception { + client.arrays().putUuidValid(Arrays.asList(UUID.fromString("6dcc7237-45fe-45c4-8a6b-3a8a3f625652"), + UUID.fromString("d1399005-30f7-40d6-8da6-dd7c89ad34db"), UUID.fromString("f42f6aa1-a5bc-4ddf-907e-5f915de43205"))); + } + + @Test + public void getUuidInvalidChars() throws Exception { + try { + List result = client.arrays().getUuidInvalidChars(); + Assert.fail(); + } catch (RuntimeException ex) { + // expected + Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("UUID has to be represented")); + } + } + @Test + public void getDateValid() throws Exception { + List result = client.arrays().getDateValid(); + Object[] expected = new LocalDate[] { + new LocalDate(2000, 12, 1), + new LocalDate(1980, 1, 2), + new LocalDate(1492, 10, 12) + }; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putDateValid() throws Exception { + client.arrays().putDateValid(Arrays.asList( + new LocalDate(2000, 12, 1), + new LocalDate(1980, 1, 2), + new LocalDate(1492, 10, 12) + )); + } + + @Test + public void getDateInvalidNull() throws Exception { + try { + List result = client.arrays().getDateInvalidNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getDateInvalidString() throws Exception { + try { + List result = client.arrays().getDateInvalidChars(); + } catch (RuntimeException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("Invalid format: \"date\"")); + } + } + + @Test + public void getDateTimeValid() throws Exception { + List result = client.arrays().getDateTimeValid(); + Object[] expected = new DateTime[] { + new DateTime(2000, 12, 1, 0, 0, 1, DateTimeZone.UTC), + new DateTime(1980, 1, 2, 0, 11, 35, DateTimeZone.UTC), + new DateTime(1492, 10, 12, 10, 15, 1, DateTimeZone.UTC) + }; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putDateTimeValid() throws Exception { + client.arrays().putDateTimeValid(Arrays.asList( + new DateTime(2000, 12, 1, 0, 0, 1, DateTimeZone.UTC), + new DateTime(1980, 1, 2, 0, 11, 35, DateTimeZone.UTC), + new DateTime(1492, 10, 12, 10, 15, 1, DateTimeZone.UTC) + )); + } + + @Test + public void getDateTimeInvalidNull() throws Exception { + try { + List result = client.arrays().getDateTimeInvalidNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getDateTimeInvalidString() throws Exception { + try { + List result = client.arrays().getDateTimeInvalidChars(); + } catch (RuntimeException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("Invalid format: \"date-time\"")); + } + } + + @Test + public void getDateTimeRfc1123Valid() throws Exception { + List result = client.arrays().getDateTimeRfc1123Valid(); + Object[] expected = new DateTime[] { + new DateTime(2000, 12, 1, 0, 0, 1, DateTimeZone.UTC), + new DateTime(1980, 1, 2, 0, 11, 35, DateTimeZone.UTC), + new DateTime(1492, 10, 12, 10, 15, 1, DateTimeZone.UTC) + }; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putDateTimeRfc1123Valid() throws Exception { + client.arrays().putDateTimeRfc1123Valid(Arrays.asList( + new DateTime(2000, 12, 1, 0, 0, 1, DateTimeZone.UTC), + new DateTime(1980, 1, 2, 0, 11, 35, DateTimeZone.UTC), + new DateTime(1492, 10, 12, 10, 15, 1, DateTimeZone.UTC) + )); + } + + @Test + public void getDurationValid() throws Exception { + List result = client.arrays().getDurationValid(); + Object[] expected = new Period[] { + new Period(0, 0, 0, 123, 22, 14, 12, 11), + new Period(0, 0, 0, 5, 1, 0, 0, 0) + }; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putDurationValid() throws Exception { + client.arrays().putDurationValid(Arrays.asList( + new Period(0, 0, 0, 123, 22, 14, 12, 11), + new Period(0, 0, 0, 5, 1, 0, 0, 0))); + } + + @Test + public void getByteValid() throws Exception { + List result = client.arrays().getByteValid(); + Object[] expected = new byte[][] { + new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFA}, + new byte[] {(byte) 0x01, (byte) 0x02, (byte) 0x03}, + new byte[] {(byte) 0x25, (byte) 0x29, (byte) 0x43} + }; + Assert.assertArrayEquals(expected, result.toArray()); + } + + @Test + public void putByteValid() throws Exception { + client.arrays().putByteValid(Arrays.asList( + new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFA}, + new byte[] {(byte) 0x01, (byte) 0x02, (byte) 0x03}, + new byte[] {(byte) 0x25, (byte) 0x29, (byte) 0x43} + )); + } + + @Test + public void getByteInvalidNull() throws Exception { + try { + List result = client.arrays().getByteInvalidNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getBase64Url() throws Exception { + List result = client.arrays().getBase64Url(); + Assert.assertEquals(3, result.size()); + Assert.assertEquals("a string that gets encoded with base64url", new String(result.get(0))); + Assert.assertEquals("test string", new String(result.get(1))); + Assert.assertEquals("Lorem ipsum", new String(result.get(2))); + } + + @Test + public void getComplexNull() throws Exception { + try { + List result = client.arrays().getComplexNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getComplexEmpty() throws Exception { + List result = client.arrays().getComplexEmpty(); + Assert.assertEquals(0, result.size()); + } + + @Test + public void getComplexItemNull() throws Exception { + List result = client.arrays().getComplexItemNull(); + Assert.assertEquals(3, result.size()); + Assert.assertNull(result.get(1)); + } + + @Test + public void getComplexItemEmpty() throws Exception { + List result = client.arrays().getComplexItemEmpty(); + Assert.assertEquals(3, result.size()); + Assert.assertNull(result.get(1).stringProperty()); + } + + @Test + public void getComplexValid() throws Exception { + List result = client.arrays().getComplexValid(); + Assert.assertEquals(3, result.size()); + Assert.assertEquals(5, result.get(2).integer().intValue()); + Assert.assertEquals("6", result.get(2).stringProperty()); + } + + @Test + public void putComplexValid() throws Exception { + List body = new ArrayList(); + Product p1 = new Product(); + p1.withInteger(1); + p1.withStringProperty("2"); + body.add(p1); + Product p2 = new Product(); + p2.withInteger(3); + p2.withStringProperty("4"); + body.add(p2); + Product p3 = new Product(); + p3.withInteger(5); + p3.withStringProperty("6"); + body.add(p3); + client.arrays().putComplexValid(body); + } + + @Test + public void getArrayNull() throws Exception { + try { + List> result = client.arrays().getArrayNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getArrayEmpty() throws Exception { + List> result = client.arrays().getArrayEmpty(); + Assert.assertEquals(0, result.size()); + } + + @Test + public void getArrayItemNull() throws Exception { + List> result = client.arrays().getArrayItemNull(); + Assert.assertEquals(3, result.size()); + Assert.assertNull(result.get(1)); + } + + @Test + public void getArrayItemEmpty() throws Exception { + List> result = client.arrays().getArrayItemEmpty(); + Assert.assertEquals(3, result.size()); + Assert.assertEquals(0, result.get(1).size()); + } + + @Test + public void getArrayValid() throws Exception { + List> result = client.arrays().getArrayValid(); + Assert.assertArrayEquals(new String[]{"1", "2", "3"}, result.get(0).toArray()); + Assert.assertArrayEquals(new String[]{"4", "5", "6"}, result.get(1).toArray()); + Assert.assertArrayEquals(new String[] {"7", "8", "9"}, result.get(2).toArray()); + } + + @Test + public void putArrayValid() throws Exception { + List> body = new ArrayList>(); + body.add(Arrays.asList("1", "2", "3")); + body.add(Arrays.asList("4", "5", "6")); + body.add(Arrays.asList("7", "8", "9")); + client.arrays().putArrayValid(body); + } + + @Test + public void getDictionaryNull() throws Exception { + try { + List> result = client.arrays().getDictionaryNull(); + } catch (ErrorException ex) { + // expected + Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); + } + } + + @Test + public void getDictionaryEmpty() throws Exception { + List> result = client.arrays().getDictionaryEmpty(); + Assert.assertEquals(0, result.size()); + } + + @Test + public void getDictionaryItemNull() throws Exception { + List> result = client.arrays().getDictionaryItemNull(); + Assert.assertEquals(3, result.size()); + Assert.assertNull(result.get(1)); + } + + @Test + public void getDictionaryItemEmpty() throws Exception { + List> result = client.arrays().getDictionaryItemEmpty(); + Assert.assertEquals(3, result.size()); + Assert.assertEquals(0, result.get(1).size()); + } + + @Test + public void getDictionaryValid() throws Exception { + List> result = client.arrays().getDictionaryValid(); + Assert.assertEquals("seven", result.get(2).get("7")); + Assert.assertEquals("five", result.get(1).get("5")); + Assert.assertEquals("three", result.get(0).get("3")); + } + + @Test + public void putDictionaryValid() throws Exception { + List> body = new ArrayList>(); + Map m1 = new HashMap(); + m1.put("1", "one"); + m1.put("2", "two"); + m1.put("3", "three"); + body.add(m1); + Map m2 = new HashMap(); + m2.put("4", "four"); + m2.put("5", "five"); + m2.put("6", "six"); + body.add(m2); + Map m3 = new HashMap(); + m3.put("7", "seven"); + m3.put("8", "eight"); + m3.put("9", "nine"); + body.add(m3); + client.arrays().putDictionaryValid(body); + } +} diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodycomplex/BasicOperationsTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodycomplex/BasicOperationsTests.java index e99b0e57a5..0963f08fc5 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodycomplex/BasicOperationsTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodycomplex/BasicOperationsTests.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.exc.InvalidFormatException; +import com.microsoft.rest.LogLevel; import fixtures.bodycomplex.implementation.AutoRestComplexTestServiceImpl; import fixtures.bodycomplex.models.Basic; import fixtures.bodycomplex.models.CMYKColors; @@ -18,10 +19,9 @@ public class BasicOperationsTests { @BeforeClass public static void setup() { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder() - .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)); - client = new AutoRestComplexTestServiceImpl("http://localhost:3000", clientBuilder, new Retrofit.Builder()); + client = new AutoRestComplexTestServiceImpl("http://localhost:3000"); client.withApiVersion("2015-05-01"); + client.restClient().withLogLevel(LogLevel.BODY); } @Test diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodystring/StringOperationsTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodystring/StringOperationsTests.java index c26238c2cd..49a7edd6f2 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodystring/StringOperationsTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/bodystring/StringOperationsTests.java @@ -1,8 +1,8 @@ package fixtures.bodystring; +import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceException; - +import fixtures.bodystring.implementation.AutoRestSwaggerBATServiceImpl; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -10,8 +10,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import fixtures.bodystring.implementation.AutoRestSwaggerBATServiceImpl; - public class StringOperationsTests { private static AutoRestSwaggerBATService client; private CountDownLatch lock = new CountDownLatch(1); @@ -86,7 +84,7 @@ public void getNotProvided() throws Exception { try { client.strings().getNotProvided(); } catch (Exception ex) { - Assert.assertEquals(ServiceException.class, ex.getClass()); + Assert.assertEquals(RestException.class, ex.getClass()); Assert.assertTrue(ex.getMessage().contains("JsonMappingException")); } } diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/header/HeaderOperationsTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/header/HeaderOperationsTests.java index 2156b1485a..b3c38f2ac9 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/header/HeaderOperationsTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/header/HeaderOperationsTests.java @@ -17,7 +17,6 @@ import java.util.concurrent.TimeUnit; import fixtures.header.implementation.AutoRestSwaggerBATHeaderServiceImpl; -import fixtures.header.models.ErrorException; import fixtures.header.models.GreyscaleColors; import fixtures.header.models.HeaderResponseBoolHeaders; import fixtures.header.models.HeaderResponseByteHeaders; @@ -59,7 +58,7 @@ public void responseExistingKey() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("User-Agent") != null) { Assert.assertEquals("overwrite", headers.get("User-Agent")); lock.countDown(); @@ -78,7 +77,7 @@ public void call(Throwable throwable) { public void paramProtectedKey() throws Exception { try { client.headers().paramProtectedKey("text/html"); - } catch (ErrorException ex) { + } catch (RuntimeException ex) { // OkHttp can actually overwrite header "Content-Type" } } @@ -90,7 +89,7 @@ public void responseProtectedKey() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("Content-Type") != null) { Assert.assertTrue(headers.get("Content-Type").contains("text/html")); lock.countDown(); @@ -118,7 +117,7 @@ public void responseInteger() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("1", headers.get("value")); lock.countDown(); @@ -136,7 +135,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("-2", headers.get("value")); lock.countDown(); @@ -164,7 +163,7 @@ public void responseLong() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("105", headers.get("value")); lock.countDown(); @@ -182,7 +181,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("-2", headers.get("value")); lock.countDown(); @@ -210,7 +209,7 @@ public void responseFloat() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("0.07", headers.get("value")); lock.countDown(); @@ -228,7 +227,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("-3", headers.get("value")); lock.countDown(); @@ -256,7 +255,7 @@ public void responseDouble() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("7e+120", headers.get("value")); lock.countDown(); @@ -274,7 +273,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("-3", headers.get("value")); lock.countDown(); @@ -302,7 +301,7 @@ public void responseBool() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("true", headers.get("value")); lock.countDown(); @@ -320,7 +319,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("false", headers.get("value")); lock.countDown(); @@ -349,7 +348,7 @@ public void responseString() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("The quick brown fox jumps over the lazy dog", headers.get("value")); lock.countDown(); @@ -367,7 +366,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("null", headers.get("value")); lock.countDown(); @@ -385,7 +384,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("", headers.get("value")); lock.countDown(); @@ -413,7 +412,7 @@ public void responseDate() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("2010-01-01", headers.get("value")); lock.countDown(); @@ -431,7 +430,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("0001-01-01", headers.get("value")); lock.countDown(); @@ -458,7 +457,7 @@ public void responseDuration() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("P123DT22H14M12.011S", headers.get("value")); lock.countDown(); @@ -486,7 +485,7 @@ public void responseDatetimeRfc1123() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("Fri, 01 Jan 2010 12:34:56 GMT", headers.get("value")); lock.countDown(); @@ -504,7 +503,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("Mon, 01 Jan 0001 00:00:00 GMT", headers.get("value")); lock.countDown(); @@ -533,7 +532,7 @@ public void responseDatetime() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("2010-01-01T12:34:56Z", headers.get("value")); lock.countDown(); @@ -551,7 +550,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("0001-01-01T00:00:00Z", headers.get("value")); lock.countDown(); @@ -578,7 +577,7 @@ public void responseByte() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { byte[] value = Base64.decodeBase64(headers.get("value")); String actual = new String(value, Charset.forName("UTF-8")); @@ -608,7 +607,7 @@ public void responseEnum() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("GREY", headers.get("value")); lock.countDown(); @@ -626,7 +625,7 @@ public void call(Throwable throwable) { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Headers headers = response.getResponse().headers(); + Headers headers = response.response().headers(); if (headers.get("value") != null) { Assert.assertEquals("", headers.get("value")); lock.countDown(); diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpClientFailureTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpClientFailureTests.java index f653e795b3..bf47283b48 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpClientFailureTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpClientFailureTests.java @@ -1,12 +1,11 @@ package fixtures.http; +import fixtures.http.implementation.AutoRestHttpInfrastructureTestServiceImpl; +import fixtures.http.models.ErrorException; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import fixtures.http.implementation.AutoRestHttpInfrastructureTestServiceImpl; -import fixtures.http.models.ErrorException; - import static org.junit.Assert.fail; public class HttpClientFailureTests { @@ -23,7 +22,7 @@ public void head400() throws Exception { client.httpClientFailures().head400(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -33,7 +32,7 @@ public void get400() throws Exception { client.httpClientFailures().get400(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -43,7 +42,7 @@ public void put400() throws Exception { client.httpClientFailures().put400(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -53,7 +52,7 @@ public void patch400() throws Exception { client.httpClientFailures().patch400(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -63,7 +62,7 @@ public void post400() throws Exception { client.httpClientFailures().post400(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -73,7 +72,7 @@ public void delete400() throws Exception { client.httpClientFailures().delete400(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -83,7 +82,7 @@ public void head401() throws Exception { client.httpClientFailures().head401(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(401, ex.getResponse().code()); + Assert.assertEquals(401, ex.response().code()); } } @@ -93,7 +92,7 @@ public void get402() throws Exception { client.httpClientFailures().get402(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(402, ex.getResponse().code()); + Assert.assertEquals(402, ex.response().code()); } } @@ -103,7 +102,7 @@ public void get403() throws Exception { client.httpClientFailures().get403(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(403, ex.getResponse().code()); + Assert.assertEquals(403, ex.response().code()); } } @@ -113,7 +112,7 @@ public void put404() throws Exception { client.httpClientFailures().put404(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(404, ex.getResponse().code()); + Assert.assertEquals(404, ex.response().code()); } } @@ -123,7 +122,7 @@ public void patch405() throws Exception { client.httpClientFailures().patch405(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(405, ex.getResponse().code()); + Assert.assertEquals(405, ex.response().code()); } } @@ -133,7 +132,7 @@ public void post406() throws Exception { client.httpClientFailures().post406(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(406, ex.getResponse().code()); + Assert.assertEquals(406, ex.response().code()); } } @@ -153,7 +152,7 @@ public void put409() throws Exception { client.httpClientFailures().put409(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(409, ex.getResponse().code()); + Assert.assertEquals(409, ex.response().code()); } } @@ -163,7 +162,7 @@ public void head410() throws Exception { client.httpClientFailures().head410(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(410, ex.getResponse().code()); + Assert.assertEquals(410, ex.response().code()); } } @@ -173,7 +172,7 @@ public void get411() throws Exception { client.httpClientFailures().get411(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(411, ex.getResponse().code()); + Assert.assertEquals(411, ex.response().code()); } } @@ -183,7 +182,7 @@ public void get412() throws Exception { client.httpClientFailures().get412(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(412, ex.getResponse().code()); + Assert.assertEquals(412, ex.response().code()); } } @@ -193,7 +192,7 @@ public void put413() throws Exception { client.httpClientFailures().put413(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(413, ex.getResponse().code()); + Assert.assertEquals(413, ex.response().code()); } } @@ -203,7 +202,7 @@ public void patch414() throws Exception { client.httpClientFailures().patch414(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(414, ex.getResponse().code()); + Assert.assertEquals(414, ex.response().code()); } } @@ -213,7 +212,7 @@ public void post415() throws Exception { client.httpClientFailures().post415(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(415, ex.getResponse().code()); + Assert.assertEquals(415, ex.response().code()); } } @@ -223,7 +222,7 @@ public void get416() throws Exception { client.httpClientFailures().get416(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(416, ex.getResponse().code()); + Assert.assertEquals(416, ex.response().code()); } } @@ -233,7 +232,7 @@ public void delete417() throws Exception { client.httpClientFailures().delete417(true); fail(); } catch (ErrorException ex) { - Assert.assertEquals(417, ex.getResponse().code()); + Assert.assertEquals(417, ex.response().code()); } } @@ -243,7 +242,7 @@ public void head429() throws Exception { client.httpClientFailures().head429(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(429, ex.getResponse().code()); + Assert.assertEquals(429, ex.response().code()); } } } diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpFailureTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpFailureTests.java index dbb2a3144a..6ab9d11ba7 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpFailureTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpFailureTests.java @@ -1,7 +1,6 @@ package fixtures.http; -import com.microsoft.rest.ServiceException; - +import com.microsoft.rest.RestException; import fixtures.http.implementation.AutoRestHttpInfrastructureTestServiceImpl; import fixtures.http.models.ErrorException; import org.junit.Assert; @@ -24,7 +23,7 @@ public void getEmptyError() throws Exception { client.httpFailures().getEmptyError(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -33,8 +32,8 @@ public void getNoModelError() throws Exception { try { client.httpFailures().getNoModelError(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + } catch (RestException ex) { + Assert.assertEquals(400, ex.response().code()); //Assert.assertTrue(ex.getResponse().raw().toString().contains("NoErrorModel")); } } diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpRedirectsTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpRedirectsTests.java index 3f8a9de2e6..00c3978988 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpRedirectsTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpRedirectsTests.java @@ -44,7 +44,7 @@ public void head300() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(200, response.getHeadResponse().code()); + Assert.assertEquals(200, response.headResponse().code()); lock.countDown(); } }); @@ -57,7 +57,7 @@ public void get300() throws Exception { .subscribe(new Action1, HttpRedirectsGet300Headers>>() { @Override public void call(ServiceResponseWithHeaders, HttpRedirectsGet300Headers> response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -70,7 +70,7 @@ public void head301() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(200, response.getHeadResponse().code()); + Assert.assertEquals(200, response.headResponse().code()); lock.countDown(); } }); @@ -83,7 +83,7 @@ public void get301() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -97,7 +97,7 @@ public void put301() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(301, response.getResponse().code()); + Assert.assertEquals(301, response.response().code()); lock.countDown(); } }); @@ -110,7 +110,7 @@ public void head302() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(200, response.getHeadResponse().code()); + Assert.assertEquals(200, response.headResponse().code()); lock.countDown(); } }); @@ -123,7 +123,7 @@ public void get302() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -137,7 +137,7 @@ public void patch302() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(302, response.getResponse().code()); + Assert.assertEquals(302, response.response().code()); lock.countDown(); } }); @@ -150,7 +150,7 @@ public void post303() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -163,7 +163,7 @@ public void head307() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(200, response.getHeadResponse().code()); + Assert.assertEquals(200, response.headResponse().code()); lock.countDown(); } }); @@ -176,7 +176,7 @@ public void get307() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -189,7 +189,7 @@ public void put307() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(307, response.getResponse().code()); + Assert.assertEquals(307, response.response().code()); lock.countDown(); } }); @@ -202,7 +202,7 @@ public void patch307() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(307, response.getResponse().code()); + Assert.assertEquals(307, response.response().code()); lock.countDown(); } }); @@ -215,7 +215,7 @@ public void post307() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(307, response.getResponse().code()); + Assert.assertEquals(307, response.response().code()); lock.countDown(); } }); @@ -228,7 +228,7 @@ public void delete307() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponseWithHeaders response) { - Assert.assertEquals(307, response.getResponse().code()); + Assert.assertEquals(307, response.response().code()); lock.countDown(); } }); diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpRetryTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpRetryTests.java index 2583d52518..194787b1a8 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpRetryTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpRetryTests.java @@ -27,7 +27,7 @@ public void head408() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(200, response.getHeadResponse().code()); + Assert.assertEquals(200, response.headResponse().code()); lock.countDown(); } }); @@ -40,7 +40,7 @@ public void put500() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -53,7 +53,7 @@ public void patch500() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -66,7 +66,7 @@ public void get502() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -79,7 +79,7 @@ public void post503() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -92,7 +92,7 @@ public void delete503() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -105,7 +105,7 @@ public void put504() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); @@ -118,7 +118,7 @@ public void patch504() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(200, response.getResponse().code()); + Assert.assertEquals(200, response.response().code()); lock.countDown(); } }); diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpServerFailureTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpServerFailureTests.java index 98729208fe..2ed2fb4e0d 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpServerFailureTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/HttpServerFailureTests.java @@ -19,7 +19,7 @@ public void head501() throws Exception { try { client.httpServerFailures().head501(); } catch (ErrorException ex) { - Assert.assertEquals(501, ex.getResponse().code()); + Assert.assertEquals(501, ex.response().code()); } } @@ -28,7 +28,7 @@ public void get501() throws Exception { try { client.httpServerFailures().get501(); } catch (ErrorException ex) { - Assert.assertEquals(501, ex.getResponse().code()); + Assert.assertEquals(501, ex.response().code()); } } @@ -37,7 +37,7 @@ public void post505() throws Exception { try { client.httpServerFailures().post505(true); } catch (ErrorException ex) { - Assert.assertEquals(505, ex.getResponse().code()); + Assert.assertEquals(505, ex.response().code()); } } @@ -46,7 +46,7 @@ public void delete505() throws Exception { try { client.httpServerFailures().delete505(true); } catch (ErrorException ex) { - Assert.assertEquals(505, ex.getResponse().code()); + Assert.assertEquals(505, ex.response().code()); } } } diff --git a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/MultipleResponsesTests.java b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/MultipleResponsesTests.java index 5976e2bd7f..880b94f8cf 100644 --- a/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/MultipleResponsesTests.java +++ b/src/generator/AutoRest.Java.Tests/src/test/java/fixtures/http/MultipleResponsesTests.java @@ -1,15 +1,7 @@ package fixtures.http; -import com.microsoft.rest.ServiceException; +import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceResponse; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import fixtures.http.implementation.AutoRestHttpInfrastructureTestServiceImpl; import fixtures.http.models.A; import fixtures.http.models.C; @@ -17,8 +9,14 @@ import fixtures.http.models.Error; import fixtures.http.models.ErrorException; import fixtures.http.models.MyException; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; import rx.functions.Action1; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import static org.junit.Assert.fail; public class MultipleResponsesTests { @@ -49,7 +47,7 @@ public void get200Model204NoModelDefaultError201Invalid() throws Exception { client.multipleResponses().get200Model204NoModelDefaultError201Invalid(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(201, ex.getResponse().code()); + Assert.assertEquals(201, ex.response().code()); } } @@ -58,7 +56,7 @@ public void get200Model204NoModelDefaultError202None() throws Exception { try { A result = client.multipleResponses().get200Model204NoModelDefaultError202None(); } catch (ErrorException ex) { - Assert.assertEquals(202, ex.getResponse().code()); + Assert.assertEquals(202, ex.response().code()); } } @@ -68,7 +66,7 @@ public void get200Model204NoModelDefaultError400Valid() throws Exception { client.multipleResponses().get200Model204NoModelDefaultError400Valid(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -90,9 +88,9 @@ public void get200Model201ModelDefaultError400Valid() throws Exception { client.multipleResponses().get200Model201ModelDefaultError400Valid(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); - Assert.assertEquals(400, ex.getBody().status().intValue()); - Assert.assertEquals("client error", ex.getBody().message()); + Assert.assertEquals(400, ex.response().code()); + Assert.assertEquals(400, ex.body().status().intValue()); + Assert.assertEquals("client error", ex.body().message()); } } @@ -123,8 +121,8 @@ public void get200ModelA201ModelC404ModelDDefaultError400Valid() throws Exceptio client.multipleResponses().get200ModelA201ModelC404ModelDDefaultError400Valid(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); - Error model = ex.getBody(); + Assert.assertEquals(400, ex.response().code()); + Error model = ex.body(); Assert.assertEquals(400, model.status().intValue()); Assert.assertEquals("client error", model.message()); } @@ -136,7 +134,7 @@ public void get202None204NoneDefaultError202None() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(202, response.getResponse().code()); + Assert.assertEquals(202, response.response().code()); lock.countDown(); } }); @@ -149,7 +147,7 @@ public void get202None204NoneDefaultError204None() throws Exception { .subscribe(new Action1>() { @Override public void call(ServiceResponse response) { - Assert.assertEquals(204, response.getResponse().code()); + Assert.assertEquals(204, response.response().code()); lock.countDown(); } }); @@ -162,8 +160,8 @@ public void get202None204NoneDefaultError400Valid() throws Exception { client.multipleResponses().get202None204NoneDefaultError400Valid(); fail(); } catch (ErrorException ex) { - Assert.assertEquals(400, ex.getResponse().code()); - Error model = ex.getBody(); + Assert.assertEquals(400, ex.response().code()); + Error model = ex.body(); Assert.assertEquals(400, model.status().intValue()); Assert.assertEquals("client error", model.message()); } @@ -184,8 +182,8 @@ public void get202None204NoneDefaultNone400None() throws Exception { try { client.multipleResponses().get202None204NoneDefaultNone400None(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + } catch (RestException ex) { + Assert.assertEquals(400, ex.response().code()); } } @@ -194,8 +192,8 @@ public void get202None204NoneDefaultNone400Invalid() throws Exception { try { client.multipleResponses().get202None204NoneDefaultNone400Invalid(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + } catch (RestException ex) { + Assert.assertEquals(400, ex.response().code()); } } @@ -217,8 +215,8 @@ public void getDefaultModelA400Valid() throws Exception { client.multipleResponses().getDefaultModelA400Valid(); fail(); } catch (MyException ex) { - Assert.assertEquals(400, ex.getResponse().code()); - Assert.assertEquals("400", ex.getBody().statusCode()); + Assert.assertEquals(400, ex.response().code()); + Assert.assertEquals("400", ex.body().statusCode()); } } @@ -228,7 +226,7 @@ public void getDefaultModelA400None() throws Exception { client.multipleResponses().getDefaultModelA400None(); fail(); } catch (MyException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + Assert.assertEquals(400, ex.response().code()); } } @@ -247,8 +245,8 @@ public void getDefaultNone400Invalid() throws Exception { try { client.multipleResponses().getDefaultNone400Invalid(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + } catch (RestException ex) { + Assert.assertEquals(400, ex.response().code()); } } @@ -257,8 +255,8 @@ public void getDefaultNone400None() throws Exception { try { client.multipleResponses().getDefaultNone400None(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + } catch (RestException ex) { + Assert.assertEquals(400, ex.response().code()); } } @@ -284,9 +282,9 @@ public void get200ModelA400None() throws Exception { try { client.multipleResponses().get200ModelA400None(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(400, ex.getResponse().code()); - Assert.assertNull(ex.getBody()); + } catch (RestException ex) { + Assert.assertEquals(400, ex.response().code()); + Assert.assertNull(ex.body()); } } @@ -295,8 +293,8 @@ public void get200ModelA400Valid() throws Exception { try { client.multipleResponses().get200ModelA400Valid(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + } catch (RestException ex) { + Assert.assertEquals(400, ex.response().code()); } } @@ -305,8 +303,8 @@ public void get200ModelA400Invalid() throws Exception { try { client.multipleResponses().get200ModelA400Invalid(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(400, ex.getResponse().code()); + } catch (RestException ex) { + Assert.assertEquals(400, ex.response().code()); } } @@ -315,8 +313,8 @@ public void get200ModelA202Valid() throws Exception { try { client.multipleResponses().get200ModelA202Valid(); fail(); - } catch (ServiceException ex) { - Assert.assertEquals(202, ex.getResponse().code()); + } catch (RestException ex) { + Assert.assertEquals(202, ex.response().code()); } } } diff --git a/src/generator/AutoRest.Java/CodeGeneratorJv.cs b/src/generator/AutoRest.Java/CodeGeneratorJv.cs index de0a5ff2de..914fe2bcdf 100644 --- a/src/generator/AutoRest.Java/CodeGeneratorJv.cs +++ b/src/generator/AutoRest.Java/CodeGeneratorJv.cs @@ -18,7 +18,7 @@ namespace AutoRest.Java { public class CodeGeneratorJv : CodeGenerator { - private const string ClientRuntimePackage = "com.microsoft.rest:client-runtime:1.0.0-beta5-SNAPSHOT from snapshot repo https://oss.sonatype.org/content/repositories/snapshots/"; + private const string ClientRuntimePackage = "com.microsoft.rest:client-runtime:1.0.0-beta6-SNAPSHOT from snapshot repo https://oss.sonatype.org/content/repositories/snapshots/"; private const string _packageInfoFileName = "package-info.java"; public CodeNamerJv Namer { get; private set; } diff --git a/src/generator/AutoRest.Python.Azure/Model/CodeModelPya.cs b/src/generator/AutoRest.Python.Azure/Model/CodeModelPya.cs index 04b0f538f6..401a6ab469 100644 --- a/src/generator/AutoRest.Python.Azure/Model/CodeModelPya.cs +++ b/src/generator/AutoRest.Python.Azure/Model/CodeModelPya.cs @@ -42,6 +42,10 @@ public override string RequiredConstructorParameters var optionalParams = new List(); foreach (var property in Properties) { + if (property.IsConstant) + { + continue; + } if (property.IsRequired) { requireParams.Add(property.Name.ToPythonCase()); diff --git a/src/generator/AutoRest.Python.Tests/AcceptanceTests/validation_tests.py b/src/generator/AutoRest.Python.Tests/AcceptanceTests/validation_tests.py index cf210616d7..fb333e4b7c 100644 --- a/src/generator/AutoRest.Python.Tests/AcceptanceTests/validation_tests.py +++ b/src/generator/AutoRest.Python.Tests/AcceptanceTests/validation_tests.py @@ -111,14 +111,14 @@ def test_validation(self): client.validation_of_body("123", 150, tempproduct) except ValidationError as err: self.assertEqual(err.rule, "minimum_ex") - self.assertEqual(err.target, "capacity") + self.assertIn("capacity", err.target) try: tempproduct=Product(child=ChildProduct(), capacity=100) client.validation_of_body("123", 150, tempproduct) except ValidationError as err: self.assertEqual(err.rule, "maximum_ex") - self.assertEqual(err.target, "capacity") + self.assertIn("capacity", err.target) try: tempproduct=Product(child=ChildProduct(), @@ -126,7 +126,7 @@ def test_validation(self): client.validation_of_body("123", 150, tempproduct) except ValidationError as err: self.assertEqual(err.rule, "max_items") - self.assertEqual(err.target, "display_names") + self.assertIn("display_names", err.target) client2 = AutoRestValidationTest( "abc123", diff --git a/src/generator/AutoRest.Python/Model/CodeModelPy.cs b/src/generator/AutoRest.Python/Model/CodeModelPy.cs index 7057e40e80..d4f729d0d7 100644 --- a/src/generator/AutoRest.Python/Model/CodeModelPy.cs +++ b/src/generator/AutoRest.Python/Model/CodeModelPy.cs @@ -74,6 +74,10 @@ public virtual string RequiredConstructorParameters var requireParams = new List(); foreach (var property in parameters) { + if (property.IsConstant) + { + continue; + } if (property.IsRequired) { requireParams.Add(property.Name); diff --git a/src/generator/AutoRest.Ruby.Azure.Tests/Gemfile b/src/generator/AutoRest.Ruby.Azure.Tests/Gemfile index 945b73e3b0..eb0ba50c86 100644 --- a/src/generator/AutoRest.Ruby.Azure.Tests/Gemfile +++ b/src/generator/AutoRest.Ruby.Azure.Tests/Gemfile @@ -2,6 +2,6 @@ source 'https://rubygems.org' group :development, :local, :test do gem 'rspec' - gem 'ms_rest', '~> 0.6.1' - gem 'ms_rest_azure', '~> 0.6.1' + gem 'ms_rest', '~> 0.6.3' + gem 'ms_rest_azure', '~> 0.7.0' end diff --git a/src/generator/AutoRest.Ruby.Azure.Tests/RspecTests/lro_spec.rb b/src/generator/AutoRest.Ruby.Azure.Tests/RspecTests/lro_spec.rb index 74884999fe..42687327e3 100644 --- a/src/generator/AutoRest.Ruby.Azure.Tests/RspecTests/lro_spec.rb +++ b/src/generator/AutoRest.Ruby.Azure.Tests/RspecTests/lro_spec.rb @@ -115,13 +115,13 @@ it 'should succeed for post async retry' do result = @lros_client.post_async_retry_succeeded_async(@product).value! - expect(result.body).to be_nil + expect(result.body).to be_instance_of(Product) expect(result.response.status).to eq(200) end it 'should succeed for post async no retry' do result = @lros_client.post_async_no_retry_succeeded_async(@product).value! - expect(result.body).to be_nil + expect(result.body).to be_instance_of(Product) expect(result.response.status).to eq(200) end diff --git a/src/generator/AutoRest.Ruby.Azure/CodeGeneratorRba.cs b/src/generator/AutoRest.Ruby.Azure/CodeGeneratorRba.cs index 82a8618a06..6e05b4a977 100644 --- a/src/generator/AutoRest.Ruby.Azure/CodeGeneratorRba.cs +++ b/src/generator/AutoRest.Ruby.Azure/CodeGeneratorRba.cs @@ -29,7 +29,7 @@ public CodeGeneratorRba() /// /// Gets the usage instructions for the code generator. /// - public override string UsageInstructions => @"The ""gem 'ms_rest_azure' ~> 0.6"" is required for working with generated code."; + public override string UsageInstructions => @"The ""gem 'ms_rest_azure' ~> 0.7"" is required for working with generated code."; /// /// Generates Ruby code for Azure service client. diff --git a/src/generator/AutoRest.Ruby.Tests/Gemfile b/src/generator/AutoRest.Ruby.Tests/Gemfile index 864e1d3fab..7ac6705170 100644 --- a/src/generator/AutoRest.Ruby.Tests/Gemfile +++ b/src/generator/AutoRest.Ruby.Tests/Gemfile @@ -3,5 +3,5 @@ source 'https://rubygems.org' group :development, :local, :test do gem 'rspec' gem 'faraday-cookie_jar', '~> 0.0.6' - gem 'ms_rest', '~> 0.6.1' + gem 'ms_rest', '~> 0.6.3' end diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/boolean-properties.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/boolean-properties.json new file mode 100644 index 0000000000..d480dd9fc5 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/boolean-properties.json @@ -0,0 +1,61 @@ +{ + "swagger": "2.0", + "info": { + "title": "Boolean properties not recommended in models", + "description": "Some documentation.", + "version": "2017-02-08" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/foo": { + "post": { + "operationId": "PostFoo", + "summary": "Foo path", + "description": "Foo operation", + "responses": { + "default": { + "description": "Unexpected error" + } + } + } + } + }, + "definitions": { + "Test1": { + "description": "Property for foo path 1", + "properties": { + "nameAvailable": { + "readOnly": true, + "type": "boolean", + "description": "Gets a boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already been taken or invalid and cannot be used." + } + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } + } +} \ No newline at end of file diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-delete.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-delete.json new file mode 100644 index 0000000000..51d9a67a69 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-delete.json @@ -0,0 +1,50 @@ +{ + "swagger": "2.0", + "info": { + "title": "LongRunningResponseForDeleteValidation", + "description": "The 200 or 204 response code is not modeled for a long running delete operation", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/foo": { + "delete": { + "operationId": "Foo_Delete", + "summary": "Foo path", + "description": "Foo operation", + "x-ms-long-running-operation": true, + "responses": { + "202": { + "description": "Accepted." + } + } + } + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-post.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-post.json new file mode 100644 index 0000000000..42818e13f1 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-post.json @@ -0,0 +1,50 @@ +{ + "swagger": "2.0", + "info": { + "title": "LongRunningResponseForPostValidation", + "description": "The 200, 201 or 204 response code is not modeled for a long running post operation", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/foo": { + "post": { + "operationId": "Foo_Post", + "summary": "Foo path", + "description": "Foo operation", + "x-ms-long-running-operation": true, + "responses": { + "202": { + "description": "Accepted." + } + } + } + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-put.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-put.json new file mode 100644 index 0000000000..d153b407b2 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/long-running-invalid-response-put.json @@ -0,0 +1,50 @@ +{ + "swagger": "2.0", + "info": { + "title": "LongRunningResponseForPutValidation", + "description": "The 200 or 201 response code is not modeled for a long running put operation", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/foo": { + "put": { + "operationId": "Foo_Create", + "summary": "Foo path", + "description": "Foo operation", + "x-ms-long-running-operation": true, + "responses": { + "202": { + "description": "Accepted." + } + } + } + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/mutability-invalid-values-for-readonly.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/mutability-invalid-values-for-readonly.json new file mode 100644 index 0000000000..d515625d99 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/mutability-invalid-values-for-readonly.json @@ -0,0 +1,97 @@ +{ + "swagger": "2.0", + "info": { + "title": "Mutability extension used with invalid values when modeled with readonly.", + "description": "Some documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/foo": { + "post": { + "operationId": "Noun_Verb", + "summary": "Foo path", + "description": "Foo operation", + "parameters": [ + { + "name": "foo1", + "description": "Name of the domain.", + "type": "string" + } + ], + "responses": { + "default": { + "description": "Unexpected error" + } + } + } + } + }, + "definitions": { + "Resource": { + "description": "The Resource Model definition.", + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource Id", + "x-ms-mutability": [ "read" ] + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name", + "x-ms-mutability": [ "create", "read" ] + }, + "type": { + "type": "string", + "description": "Resource type", + "x-ms-mutability": [ "read" ] + }, + "location": { + "type": "string", + "description": "Resource location", + "x-ms-mutability": [ "create", "read" ] + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags", + "x-ms-mutability": [ "create", "read", "update" ] + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/mutability-invalid-values.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/mutability-invalid-values.json new file mode 100644 index 0000000000..9c6dd6fd64 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/mutability-invalid-values.json @@ -0,0 +1,86 @@ +{ + "swagger": "2.0", + "info": { + "title": "Mutability extension used with invalid values.", + "description": "Some documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/foo": { + "post": { + "operationId": "Noun_Verb", + "summary": "Foo path", + "description": "Foo operation", + "parameters": [ + { + "name": "foo1", + "description": "Name of the domain.", + "type": "string" + } + ], + "responses": { + "default": { + "description": "Unexpected error" + } + } + } + } + }, + "definitions": { + "Resource": { + "description": "The Resource Model definition.", + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource Id", + "x-ms-mutability": [ "readWrite" ] + }, + "name": { + "type": "string", + "description": "Resource name", + "x-ms-mutability": [ "read", "create", "update", "delete" ] + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags", + "x-ms-mutability": [ "create", "read", "update" ] + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/operation-name-not-valid.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/operation-name-not-valid.json new file mode 100644 index 0000000000..510094f61a --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/operation-name-not-valid.json @@ -0,0 +1,85 @@ +{ + "swagger": "2.0", + "info": { + "title": "Operation name not valid", + "description": "Some documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/foo": { + "get": { + "operationId": "Noun_NotNamedGet", + "summary": "Foo get path", + "description": "Foo operation", + "responses": { + "default": { + "description": "Unexpected error" + } + } + } + }, + "/foo1": { + "put": { + "operationId": "Noun_NotNamedCreate", + "summary": "Foo2 create path", + "description": "Foo2 operation", + "responses": { + "default": { + "description": "Unexpected error" + } + } + } + }, + "/foo2": { + "delete": { + "operationId": "Noun_NotNamedDelete", + "summary": "Foo2 delete path", + "description": "Foo2 operation", + "responses": { + "default": { + "description": "Unexpected error" + } + } + } + }, + "/foo3": { + "get": { + "operationId": "Noun_List", + "summary": "Foo3 path", + "description": "Foo3 list operation", + "responses": { + "default": { + "description": "Unexpected error" + } + } + } + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/long-running-valid-response.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/long-running-valid-response.json new file mode 100644 index 0000000000..f0de67bbed --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/long-running-valid-response.json @@ -0,0 +1,180 @@ +{ + "swagger": "2.0", + "info": { + "title": "LongRunningValidResponse", + "description": "long running put operations' responses are modeled correctly with aleast one successful terminal code", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/operations": { + "get": { + "summary": "Lists all foo.", + "description": "foo", + "operationId": "Operations_List", + "parameters": [ + { + "name": "limit", + "type": "string", + "description": "foo" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/OperationsListResult" + } + }, + "default": { + "description": "unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/foo": { + "put": { + "operationId": "Foo_Create", + "summary": "Foo path", + "description": "Foo operation", + "x-ms-long-running-operation": true, + "responses": { + "200": { + "description": "OK.", + "schema": { + "$ref": "#/definitions/StorageAccount" + } + } + } + }, + "post": { + "operationId": "Foo_Post", + "summary": "Foo path", + "description": "Foo operation", + "x-ms-long-running-operation": true, + "responses": { + "201": { + "description": "Created." + } + } + }, + "delete": { + "operationId": "Foo_Delete", + "summary": "Foo path", + "description": "Foo operation", + "x-ms-long-running-operation": true, + "responses": { + "204": { + "description": "No Content." + } + } + } + } + }, + "definitions": { + "StorageAccount": { + "properties": { + "kind": { + "readOnly": true, + "type": "string", + "description": "Gets the Kind.", + "enum": [ + "Storage", + "BlobStorage" + ], + "x-ms-enum": { + "name": "Kind", + "modelAsString": false + } + } + }, + "description": "The storage account." + }, + "OperationsListResult": { + "description": "List of operations", + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + }, + "description": "List of Operations" + } + } + }, + "Operation": { + "description": "Description of Operation", + "type": "object", + "properties": { + "name": { + "description": "Operation name", + "type": "string" + }, + "display": { + "description": "foo", + "properties": { + "provider": { + "description": "Service provider", + "type": "string" + }, + "resource": { + "description": "Resource on which the operation is performed: Profile, endpoint, etc.", + "type": "string" + }, + "operation": { + "description": "Operation type: Read, write, delete, etc.", + "type": "string" + } + } + } + } + }, + "Error": { + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32", + "description": "The code of the error" + }, + "message": { + "type": "string", + "description": "The message of the error" + } + }, + "description": "An error result" + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/pageable-nextlink-defined-allof.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/pageable-nextlink-defined-allof.json new file mode 100644 index 0000000000..bae0328c08 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/pageable-nextlink-defined-allof.json @@ -0,0 +1,166 @@ +{ + "swagger": "2.0", + "info": { + "title": "PageableNextLinkModeledAllOf", + "description": "The properties needed for pageable are modeled in a parent definition", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/operations": { + "get": { + "summary": "Lists all foo.", + "description": "foo", + "operationId": "Operations_List", + "parameters": [ + { + "name": "limit", + "type": "string", + "description": "foo" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/OperationsListResult" + } + }, + "default": { + "description": "unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/foo": { + "post": { + "operationId": "PostFoo", + "summary": "Foo path", + "description": "Foo operation", + "x-ms-pageable": { + "nextLinkName": "bar" + }, + "responses": { + "200": { + "description": "A pageable response", + "schema": { + "$ref": "#/definitions/PageableFoo" + } + } + } + } + } + }, + "definitions": { + "Pageable": { + "type": "object", + "description": "Pageable object", + "properties": { + "value": { + "type": "array", + "items": { + "type": "string" + } + }, + "bar": { + "type": "string" + } + } + }, + "PageableFoo": { + "allOf": [ + { + "$ref": "#/definitions/Pageable" + } + ], + "type": "object", + "description": "Foo object that inherits from pageable and doesn't define the pageable properties" + }, + "OperationsListResult": { + "description": "List of operations", + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + }, + "description": "List of Operations" + } + } + }, + "Operation": { + "description": "Description of Operation", + "type": "object", + "properties": { + "name": { + "description": "Operation name", + "type": "string" + }, + "display": { + "description": "foo", + "properties": { + "provider": { + "description": "Service provider", + "type": "string" + }, + "resource": { + "description": "Resource on which the operation is performed: Profile, endpoint, etc.", + "type": "string" + }, + "operation": { + "description": "Operation type: Read, write, delete, etc.", + "type": "string" + } + } + } + } + }, + "Error": { + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32", + "description": "The code of the error" + }, + "message": { + "type": "string", + "description": "The message of the error" + } + }, + "description": "An error result" + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} \ No newline at end of file diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/required-property-defined-allof.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/required-property-defined-allof.json new file mode 100644 index 0000000000..0353c1e492 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/positive/required-property-defined-allof.json @@ -0,0 +1,157 @@ +{ + "swagger": "2.0", + "info": { + "title": "RequiredPropertyDefinedAllOf", + "description": "A spec file with required properties that are defined in ancestors", + "version": "2016-08-12" + }, + "host": "contoso.com", + "schemes": [ + "https" + ], + "basePath": "/", + "paths": { + "/operations": { + "get": { + "summary": "Lists all foo.", + "description": "foo", + "operationId": "Operations_List", + "parameters": [ + { + "name": "limit", + "type": "string", + "description": "foo" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/OperationsListResult" + } + }, + "default": { + "description": "unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/foo": { + "post": { + "operationId": "PostFoo", + "summary": "Foo path", + "description": "Foo operation", + "responses": { + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "definitions": { + "BaseError": { + "description": "Base error", + "properties": { + "foo": { + "type": "string", + "description": "foo property" + } + } + }, + "ParentError": { + "allOf": [ + { + "$ref": "#/definitions/BaseError" + } + ], + "description": "Parent error", + "properties": { + "bar": { + "type": "string", + "description": "bar property" + } + } + }, + "Error": { + "allOf": [ + { + "$ref": "#/definitions/ParentError" + } + ], + "description": "Default error", + "required": [ + "foo", + "bar", + "baz" + ], + "properties": { + "baz": { + "description": "baz property", + "type": "string" + } + } + }, + "OperationsListResult": { + "description": "List of operations", + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + }, + "description": "List of Operations" + } + } + }, + "Operation": { + "description": "Description of Operation", + "type": "object", + "properties": { + "name": { + "description": "Operation name", + "type": "string" + }, + "display": { + "description": "foo", + "properties": { + "provider": { + "description": "Service provider", + "type": "string" + }, + "resource": { + "description": "Resource on which the operation is performed: Profile, endpoint, etc.", + "type": "string" + }, + "operation": { + "description": "Operation type: Read, write, delete, etc.", + "type": "string" + } + } + } + } + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "test subscription id" + }, + "ApiVersion": { + "name": "api-version", + "in": "path", + "required": true, + "type": "string", + "description": "test api version" + } + } +} \ No newline at end of file diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-delete-request-body-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-delete-request-body-validation.json new file mode 100644 index 0000000000..49811078cf --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-delete-request-body-validation.json @@ -0,0 +1,87 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { + "delete": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Delete", + "description": "Deletes a Redis cache.", + "x-ms-long-running-operation": true, + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Redis cache." + }, + { + "name": "name2", + "in": "body", + "required": false, + "schema": { + "id": { + "type": "string", + "description": "API identifier path: /apis/{apiId}", + "readOnly": true + } + }, + "description": "The name of the Redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParamterer" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + + } + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-msclientname-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-msclientname-validation.json new file mode 100644 index 0000000000..0865954e97 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-msclientname-validation.json @@ -0,0 +1,112 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { + "delete": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Delete", + "description": "Deletes a Redis cache.", + "x-ms-long-running-operation": true, + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParamterer" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + + } + } + }, + "definitions": { + "Resource": { + "description": "The Resource model definition.", + "properties": { + "id": { + "readOnly": true, + "type": "string", + "x-ms-client-name": "id", + "description": "Resource Id" + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-msresource-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-msresource-validation.json new file mode 100644 index 0000000000..301b49019d --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-msresource-validation.json @@ -0,0 +1,110 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { + "delete": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Delete", + "description": "Deletes a Redis cache.", + "x-ms-long-running-operation": true, + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParamterer" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + + } + } + }, + "definitions": { + "Resource": { + "description": "The Resource model definition.", + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource Id" + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "required": [ + "location" + ] + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-resource-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-resource-validation.json new file mode 100644 index 0000000000..d34a89b049 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-ext-resource-validation.json @@ -0,0 +1,106 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { + "delete": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Delete", + "description": "Deletes a Redis cache.", + "x-ms-long-running-operation": true, + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParamterer" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + + } + } + }, + "definitions": { + "Resource": { + "description": "The Resource model definition.", + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource Id" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-guid-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-guid-validation.json new file mode 100644 index 0000000000..8132da3638 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-guid-validation.json @@ -0,0 +1,157 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/service/{serviceName}/apis/{apiId}/operations": { + "get": { + "tags": [ + "ApiOperations" + ], + "operationId": "ApiOperations_ListByApi", + "description": "Lists a collection of the operations for the specified API.", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParamterer" + }, + { + "name": "resourceGroupName", + "in": "path", + "description": "Resource Group ID.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "A collection of operation summary entities at the API level.", + "schema": { + "$ref": "#/definitions/Product" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { + "get": { + "operationId": "list", + "summary": "Product Types", + "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParamterer" + }, + { + "name": "resourceGroupName", + "in": "path", + "description": "Resource Group ID.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "tags": [ + "Redis" + ], + "responses": { + "200": { + "description": "A list of caches", + "schema": { + "$ref": "#/definitions/Product" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "definitions": { + "Product": { + "title": "The product title.", + "description": "The product documentation.", + "properties": { + "product_id": { + "type": "string", + "title": "A product id.", + "format": "uuid", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_name": { + "type": "string", + "description": "Display name of product." + }, + "capacity": { + "type": "string", + "description": "Capacity of product. For example, 4 people.", + "default": "100" + }, + "image": { + "type": "string", + "description": "Image URL representing the product." + } + }, + "example": { + "name": "Puma", + "id": 1 + } + }, + "Error": { + "description": "The Error documentation.", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "description": "Description dummy" + }, + "message": { + "type": "string", + "description": "Description dummy" + }, + "fields": { + "type": "string", + "description": "Description dummy" + } + } + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-operations-api-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-operations-api-validation.json new file mode 100644 index 0000000000..a246002862 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-operations-api-validation.json @@ -0,0 +1,111 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { + "delete": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Delete", + "description": "Deletes a Redis cache.", + "x-ms-long-running-operation": true, + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParamterer" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + + } + } + }, + "definitions": { + "Resource": { + "description": "The Resource model definition.", + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource Id" + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-putgetpatch-response-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-putgetpatch-response-validation.json new file mode 100644 index 0000000000..2bd6e59bce --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-putgetpatch-response-validation.json @@ -0,0 +1,774 @@ +{ + "swagger": "2.0", + "info": { + "title": "DnsManagementClient", + "description": "The DNS Management Client.", + "version": "2016-04-01" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}": { + "patch": { + "tags": [ + "RecordSets" + ], + "operationId": "RecordSets_Update", + "description": "Updates a record set within a DNS zone.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "zoneName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the DNS zone (without a terminating dot)." + }, + { + "name": "relativeRecordSetName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the record set, relative to the name of the zone.", + "x-ms-skip-url-encoding": true + }, + { + "name": "recordType", + "in": "path", + "required": true, + "type": "string", + "description": "The type of DNS record in this record set.", + "enum": [ + "A", + "AAAA", + "CNAME", + "MX", + "NS", + "PTR", + "SOA", + "SRV", + "TXT" + ], + "x-ms-enum": { + "name": "RecordType", + "modelAsString": false + } + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RecordSet" + }, + "description": "Parameters supplied to the Update operation." + }, + { + "name": "If-Match", + "in": "header", + "required": false, + "type": "string", + "x-ms-client-name": "IfMatch", + "description": "The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwritting concurrent changes." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "The record set has been updated.", + "schema": { + "$ref": "#/definitions/CloudError" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/CloudError" + } + } + } + }, + "put": { + "tags": [ + "RecordSets" + ], + "operationId": "RecordSets_CreateOrUpdate", + "description": "Creates or updates a record set within a DNS zone.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "zoneName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the DNS zone (without a terminating dot)." + }, + { + "name": "relativeRecordSetName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the record set, relative to the name of the zone.", + "x-ms-skip-url-encoding": true + }, + { + "name": "recordType", + "in": "path", + "required": true, + "type": "string", + "description": "The type of DNS record in this record set. Record sets of type SOA can be updated but not created (they are created when the DNS zone is created).", + "enum": [ + "A", + "AAAA", + "CNAME", + "MX", + "NS", + "PTR", + "SOA", + "SRV", + "TXT" + ], + "x-ms-enum": { + "name": "RecordType", + "modelAsString": false + } + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RecordSet" + }, + "description": "Parameters supplied to the CreateOrUpdate operation." + }, + { + "name": "If-Match", + "in": "header", + "required": false, + "type": "string", + "x-ms-client-name": "IfMatch", + "description": "The etag of the record set. Omit this value to always overwrite the current record set. Specify the last-seen etag value to prevent accidentally overwritting any concurrent changes." + }, + { + "name": "If-None-Match", + "in": "header", + "required": false, + "type": "string", + "x-ms-client-name": "IfNoneMatch", + "description": "Set to '*' to allow a new record set to be created, but to prevent updating an existing record set. Other values will be ignored." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "201": { + "description": "The record set has been created.", + "schema": { + "$ref": "#/definitions/RecordSet" + } + }, + "200": { + "description": "The record set has been updated.", + "schema": { + "$ref": "#/definitions/RecordSet" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/CloudError" + } + } + } + }, + "get": { + "tags": [ + "RecordSets" + ], + "operationId": "RecordSets_Get", + "description": "Gets a record set.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "zoneName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the DNS zone (without a terminating dot)." + }, + { + "name": "relativeRecordSetName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the record set, relative to the name of the zone.", + "x-ms-skip-url-encoding": true + }, + { + "name": "recordType", + "in": "path", + "required": true, + "type": "string", + "description": "The type of DNS record in this record set.", + "enum": [ + "A", + "AAAA", + "CNAME", + "MX", + "NS", + "PTR", + "SOA", + "SRV", + "TXT" + ], + "x-ms-enum": { + "name": "RecordType", + "modelAsString": false + } + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/RecordSet" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/CloudError" + } + } + } + } + } + }, + "definitions": { + "RecordSet": { + "properties": { + "id": { + "type": "string", + "description": "The ID of the record set." + }, + "name": { + "type": "string", + "description": "The name of the record set." + }, + "type": { + "type": "string", + "description": "The type of the record set." + }, + "etag": { + "type": "string", + "description": "The etag of the record set." + }, + "properties": { + "$ref": "#/definitions/RecordSetProperties", + "x-ms-client-flatten": true, + "description": "The properties of the record set." + } + }, + "description": "Describes a DNS record set (a collection of DNS records with the same name and type)." + }, + "ARecord": { + "properties": { + "ipv4Address": { + "type": "string", + "description": "The IPv4 address of this A record." + } + }, + "description": "An A record." + }, + "AaaaRecord": { + "properties": { + "ipv6Address": { + "type": "string", + "description": "The IPv6 address of this AAAA record." + } + }, + "description": "An AAAA record." + }, + "MxRecord": { + "properties": { + "preference": { + "type": "integer", + "format": "int32", + "description": "The preference value for this MX record." + }, + "exchange": { + "type": "string", + "description": "The domain name of the mail host for this MX record." + } + }, + "description": "An MX record." + }, + "NsRecord": { + "properties": { + "nsdname": { + "type": "string", + "description": "The name server name for this NS record." + } + }, + "description": "An NS record." + }, + "PtrRecord": { + "properties": { + "ptrdname": { + "type": "string", + "description": "The PTR target domain name for this PTR record." + } + }, + "description": "A PTR record." + }, + "SrvRecord": { + "properties": { + "priority": { + "type": "integer", + "format": "int32", + "description": "The priority value for this SRV record." + }, + "weight": { + "type": "integer", + "format": "int32", + "description": "The weight value for this SRV record." + }, + "port": { + "type": "integer", + "format": "int32", + "description": "The port value for this SRV record." + }, + "target": { + "type": "string", + "description": "The target domain name for this SRV record." + } + }, + "description": "An SRV record." + }, + "TxtRecord": { + "properties": { + "value": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The text value of this TXT record." + } + }, + "description": "A TXT record." + }, + "CnameRecord": { + "properties": { + "cname": { + "type": "string", + "description": "The canonical name for this CNAME record." + } + }, + "description": "A CNAME record." + }, + "SoaRecord": { + "properties": { + "host": { + "type": "string", + "description": "The domain name of the authoritative name server for this SOA record." + }, + "email": { + "type": "string", + "description": "The email contact for this SOA record." + }, + "serialNumber": { + "type": "integer", + "format": "int64", + "description": "The serial number for this SOA record." + }, + "refreshTime": { + "type": "integer", + "format": "int64", + "description": "The refresh value for this SOA record." + }, + "retryTime": { + "type": "integer", + "format": "int64", + "description": "The retry time for this SOA record." + }, + "expireTime": { + "type": "integer", + "format": "int64", + "description": "The expire time for this SOA record." + }, + "minimumTTL": { + "type": "integer", + "format": "int64", + "x-ms-client-name": "minimumTtl", + "description": "The minimum value for this SOA record. By convention this is used to determine the negative caching duration." + } + }, + "description": "An SOA record." + }, + "RecordSetProperties": { + "properties": { + "metadata": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "The metadata attached to the record set." + }, + "TTL": { + "type": "integer", + "format": "int64", + "description": "The TTL (time-to-live) of the records in the record set." + }, + "ARecords": { + "type": "array", + "items": { + "$ref": "#/definitions/ARecord" + }, + "description": "The list of A records in the record set." + }, + "AAAARecords": { + "type": "array", + "x-ms-client-name": "AaaaRecords", + "items": { + "$ref": "#/definitions/AaaaRecord" + }, + "description": "The list of AAAA records in the record set." + }, + "MXRecords": { + "type": "array", + "x-ms-client-name": "MxRecords", + "items": { + "$ref": "#/definitions/MxRecord" + }, + "description": "The list of MX records in the record set." + }, + "NSRecords": { + "type": "array", + "x-ms-client-name": "NsRecords", + "items": { + "$ref": "#/definitions/NsRecord" + }, + "description": "The list of NS records in the record set." + }, + "PTRRecords": { + "type": "array", + "x-ms-client-name": "PtrRecords", + "items": { + "$ref": "#/definitions/PtrRecord" + }, + "description": "The list of PTR records in the record set." + }, + "SRVRecords": { + "type": "array", + "x-ms-client-name": "SrvRecords", + "items": { + "$ref": "#/definitions/SrvRecord" + }, + "description": "The list of SRV records in the record set." + }, + "TXTRecords": { + "type": "array", + "x-ms-client-name": "TxtRecords", + "items": { + "$ref": "#/definitions/TxtRecord" + }, + "description": "The list of TXT records in the record set." + }, + "CNAMERecord": { + "$ref": "#/definitions/CnameRecord", + "x-ms-client-name": "CnameRecord", + "description": "The CNAME record in the record set." + }, + "SOARecord": { + "$ref": "#/definitions/SoaRecord", + "x-ms-client-name": "SoaRecord", + "description": "The SOA record in the record set." + } + }, + "description": "Represents the properties of the records in the record set." + }, + + "RecordSetUpdateParameters": { + "properties": { + "RecordSet": { + "$ref": "#/definitions/RecordSet", + "description": "Specifies information about the record set being updated." + } + }, + "description": "Parameters supplied to update a record set." + }, + "RecordSetListResult": { + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/RecordSet" + }, + "description": "Information about the record sets in the response." + }, + "nextLink": { + "type": "string", + "description": "The continuation token for the next page of results." + } + }, + "description": "The response to a record set List operation." + }, + "ZoneProperties": { + "properties": { + "maxNumberOfRecordSets": { + "type": "integer", + "format": "int64", + "description": "The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored." + }, + "numberOfRecordSets": { + "type": "integer", + "format": "int64", + "description": "The current number of record sets in this DNS zone. This is a read-only property and any attempt to set this value will be ignored." + }, + "nameServers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored.", + "readOnly": true + } + }, + "description": "Represents the properties of the zone." + }, + "Zone": { + "properties": { + "etag": { + "type": "string", + "description": "The etag of the zone." + }, + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/ZoneProperties", + "description": "The properties of the zone." + } + }, + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "description": "Describes a DNS zone." + }, + "ZoneDeleteResult": { + "properties": { + "azureAsyncOperation": { + "type": "string", + "description": "Users can perform a Get on Azure-AsyncOperation to get the status of their delete Zone operations." + }, + "status": { + "type": "string", + "enum": [ + "InProgress", + "Succeeded", + "Failed" + ], + "x-ms-enum": { + "name": "OperationStatus", + "modelAsString": false + } + }, + "statusCode": { + "type": "string", + "enum": [ + "Continue", + "SwitchingProtocols", + "OK", + "Created", + "Accepted", + "NonAuthoritativeInformation", + "NoContent", + "ResetContent", + "PartialContent", + "MultipleChoices", + "Ambiguous", + "MovedPermanently", + "Moved", + "Found", + "Redirect", + "SeeOther", + "RedirectMethod", + "NotModified", + "UseProxy", + "Unused", + "TemporaryRedirect", + "RedirectKeepVerb", + "BadRequest", + "Unauthorized", + "PaymentRequired", + "Forbidden", + "NotFound", + "MethodNotAllowed", + "NotAcceptable", + "ProxyAuthenticationRequired", + "RequestTimeout", + "Conflict", + "Gone", + "LengthRequired", + "PreconditionFailed", + "RequestEntityTooLarge", + "RequestUriTooLong", + "UnsupportedMediaType", + "RequestedRangeNotSatisfiable", + "ExpectationFailed", + "UpgradeRequired", + "InternalServerError", + "NotImplemented", + "BadGateway", + "ServiceUnavailable", + "GatewayTimeout", + "HttpVersionNotSupported" + ], + "x-ms-enum": { + "name": "HttpStatusCode", + "modelAsString": false + } + }, + "requestId": { + "type": "string" + } + }, + "description": "The response to a Zone Delete operation." + }, + "ZoneListResult": { + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/Zone" + }, + "description": "Information about the DNS zones." + }, + "nextLink": { + "type": "string", + "description": "The continuation token for the next page of results." + } + }, + "description": "The response to a Zone List or ListAll operation." + }, + "Resource": { + "x-ms-azure-resource": true, + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource ID." + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name." + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type." + }, + "location": { + "type": "string", + "description": "Resource location." + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags." + } + }, + "required": [ + "location" + ] + }, + "SubResource": { + "properties": { + "id": { + "type": "string", + "description": "Resource Id." + } + }, + "x-ms-external": true + }, + "CloudError": { + "type": "object", + "properties": { "error": { "$ref": "#/definitions/CloudErrorBody" } }, + "x-ms-external": true + }, + "CloudErrorBody": { + "type": "object", + "properties": { + "code": { "type": "string" }, + "message": { "type": "string" }, + "target": { "type": "string" }, + "details": { + "type": "array", + "items": { "$ref": "#/definitions/CloudErrorBody" } + } + }, + "x-ms-external": true + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription." + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Specifies the API version." + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-skumodel-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-skumodel-validation.json new file mode 100644 index 0000000000..961e5c68b0 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-skumodel-validation.json @@ -0,0 +1,134 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { + "delete": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Delete", + "description": "Deletes a Redis cache.", + "x-ms-long-running-operation": true, + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParamterer" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + + } + } + }, + "definitions": { + "Sku": { + "description": "The SKU (pricing tier) of the CDN profile.", + "type": "object", + "properties": { + "name": { + "description": "Name of the pricing tier", + "enum": [ + "Standard", + "Premium" + ], + "type": "string", + "x-ms-enum": { + "name": "SkuName", + "modelAsString": false + } + }, + "dummy1": { + "type": "string", + "description": "Resource name" + } + } + }, + "Resource": { + "description": "The Resource model definition.", + "properties": { + "id": { + "readOnly": true, + "type": "string", + "x-ms-client-name": "id", + "description": "Resource Id" + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-1-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-1-validation.json new file mode 100644 index 0000000000..2181597e0b --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-1-validation.json @@ -0,0 +1,145 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}": { + "delete": { + "tags": [ + "Redis" + ], + "operationId": "Redis_Delete", + "description": "Deletes a Redis cache.", + "x-ms-long-running-operation": true, + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "name", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Redis cache." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParamterer" + } + ], + "responses": { + "200": { + "description": "" + }, + "204": { + "description": "" + } + } + + } + } + }, + "definitions": { + "Sku": { + "description": "The SKU (pricing tier) of the CDN profile.", + "type": "object", + "properties": { + "name": { + "description": "Name of the pricing tier", + "enum": [ + "Standard", + "Premium" + ], + "type": "string", + "x-ms-enum": { + "name": "SkuName", + "modelAsString": false + } + } + } + }, + "StorageAccountInfo": { + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "properties": { + "properties": { + "dummy1": { + "type": "string" + } + } + }, + "description": "Azure Storage account information." + }, + "Resource": { + "description": "The Resource model definition.", + "properties": { + "id": { + "readOnly": true, + "type": "string", + "x-ms-client-name": "id", + "description": "Resource Id" + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name" + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type" + }, + "location": { + "type": "string", + "description": "Resource location" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-2-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-2-validation.json new file mode 100644 index 0000000000..6834763b0a --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-2-validation.json @@ -0,0 +1,159 @@ +{ + "swagger": "2.0", + "info": { + "title": "DnsManagementClient", + "description": "The DNS Management Client.", + "version": "2016-04-01" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}": { + "get": { + "tags": [ + "Zones" + ], + "operationId": "Zones_Get", + "description": "Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "zoneName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the DNS zone (without a terminating dot)." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/Zone" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/Zone" + } + } + } + } + } + }, + "definitions": { + "Zone": { + "properties": { + "etag": { + "type": "string", + "description": "The etag of the zone." + }, + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/ZoneProperties", + "description": "The properties of the zone." + } + }, + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "description": "Describes a DNS zone." + }, + "ZoneProperties": { + "properties": { + "maxNumberOfRecordSets": { + "type": "integer", + "format": "int64", + "description": "The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored." + }, + "numberOfRecordSets": { + "type": "integer", + "format": "int64", + "description": "The current number of record sets in this DNS zone. This is a read-only property and any attempt to set this value will be ignored." + }, + "nameServers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored.", + "readOnly": true + } + }, + "description": "Represents the properties of the zone." + }, + "Resource": { + "x-ms-azure-resource": true, + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource ID." + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name." + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type." + }, + "location": { + "type": "string", + "description": "Resource location." + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags." + } + }, + "required": [ + "location" + ] + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription." + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Specifies the API version." + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-3-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-3-validation.json new file mode 100644 index 0000000000..09cb36581d --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-3-validation.json @@ -0,0 +1,224 @@ +{ + "swagger": "2.0", + "info": { + "title": "DnsManagementClient", + "description": "The DNS Management Client.", + "version": "2016-04-01" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}": { + "get": { + "tags": [ + "Zones" + ], + "operationId": "Zones_Get", + "description": "Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "zoneName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the DNS zone (without a terminating dot)." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/Zone" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/Zone" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones": { + "get": { + "tags": [ + "Zones" + ], + "operationId": "Zones_ListByResourceGroup", + "description": "Lists the DNS zones within a resource group.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "$top", + "in": "query", + "required": false, + "type": "integer", + "format": "int32", + "description": "The maximum number of record sets to return. If not specified, returns up to 100 record sets." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/ZoneListResult" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/Zone" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + } + }, + "definitions": { + "ZoneListResult": { + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/Zone" + }, + "description": "Information about the DNS zones." + }, + "nextLink": { + "type": "string", + "description": "The continuation token for the next page of results." + } + }, + "description": "The response to a Zone List or ListAll operation." + }, + "Zone": { + "properties": { + "etag": { + "type": "string", + "description": "The etag of the zone." + }, + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/ZoneProperties", + "description": "The properties of the zone." + } + }, + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "description": "Describes a DNS zone." + }, + "ZoneProperties": { + "properties": { + "maxNumberOfRecordSets": { + "type": "integer", + "format": "int64", + "description": "The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored." + }, + "numberOfRecordSets": { + "type": "integer", + "format": "int64", + "description": "The current number of record sets in this DNS zone. This is a read-only property and any attempt to set this value will be ignored." + }, + "nameServers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored.", + "readOnly": true + } + }, + "description": "Represents the properties of the zone." + }, + "Resource": { + "x-ms-azure-resource": true, + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource ID." + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name." + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type." + }, + "location": { + "type": "string", + "description": "Resource location." + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags." + } + }, + "required": [ + "location" + ] + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription." + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Specifies the API version." + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-4-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-4-validation.json new file mode 100644 index 0000000000..97125c1dff --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-tracked-resource-4-validation.json @@ -0,0 +1,270 @@ +{ + "swagger": "2.0", + "info": { + "title": "DnsManagementClient", + "description": "The DNS Management Client.", + "version": "2016-04-01" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}": { + "get": { + "tags": [ + "Zones" + ], + "operationId": "Zones_Get", + "description": "Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "zoneName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the DNS zone (without a terminating dot)." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/Zone" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/Zone" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones": { + "get": { + "tags": [ + "Zones" + ], + "operationId": "Zones_ListByResourceGroup", + "description": "Lists the DNS zones within a resource group.", + "parameters": [ + { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group." + }, + { + "name": "$top", + "in": "query", + "required": false, + "type": "integer", + "format": "int32", + "description": "The maximum number of record sets to return. If not specified, returns up to 100 record sets." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/ZoneListResult" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/Zone" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones": { + "get": { + "tags": [ + "Zones" + ], + "operationId": "Zones_List", + "description": "Lists the DNS zones in all resource groups in a subscription.", + "parameters": [ + { + "name": "$top", + "in": "query", + "required": false, + "type": "integer", + "format": "int32", + "description": "The maximum number of DNS zones to return. If not specified, returns up to 100 zones." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Success.", + "schema": { + "$ref": "#/definitions/ZoneListResult" + } + }, + "default": { + "description": "Default response. It will be deserialized as per the Error definition.", + "schema": { + "$ref": "#/definitions/Zone" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + } + }, + "definitions": { + "ZoneListResult": { + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/Zone" + }, + "description": "Information about the DNS zones." + }, + "nextLink": { + "type": "string", + "description": "The continuation token for the next page of results." + } + }, + "description": "The response to a Zone List or ListAll operation." + }, + "Zone": { + "properties": { + "etag": { + "type": "string", + "description": "The etag of the zone." + }, + "location": { + "type": "string", + "description": "The etag of the zone." + }, + "properties": { + "x-ms-client-flatten": true, + "$ref": "#/definitions/ZoneProperties", + "description": "The properties of the zone." + } + }, + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "description": "Describes a DNS zone." + }, + "ZoneProperties": { + "properties": { + "maxNumberOfRecordSets": { + "type": "integer", + "format": "int64", + "description": "The maximum number of record sets that can be created in this DNS zone. This is a read-only property and any attempt to set this value will be ignored." + }, + "numberOfRecordSets": { + "type": "integer", + "format": "int64", + "description": "The current number of record sets in this DNS zone. This is a read-only property and any attempt to set this value will be ignored." + }, + "nameServers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The name servers for this DNS zone. This is a read-only property and any attempt to set this value will be ignored.", + "readOnly": true + } + }, + "description": "Represents the properties of the zone." + }, + "Resource": { + "x-ms-azure-resource": true, + "properties": { + "id": { + "readOnly": true, + "type": "string", + "description": "Resource ID." + }, + "name": { + "readOnly": true, + "type": "string", + "description": "Resource name." + }, + "type": { + "readOnly": true, + "type": "string", + "description": "Resource type." + }, + "location": { + "type": "string", + "description": "Resource location." + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags." + } + }, + "required": [ + "location" + ] + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "Specifies the Azure subscription ID, which uniquely identifies the Microsoft Azure subscription." + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Specifies the API version." + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-version-validation.json b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-version-validation.json new file mode 100644 index 0000000000..31a3678417 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/Validation/swagger-version-validation.json @@ -0,0 +1,156 @@ +{ + "swagger": "2.0", + "info": { + "title": "Microsoft Azure Redis Cache Management API", + "description": "Some cool documentation.", + "version": "2014-04-01-xyz" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "basePath": "/", + "produces": [ "application/json" ], + "consumes": [ "application/json" ], + "paths": { + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/service/{serviceName}/apis/{apiId}/operations": { + "get": { + "tags": [ + "ApiOperations" + ], + "operationId": "ApiOperations_ListByApi", + "description": "Lists a collection of the operations for the specified API.", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParamterer" + }, + { + "name": "resourceGroupName", + "in": "path", + "description": "Resource Group ID.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "A collection of operation summary entities at the API level.", + "schema": { + "$ref": "#/definitions/Product" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/Microsoft.Cache/Redis?api-version={apiVersion}": { + "get": { + "operationId": "list", + "summary": "Product Types", + "description": "The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParamterer" + }, + { + "name": "resourceGroupName", + "in": "path", + "description": "Resource Group ID.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "tags": [ + "Redis" + ], + "responses": { + "200": { + "description": "A list of caches", + "schema": { + "$ref": "#/definitions/Product" + } + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "definitions": { + "Product": { + "title": "The product title.", + "description": "The product documentation.", + "properties": { + "product_id": { + "type": "string", + "title": "A product id.", + "description": "Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles." + }, + "description": { + "type": "string", + "description": "Description of product." + }, + "display_name": { + "type": "string", + "description": "Display name of product." + }, + "capacity": { + "type": "string", + "description": "Capacity of product. For example, 4 people.", + "default": "100" + }, + "image": { + "type": "string", + "description": "Image URL representing the product." + } + }, + "example": { + "name": "Puma", + "id": 1 + } + }, + "Error": { + "description": "The Error documentation.", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "description": "Description dummy" + }, + "message": { + "type": "string", + "description": "Description dummy" + }, + "fields": { + "type": "string", + "description": "Description dummy" + } + } + } + }, + "parameters": { + "SubscriptionIdParamterer": { + "name": "subscriptionId", + "in": "path", + "description": "Subscription ID.", + "required": true, + "type": "string" + }, + "ApiVersionParameter": { + "name": "apiVersion", + "in": "path", + "description": "API ID.", + "required": true, + "type": "string" + } + } +} diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml-paths.yaml b/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml-paths.yaml new file mode 100644 index 0000000000..f1a544b616 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml-paths.yaml @@ -0,0 +1,32 @@ +swagger: "2.0" +info: + title: Xml Tests + version: 1.0.0 +schemes: +- http +consumes: +- application/xml +- application/json +produces: +- application/xml +- application/json +definitions: + ModelComplex: + type: object + properties: + PropertySimple: + description: CUSTOM_PropertySimple # description ~ RealPath (need prefix since "description" is sometimes overridden by something "better" by the modeler) + summary: PropertyOverride # summary ~ RealXmlPath + type: string + xml: + name: PropertyOverride + PropertyArray: + description: CUSTOM_PropertyArray + summary: + type: array + items: + type: string + additionalProperties: + type: string + description: CUSTOM_ + summary: \ No newline at end of file diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml.yaml b/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml.yaml new file mode 100644 index 0000000000..c57f824ca1 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml.yaml @@ -0,0 +1,51 @@ +swagger: "2.0" +info: + title: Xml Tests + version: 1.0.0 +schemes: +- http +consumes: +- application/xml +- application/json +produces: +- application/xml +- application/json +definitions: + ModelPlain: + description: ModelPlain + type: object + properties: + PropertyPlain: + description: PropertyPlain + type: string + PropertyOverridden: + description: PropertyOverride + type: string + xml: + name: PropertyOverride + ModelOverridden: + description: ModelOverride + type: object + xml: + name: ModelOverride + properties: + PropertyPlain: + description: PropertyPlain + type: string + PropertyOverridden: + description: PropertyOverride + type: string + xml: + name: PropertyOverride + ModelComplex: + description: ModelComplex + type: object + properties: + PropertyPlain: + description: PropertyPlain + $ref: "#/definitions/ModelOverridden" + PropertyOverridden: + description: PropertyOverride + $ref: "#/definitions/ModelOverridden" + xml: + name: PropertyOverride \ No newline at end of file diff --git a/src/modeler/AutoRest.Swagger.Tests/SwaggerModelerValidationTests.cs b/src/modeler/AutoRest.Swagger.Tests/SwaggerModelerValidationTests.cs index c162af999c..43b46f13b2 100644 --- a/src/modeler/AutoRest.Swagger.Tests/SwaggerModelerValidationTests.cs +++ b/src/modeler/AutoRest.Swagger.Tests/SwaggerModelerValidationTests.cs @@ -72,6 +72,14 @@ public void AvoidMsdnReferencesValidation() messages.AssertOnlyValidationMessage(typeof(AvoidMsdnReferences), 4); } + [Fact] + public void BooleanPropertiesValidation() + { + var messages = ValidateSwagger(Path.Combine("Swagger", "Validation", "boolean-properties.json")); + + messages.AssertOnlyValidationMessage(typeof(BooleanPropertyNotRecommended)); + } + [Fact] public void DefaultValueInEnumValidation() { diff --git a/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs b/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs index 8d5d4dd441..30f5807819 100644 --- a/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs +++ b/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs @@ -94,6 +94,7 @@ public ServiceDefinition() /// /// Key is the object serviceTypeName and the value is swagger definition. /// + [Rule(typeof(BooleanPropertyNotRecommended))] [Rule(typeof(ResourceModelValidation))] [Rule(typeof(TrackedResourceValidation))] [Rule(typeof(ResourceIsMsResourceValidation))] diff --git a/src/modeler/AutoRest.Swagger/SwaggerParser.cs b/src/modeler/AutoRest.Swagger/SwaggerParser.cs index e5553e7a20..bcade65f47 100644 --- a/src/modeler/AutoRest.Swagger/SwaggerParser.cs +++ b/src/modeler/AutoRest.Swagger/SwaggerParser.cs @@ -96,7 +96,7 @@ public static void EnsureCompleteDefinitionIsPresent(HashSet visitedEnti { currentDoc[entityType][modelName] = externalFiles[filePath][entityType][modelName]; //recursively check if the model is completely defined. - EnsureCompleteDefinitionIsPresent(visitedEntities, externalFiles, currentFilePath, entityType, modelName, externalFiles[filePath]); + EnsureCompleteDefinitionIsPresent(visitedEntities, externalFiles, filePath, entityType, modelName, externalFiles[filePath]); } else { diff --git a/src/modeler/AutoRest.Swagger/Validation/BooleanPropertyNotRecommended.cs b/src/modeler/AutoRest.Swagger/Validation/BooleanPropertyNotRecommended.cs new file mode 100644 index 0000000000..8be6e94195 --- /dev/null +++ b/src/modeler/AutoRest.Swagger/Validation/BooleanPropertyNotRecommended.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using AutoRest.Core.Logging; +using AutoRest.Core.Properties; +using AutoRest.Core.Validation; +using System.Collections.Generic; +using AutoRest.Swagger.Model; + +namespace AutoRest.Swagger.Validation +{ + /// + /// Flags properties of boolean type as they are not recommended, unless it's the only option. + /// + public class BooleanPropertyNotRecommended : TypedRule> + { + /// + /// The template message for this Rule. + /// + /// + /// This may contain placeholders '{0}' for parameterized messages. + /// + public override string MessageTemplate => Resources.BooleanPropertyNotRecommended; + + /// + /// The severity of this message (ie, debug/info/warning/error/fatal, etc) + /// + public override Category Severity => Category.Warning; + + /// + /// Validates whether properties of type boolean exist. + /// + /// Operation Definition to validate + /// true if there are propeties of type boolean, false otherwise. + public override bool IsValid(Dictionary definitions, RuleContext context, out object[] formatParameters) + { + formatParameters = null; + List booleanProperties = new List(); + foreach (string key in definitions.Keys) + { + Schema definitionSchema = definitions.GetValueOrNull(key); + if (definitionSchema.Properties != null) + { + foreach (var property in definitionSchema.Properties) + { + if (property.Value.Type.ToString().ToLower().Equals("boolean")) + { + booleanProperties.Add(key + "/" + property.Key); + + } + } + } + } + formatParameters = new[] { string.Join(", ", booleanProperties.ToArray()) }; + return (booleanProperties.Count == 0); + } + } +} \ No newline at end of file