Skip to content

Commit

Permalink
Working on model
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Schulte committed May 6, 2016
1 parent 5e54326 commit c4c32d2
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@ public static void Batch()
SwaggerSpecHelper.RunTests<AzureResourceSchemaCodeGenerator>(
SwaggerFile("BatchManagement.json"), ExpectedFolder("Batch"));
}

[Fact]
public static void Cdn()
{
SwaggerSpecHelper.RunTests<AzureResourceSchemaCodeGenerator>(
SwaggerFile("cdn.json"), ExpectedFolder("CDN"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<ItemGroup>
<Compile Include="AcceptanceTests.cs" />
<Compile Include="AzureResourceSchemaCodeGeneratorTests.cs" />
<Compile Include="JSONSchemaTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -82,7 +83,9 @@
<Content Include="Expected\Batch\Microsoft.Batch.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Expected\CDN\Microsoft.Cdn.json" />
<Content Include="Expected\CDN\Microsoft.Cdn.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="packages.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -92,7 +95,9 @@
<Content Include="Swagger\BatchManagement.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Swagger\cdn.json" />
<Content Include="Swagger\cdn.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Modelers\Swagger.Tests\AutoRest.Modeler.Swagger.Tests.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Microsoft.Batch/batchAccounts"
]
},
"apiVersion": {
"type": "string",
"enum": [
"2015-12-01"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,54 @@
"title": "Microsoft.Cdn",
"description": "Microsoft Cdn Resource Types",
"resourceDefinitions": {
"profiles": {
"customDomains": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Microsoft.Cdn/profiles"
"Microsoft.Cdn/profiles/endpoints/customDomains"
]
},
"apiVersion": {
"type": "string",
"enum": [
"2016-04-02"
]
},
"location": {
"type": "string",
"description": "Profile location"
},
"tags": {
"properties": {
"type": "object",
"additionalProperties": {
"type": "string"
"properties": {
"hostName": {
"type": "string",
"description": "The host name of the custom domain. Must be a domain name."
}
},
"description": "Profile tags"
},
"sku": {
"$ref": "#/definitions/Sku",
"description": "Profile SKU"
"required": [
"hostName"
]
}
},
"required": [
"location",
"sku"
"type",
"apiVersion",
"properties"
],
"description": "Profile properties required for profile creation."
"description": "Microsoft.Cdn/profiles/endpoints/customDomains"
},
"endpoints": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Microsoft.Cdn/profiles/endpoints"
]
},
"apiVersion": {
"type": "string",
"enum": [
"2015-06-01"
"2016-04-02"
]
},
"location": {
Expand All @@ -64,63 +66,145 @@
"description": "Endpoint tags"
},
"properties": {
"originHostHeader": {
"type": "string",
"description": "The host header CDN provider will send along with content requests to origins. The default value is the host name of the origin."
},
"originPath": {
"type": "string",
"description": "The path used for origin requests."
},
"contentTypesToCompress": {
"type": "array",
"items": {
"type": "string"
"type": "object",
"properties": {
"originHostHeader": {
"type": "string",
"description": "The host header CDN provider will send along with content requests to origins. The default value is the host name of the origin."
},
"description": "List of content types on which compression will be applied. The value for the elements should be a valid MIME type."
},
"isCompressionEnabled": {
"type": "boolean",
"description": "Indicates whether content compression is enabled. Default value is false. If compression is enabled, the content transferred from the CDN endpoint to the end user will be compressed. The requested content must be larger than 1 byte and smaller than 1 MB."
},
"isHttpAllowed": {
"type": "boolean",
"description": "Indicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed."
},
"isHttpsAllowed": {
"type": "boolean",
"description": "Indicates whether https traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed."
},
"queryStringCachingBehavior": {
"$ref": "#/definitions/QueryStringCachingBehavior",
"description": "Defines the query string caching behavior."
},
"origins": {
"type": "array",
"items": {
"$ref": "#/definitions/DeepCreatedOrigin"
"originPath": {
"type": "string",
"description": "The path used for origin requests."
},
"contentTypesToCompress": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of content types on which compression will be applied. The value for the elements should be a valid MIME type."
},
"isCompressionEnabled": {
"type": "boolean",
"description": "Indicates whether content compression is enabled. Default value is false. If compression is enabled, the content transferred from the CDN endpoint to the end user will be compressed. The requested content must be larger than 1 byte and smaller than 1 MB."
},
"isHttpAllowed": {
"type": "boolean",
"description": "Indicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed."
},
"isHttpsAllowed": {
"type": "boolean",
"description": "Indicates whether https traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed."
},
"queryStringCachingBehavior": {
"type": "string",
"enum": [
"IgnoreQueryString",
"BypassCaching",
"UseQueryString",
"NotSet"
],
"description": "Defines the query string caching behavior. Possible values include: 'IgnoreQueryString', 'BypassCaching', 'UseQueryString', 'NotSet'"
},
"origins": {
"type": "array",
"items": {
"$ref": "#/definitions/DeepCreatedOrigin"
}
}
}
},
"required": [
"origins"
]
},
"required": [
"origins"
]
}
},
"required": [
"type",
"apiVersion",
"properties",
"location"
],
"description": "Endpoint properties required for new endpoint creation."
"description": "Microsoft.Cdn/profiles/endpoints"
},
"origins": {
"type": "object",
"properties": {

"type": {
"type": "string",
"enum": [
"Microsoft.Cdn/profiles/endpoints/origins"
]
},
"apiVersion": {
"type": "string",
"enum": [
"2016-04-02"
]
},
"properties": {
"type": "object",
"properties": {
"hostName": {
"type": "string",
"description": "The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported."
},
"httpPort": {
"type": "integer",
"description": "The value of the HTTP port. Must be between 1 and 65535."
},
"httpsPort": {
"type": "integer",
"description": "The value of the HTTPS port. Must be between 1 and 65535."
}
},
"required": [
"hostName"
]
}
},
"required": [
"type",
"apiVersion",
"properties"
],
"description": "Origin properties needed for origin creation or update."
"description": "Microsoft.Cdn/profiles.endpoints/origins"
},
"customDomains": {
"profiles": {
"type": "object",
"properties": {
"type": {
"enum": [
"Microsoft.Cdn/profiles"
]
},
"apiVersion": {
"enum": [
"2016-04-02"
]
},
"location": {
"type": "string",
"description": "Profile location"
},
"tags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Profile tags"
},
"sku": {
"$ref": "#/definitions/Sku",
"description": "The SKU (pricing tier) of the CDN profile."
}
},
"required": [
"type",
"apiVersion",
"properties",
"location",
"sku"
],
"description": "Microsoft.Cdn/profiles"
}
},
"definitions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Microsoft.Storage/storageAccounts"
]
},
"apiVersion": {
"type": "string",
"enum": [
"2016-01-01"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Rest.Generator.AzureResourceSchema;
using Xunit;

namespace AutoRest.Generator.AzureResourceSchema.Tests
{
public class JSONSchemaTests
{
[Fact]
public void AddProperty()
{
JSONSchema schema = new JSONSchema();
JSONSchema age = new JSONSchema()
{
Type = "number"
};
schema.AddProperty("age", age);
Assert.Same(age, schema.Properties["age"]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="JSONSchema.cs" />
<Compile Include="SchemaProperty.cs" />
<Compile Include="Definition.cs" />
<Compile Include="ResourceProperty.cs" />
Expand Down
Loading

0 comments on commit c4c32d2

Please sign in to comment.