Skip to content
Open
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
9 changes: 2 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,23 @@
{
"name": "C# (.NET)",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/dotnet:0-6.0",
"image": "mcr.microsoft.com/devcontainers/dotnet:0-8.0",
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5001],
// "portsAttributes": {
// "5001": {
// "protocol": "https"
// }
// }

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "dotnet restore",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
}
8 changes: 1 addition & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
env:
nuget_directory: ${{ github.workspace}}/artifacts


jobs:
create:
runs-on: ubuntu-latest
Expand All @@ -17,14 +16,13 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
- name: Build
run: dotnet build -c Release
- name: Pack
run: dotnet pack -c Release -o ${{ env.nuget_directory }}
- name: Display created package files
run: ls -R ${{ env.nuget_directory }}
run: ls -R ${{ env.nuget_directory }}
- uses: actions/upload-artifact@v4
if: always()
with:
Expand All @@ -45,7 +43,3 @@ jobs:
run: ls -R ${{ env.nuget_directory }}
- name: Publish all packages to NuGet
run: dotnet nuget push ${{ env.nuget_directory }}/*.nupkg --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate




1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
- name: Build
run: dotnet build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ obj

# NUnit
Criteo.OpenApi.Comparator.sln.DotSettings.user
/.vs/Criteo.OpenApi.Comparator
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ dotnet add package Criteo.OpenApi.Comparator

Here is an example of how to use the Comparator:
```C#
var differences = OpenApiComparator.Compare(
var result = OpenApiComparator.Compare(
out var differences,
oldOpenApiSpec,
newOpenApiSpec
);
Expand Down Expand Up @@ -50,6 +51,33 @@ Each comparison rule is documented in the [documentation section](https://github

Internally, the comparator uses [microsoft/OpenAPI.NET](https://github.com/microsoft/OpenAPI.NET/) which currently supports OpenAPI 2.0 to 3.0.0.

## Versions

### 1.0
- Made breaking changes to support that additive changes are allowed by default
- Compare now returns a Change level that reflects the result or all found changes.
- Removed strict mode.
- When not in strict mode there were very few errors in previous versions
- A major version update in the spec is now considered an Breaking rule in that your API can intentionally change.
- Combined the Parsing Errors with the Comparsion Messages
- On the message itself a code will now always uniquely identify the message severity
- Severity now includes a Breaking severity
- Split up several Code so that they are easier to identify and customize
- ConstrantIsStronger
- ResponseConstraintIsStronger
- EnumConstrantIsStronger
- AddedPropertyInResponse
- AddedBreakingPropertyInResponse
- ConstraintChanged
- EnumConstraintChanged
- MultipleOfConstraintChanged
- UniqueItemsConstraintChanged
- Added new Codes
- MajorVersionChange
- MinorVersionChange
- NonSemanticVersion
- Removed .NET 6 support as its no longer supported by Microsoft

## Contributing

Any contribution is more than welcomed. For now, no specific rule must be applied to contribute, just create an Issue or a Pull Request and we'll try to handle it ASAP.
Expand Down
35 changes: 0 additions & 35 deletions documentation/rules/1002.md

This file was deleted.

3 changes: 2 additions & 1 deletion documentation/rules/1041.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

**Description**: Checks whether a property is added to the response model from the previous specification.

**Cause**: This is considered a breaking change.
**Cause**: This is considered a regular change. This is a warning in that legacy serializers can have issues but shouldn't. According to the spec the default value for


**Example**: Property `petType` is being added into a response model in the new version.

Expand Down
7 changes: 4 additions & 3 deletions documentation/rules/1045.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Description**: Checks whether a property is added to the model from the previous specification. The model includes all the models that referenced by any request or response.

**Cause**: This is considered a breaking change.
**Cause**: This is considered a breaking change if it is a required property on a request.

**Example**: Not requiered property `age` is being added into the `User` schema.

Expand Down Expand Up @@ -34,11 +34,12 @@ New specification
```json5
{
"components": {
"shema": {
"schemas": {
"User": {
"type": "object",
"required": [
"name"
"name",
"age"
],
"properties": {
"name": {
Expand Down
33 changes: 33 additions & 0 deletions documentation/rules/1049.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### 1049 - NonSemanticVersion

**Description**: Checks whether the version number follows semantic conventions. https://spec.openapis.org/oas/latest.html#versions

**Cause**: If the schema is not in the format Major.Minor.Patch. Valid Examples 1.0.0, 1.0.0-alpha

**Example**: Version is missing minor and patch in the new spec.

Old specification
```json5
{
"openapi": "3.0.2",
"info": {
"title": "New API",
"version": "1.0.0",
"description": "A brand new API with no content. Go nuts!"
},
"paths": {}
}
```

New specification
```json5
{
"openapi": "3.0.2",
"info": {
"title": "New API",
"version": "2",
"description": "A brand new API with no content. Go nuts!"
},
"paths": {}
}
```
32 changes: 32 additions & 0 deletions documentation/rules/1050.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
### 1050 - MajorVersionChange

**Description**: A major version change. This signifies breaking changes may be made. https://spec.openapis.org/oas/latest.html#versions

**Example**: Version is incremented in the new spec.

Old specification
```json5
{
"openapi": "3.0.2",
"info": {
"title": "New API",
"version": "1.0.0",
"description": "A brand new API with no content. Go nuts!"
},
"paths": {}
}
```

New specification
```json5

{
"openapi": "3.0.2",
"info": {
"title": "New API",
"version": "2.0.0",
"description": "A brand new API with no content. Go nuts!"
},
"paths": {}
}
```
32 changes: 32 additions & 0 deletions documentation/rules/1051.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
### 1051 - MinorVersionChange

**Description**: A minor version change. This signifies additive changes or occasionally, non-backwards compatible changes may be made in minor version where impact is believed to be low relative to the benefit provided. https://spec.openapis.org/oas/latest.html#versions

**Example**: Version is incremented in the new spec.

Old specification
```json5
{
"openapi": "3.0.2",
"info": {
"title": "New API",
"version": "1.0.0",
"description": "A brand new API with no content. Go nuts!"
},
"paths": {}
}
```

New specification
```json5

{
"openapi": "3.0.2",
"info": {
"title": "New API",
"version": "1.1.0",
"description": "A brand new API with no content. Go nuts!"
},
"paths": {}
}
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net8;</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<OutputType>Exe</OutputType>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
Expand All @@ -15,7 +15,7 @@
<Authors>Criteo</Authors>
<Company>Criteo</Company>
<Copyright>Copyright (c) Criteo Technology. All rights reserved.</Copyright>
<Version>0.8.3</Version>
<Version>1.0.0</Version>
<PackageProjectUrl>https://github.com/criteo/openapi-comparator</PackageProjectUrl>
<RepositoryUrl>https://github.com/criteo/openapi-comparator</RepositoryUrl>
<PackageTags>Criteo, OpenApi, OpenApi-Comparator, OpenApi-Diff, Swagger</PackageTags>
Expand Down
Loading