Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ env:
- MODE=main
install:
# Install runtime
- |-
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
sudo apt-get update
sudo apt-get install dotnet-dev-1.0.0-rc4-004769 -y
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install 7.10.0
- npm install -g npm@'>=5.4.0'
# Install dotnet 2.0.0 according to https://www.microsoft.com/net/core#linuxubuntu
- curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
- sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
- sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
- sudo apt-get update
- sudo apt-get install dotnet-sdk-2.0.0 -y
script:
- npm install
- ./node_modules/gulp/bin/gulp.js
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.8
Released on 2017-08-10.
- Updating to use AutoRest 2. This solves [#105](https://github.com/Azure/openapi-diff/issues/105)

## 0.1.7
Released on 2017-08-10.
- Chaining the promises upto `compare` method and gracefully exiting application [#88](https://github.com/Azure/openapi-diff/issues/88)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### How to install
```
npm install -g oad@0.1.7
npm install -g oad@0.1.8
```

### Command Usage
Expand All @@ -25,13 +25,13 @@ Options:
```

## Build dependencies
- [Node](https://nodejs.org) (6.9.5 or higher)
- [Node](https://nodejs.org) (7.10.0 or higher)
- [Node Package Manager](https://www.npmjs.com/package/npm)
- [.NET CLI tools](https://github.com/dotnet/cli#installers-and-binaries) build -004812 or later (after 02/14/2017)
- [.NET CLI tools](https://github.com/dotnet/cli/releases) version 2.0.0 or higher
> You want the **.NET Core SDK Binaries** for your platform <br>
>
> `dotnet --version ` <br>
> ` 1.0.0-rc4-004769 ` <br>
> ` 2.0.2 ` <br>

## Build scripts
### How to build
Expand Down
21 changes: 6 additions & 15 deletions lib/validators/openApiDiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class OpenApiDiff {
* @param {object} options The configuration options.
*
* @param {boolean} [options.json] A boolean flag indicating whether output format of the messages is json.
*
*
* @param {boolean} [options.matchApiVersion] A boolean flag indicating whether to consider api-version while comparing.
*
* @returns {object} OpenApiDiff Returns the configured OpenApiDiff object.
Expand Down Expand Up @@ -72,18 +72,7 @@ class OpenApiDiff {
dotNetPath() {
log.silly(`dotNetPath is being called`);

// try global installation directory
let result = path.join(os.homedir(), ".autorest", "frameworks", "dotnet");
if (fs.existsSync(result)) {
return result;
}

result = path.join(os.homedir(), ".autorest", "frameworks", "dotnet.exe");
if (fs.existsSync(result)) {
return result;
}

// hope there is one in the PATH
// Assume that dotnet is in the PATH
return "dotnet";
}

Expand All @@ -97,13 +86,15 @@ class OpenApiDiff {

// When oad is installed globally
let result = path.join(__dirname, "..", "..", "node_modules", "autorest", "app.js");
if (fs.existsSync(result))
if (fs.existsSync(result)) {
return `node ${result}`;
}

// When oad is installed locally
result = path.join(__dirname, "..", "..", "..", "autorest", "app.js");
if (fs.existsSync(result))
if (fs.existsSync(result)) {
return `node ${result}`;
}

// Assume that autorest is in the path
return 'autorest';
Expand Down
6 changes: 0 additions & 6 deletions openapi-diff/src/common/package-fallback.proj

This file was deleted.

2 changes: 1 addition & 1 deletion openapi-diff/src/common/project-library.proj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project ToolsVersion="15.0">
<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
9 changes: 4 additions & 5 deletions openapi-diff/src/common/project-xunittest.proj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project ToolsVersion="15.0">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.0.0" />
<!-- <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" /> -->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20161123-03" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta4-build1194" />
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
<PackageReference Include="xunit" Version="2.3.0" />
</ItemGroup>
</Project>
16 changes: 5 additions & 11 deletions openapi-diff/src/core/OpenApiDiff.Core/OpenApiDiff.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,25 @@
<Import Project="$(common)common-package-references.proj" />
<Import Project="$(common)project-library.proj" />
<Import Project="$(common)package-info.proj" />
<Import Project="$(common)package-fallback.proj" />


<PropertyGroup>
<AssemblyName>OpenApiDiff.Core</AssemblyName>
<PackageTags>Microsoft AutoRest</PackageTags>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Extensibility\**" />
<EmbeddedResource Remove="Extensibility\**" />
<None Remove="Extensibility\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="YamlDotNet.Signed" Version="3.8.0" />
<PackageReference Include="YamlDotNet.Signed" Version="4.2.2" />
<PackageReference Include="System.Net.Http" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="AutoRest.Swagger">
<HintPath>..\..\modeler\AutoRest.Swagger\bin\Debug\netstandard1.3\AutoRest.Swagger.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down
10 changes: 4 additions & 6 deletions openapi-diff/src/core/OpenApiDiff/OpenApiDiff.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), common/common.proj ))/common/common.proj" />
<Import Project="$(common)common-package-references.proj" />
<Import Project="$(common)package-info.proj" />
<Import Project="$(common)package-fallback.proj" />


<PropertyGroup>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to move this also to netstandard2.0 if we can

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For exe type we cannot use netstandard2.0 ( intended only for libraries). Since we are using this dill like an executable we need to stay to netcoreapp2.0

<AssemblyName>OpenApiDiff</AssemblyName>
<PackageTags>Microsoft OpenApiDiff</PackageTags>
<Version>0.1.0</Version>
Expand All @@ -19,7 +17,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), common/common.proj ))/common/common.proj" />
<Import Project="$(common)copy-resource-to-output.proj" />
<Import Project="$(common)package-fallback.proj" />
<Import Project="$(common)project-xunittest.proj" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -86,11 +84,11 @@
<Content Include="Resource\Swagger\old\version_check_03.json" />
<Content Include="Resource\Swagger\old\version_check_04.json" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(SolutionDir)src/modeler/AutoRest.Swagger/AutoRest.Swagger.csproj" />
<ProjectReference Include="..\..\core\OpenApiDiff.Core\OpenApiDiff.Core.csproj" />
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
namespace AutoRest.Swagger.Tests
{
/// <summary>
/// This class contains tests for the logic comparing two swagger specifications,
/// This class contains tests for the logic comparing two swagger specifications,
/// an older version against newer version.
///
/// For all but the tests that verify that version checks are done properly, the
///
/// For all but the tests that verify that version checks are done properly, the
/// old and new specifications have the same version number, which should force
/// the comparison logic to produce errors rather than warnings for each breaking
/// change.
///
///
/// Non-breaking changes are always presented as informational messages, regardless
/// of whether the version has changed or not.
/// </summary>
Expand Down Expand Up @@ -169,10 +169,10 @@ public void PathRemoved()
/// </summary>
[Fact]
public void OperationRemoved()
{
{
var messages = CompareSwagger("removed_operation.json").ToArray();
var missing = messages.Where(m => m.Id == ComparisonMessages.RemovedOperation.Id);
Assert.Equal(1, missing.Count());
Assert.Single(missing);
Assert.NotEmpty(missing.Where(m => m.Severity == Category.Error && m.Path.ReadablePath == "#/paths/api/Operations"));
}

Expand All @@ -197,11 +197,11 @@ public void AddedPaths()
{
var messages = CompareSwagger("added_path.json").ToArray();
var missing = messages.Where(m => m.Id == ComparisonMessages.AddedPath.Id);
Assert.Equal(1, missing.Count());
Assert.Single(missing);
Assert.NotEmpty(missing.Where(m => m.Severity == Category.Info && m.Path.ReadablePath == "#/paths/api/Paths"));

missing = messages.Where(m => m.Id == ComparisonMessages.AddedOperation.Id);
Assert.Equal(1, missing.Count());
Assert.Single(missing);
Assert.NotEmpty(missing.Where(m => m.Severity == Category.Info && m.Path.ReadablePath == "#/paths/api/Operations/post"));
}

Expand All @@ -213,7 +213,7 @@ public void RequiredParameterRemoved()
{
var messages = CompareSwagger("required_parameter.json").ToArray();
var missing = messages.Where(m => m.Id == ComparisonMessages.RemovedRequiredParameter.Id);
Assert.Equal(1, missing.Count());
Assert.Single(missing);
Assert.NotEmpty(missing.Where(m => m.Severity == Category.Error && m.Path.ReadablePath == "#/paths/api/Parameters/{a}/get/f"));
}

Expand Down Expand Up @@ -253,7 +253,7 @@ public void RequiredParameterAdded()
{
var messages = CompareSwagger("required_parameter.json").ToArray();
var missing = messages.Where(m => m.Id == ComparisonMessages.AddingRequiredParameter.Id);
Assert.Equal(1, missing.Count());
Assert.Single(missing);
Assert.NotEmpty(missing.Where(m => m.Severity == Category.Error && m.Path.ReadablePath == "#/paths/api/Parameters/{a}/get/g"));
}

Expand All @@ -265,7 +265,7 @@ public void ReadonlyPropertyInResponse()
{
var messages = CompareSwagger("readonly_changes.json").ToArray();
var missing = messages.Where(m => m.Id == ComparisonMessages.AddedReadOnlyPropertyInResponse.Id);
Assert.Equal(1, missing.Count());
Assert.Single(missing);
Assert.NotEmpty(missing.Where(m => m.Severity == Category.Info && m.Path.ReadablePath == "#/paths/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability/post/200/properties"));
}

Expand All @@ -277,13 +277,14 @@ public void AddedPropertyInResponse()
{
var messages = CompareSwagger("added_property_in_response.json").ToArray();
var missing = messages.Where(m => m.Id == ComparisonMessages.AddedPropertyInResponse.Id);
Assert.Equal(1, missing.Count());
Assert.Single(missing);
Assert.NotEmpty(missing.Where(m => m.Severity == Category.Error && m.Path.ReadablePath == "#/paths/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability/post/200/properties"));
}

/// <summary>
/// Verifies that rules work on the recurive models
/// </summary>
[Fact]
public void RecursiveModels()
{
var messages = CompareSwagger("recursive_model.json").ToArray();
Expand Down Expand Up @@ -330,7 +331,7 @@ public void ParameterStatusLess()
{
var messages = CompareSwagger("required_parameter.json").ToArray();
var missing = messages.Where(m => m.Id == ComparisonMessages.RequiredStatusChange.Id);
Assert.Equal(1, missing.Count());
Assert.Single(missing);
Assert.NotEmpty(missing.Where(m => m.Severity == Category.Error && m.Path.ReadablePath == "#/paths/api/Parameters/{a}/get/e"));
}

Expand Down Expand Up @@ -443,7 +444,7 @@ public void ResponseSchemaChanged()
{
var messages = CompareSwagger("operation_check_02.json").ToArray();
var removed = messages.Where(m => m.Id == ComparisonMessages.TypeChanged.Id && m.Path.JsonReference.Contains("Responses")).ToArray();
Assert.Equal(1, removed.Length);
Assert.Single(removed);
Assert.Equal(Category.Error, removed[0].Severity);
Assert.Equal("#/paths/~1api~1Responses/get/400/properties/id", removed[0].Path.JsonReference);
}
Expand All @@ -456,7 +457,7 @@ public void ResponseHeaderAdded()
{
var messages = CompareSwagger("operation_check_03.json").ToArray();
var added = messages.Where(m => m.Id == ComparisonMessages.AddingHeader.Id).ToArray();
Assert.Equal(1, added.Length);
Assert.Single(added);
Assert.Equal(Category.Info, added[0].Severity);
Assert.Equal("#/paths/~1api~1Responses/get/200/x-c", added[0].Path.JsonReference);
}
Expand All @@ -469,7 +470,7 @@ public void ResponseHeaderRemoved()
{
var messages = CompareSwagger("operation_check_03.json").ToArray();
var removed = messages.Where(m => m.Id == ComparisonMessages.RemovingHeader.Id).ToArray();
Assert.Equal(1, removed.Length);
Assert.Single(removed);
Assert.Equal(Category.Error, removed[0].Severity);
Assert.Equal("#/paths/~1api~1Responses/get/200/x-a", removed[0].Path.JsonReference);
}
Expand All @@ -482,7 +483,7 @@ public void ResponseHeaderTypeChanged()
{
var messages = CompareSwagger("operation_check_03.json").ToArray();
var changed = messages.Where(m => m.Id == ComparisonMessages.TypeChanged.Id && m.Path.JsonReference.Contains("Responses")).ToArray();
Assert.Equal(1, changed.Length);
Assert.Single(changed);
Assert.Equal(Category.Error, changed[0].Severity);
Assert.Equal("#/paths/~1api~1Responses/get/200/x-b", changed[0].Path.JsonReference);
}
Expand Down Expand Up @@ -647,7 +648,7 @@ public void GlobalResponseTypeConstraintsChanged()
public void RemovedPropertyTest()
{
var messages = CompareSwagger("removed_property.json").ToArray();
Assert.Equal(true, messages.Where(m => m.Id == ComparisonMessages.RemovedProperty.Id).Any());
Assert.True(messages.Where(m => m.Id == ComparisonMessages.RemovedProperty.Id).Any());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<Import Project="$(common)common-package-references.proj" />
<Import Project="$(common)project-library.proj" />
<Import Project="$(common)package-info.proj" />
<Import Project="$(common)package-fallback.proj" />


<PropertyGroup>
<AssemblyName>AutoRest.Swagger</AssemblyName>
<PackageTags>Microsoft AutoRest Generator Extensions</PackageTags>
Expand Down
2 changes: 1 addition & 1 deletion openapi-diff/src/modeler/AutoRest.Swagger/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="YamlDotNet.Signed" version="3.8.0" targetFramework="net45" />
<package id="YamlDotNet.Signed" version="4.2.2" targetFramework="net45" />
</packages>
Loading