├── .gitattributes
├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .markdownlint.jsonc
├── .prettierignore
├── .prettierrc
├── .vscode
├── launch.json
├── settings.json
└── tasks.json
├── CHANGELOG.md
├── CONTRIBUTING.md
├── CredScanSuppressions.json
├── LICENSE
├── README.md
├── SECURITY.md
├── azure-pipelines.yml
├── docs
├── README.md
└── rules
│ ├── 1000.md
│ ├── 1001.md
│ ├── 1002.md
│ ├── 1003.md
│ ├── 1004.md
│ ├── 1005.md
│ ├── 1006.md
│ ├── 1007.md
│ ├── 1008.md
│ ├── 1009.md
│ ├── 1010.md
│ ├── 1011.md
│ ├── 1012.md
│ ├── 1013.md
│ ├── 1014.md
│ ├── 1015.md
│ ├── 1016.md
│ ├── 1017.md
│ ├── 1019.md
│ ├── 1020.md
│ ├── 1021.md
│ ├── 1022.md
│ ├── 1023.md
│ ├── 1024.md
│ ├── 1025.md
│ ├── 1026.md
│ ├── 1027.md
│ ├── 1028.md
│ ├── 1029.md
│ ├── 1030.md
│ ├── 1031.md
│ ├── 1032.md
│ ├── 1033.md
│ ├── 1034.md
│ ├── 1035.md
│ ├── 1036.md
│ ├── 1037.md
│ ├── 1038.md
│ ├── 1039.md
│ ├── 1040.md
│ ├── 1041.md
│ ├── 1042.md
│ ├── 1043.md
│ ├── 1044.md
│ ├── 1045.md
│ ├── 1046.md
│ ├── 1047.md
│ ├── 1048.md
│ ├── 1049.md
│ └── 1050.md
├── eng
├── 1es-redirect.yml
├── image.yml
├── publish-1es-artifact.yml
├── scripts
│ └── determine-release-tag.ps1
└── test-steps.yml
├── eslint.config.js
├── openapi-diff
├── OpenApiDiff.sln
├── src
│ ├── common
│ │ ├── common-package-references.proj
│ │ ├── common.proj
│ │ ├── copy-resource-to-output.proj
│ │ ├── enumerate-inputs.proj
│ │ ├── package-info.proj
│ │ ├── project-library.proj
│ │ └── project-xunittest.proj
│ ├── core
│ │ ├── OpenApiDiff.Core
│ │ │ ├── JsonDocument.cs
│ │ │ ├── Logging
│ │ │ │ ├── LogMessageSeverity.cs
│ │ │ │ └── ObjectPath.cs
│ │ │ ├── OpenApiDiff.Core.csproj
│ │ │ ├── Properties
│ │ │ │ ├── Resources.Designer.cs
│ │ │ │ └── Resources.resx
│ │ │ ├── Settings.cs
│ │ │ ├── SettingsAliasAttribute.cs
│ │ │ └── SettingsInfoAttribute.cs
│ │ └── OpenApiDiff
│ │ │ ├── HelpExample.cs
│ │ │ ├── HelpGenerator.cs
│ │ │ ├── OpenApiDiff.csproj
│ │ │ ├── Program.cs
│ │ │ └── Properties
│ │ │ ├── Resources.Designer.cs
│ │ │ └── Resources.resx
│ └── modeler
│ │ ├── AutoRest.Swagger.Tests
│ │ ├── AutoRest.Swagger.Tests.csproj
│ │ ├── Resource
│ │ │ └── Swagger
│ │ │ │ ├── new
│ │ │ │ ├── add_optional_property_01.json
│ │ │ │ ├── added_optional_property.json
│ │ │ │ ├── added_path.json
│ │ │ │ ├── added_property_in_response.json
│ │ │ │ ├── added_readonly_required_property.json
│ │ │ │ ├── added_required_property.json
│ │ │ │ ├── changed_operation_id.json
│ │ │ │ ├── common_parameter_check_01.json
│ │ │ │ ├── common_parameter_check_02.json
│ │ │ │ ├── common_parameter_check_03.json
│ │ │ │ ├── common_parameter_check_04.json
│ │ │ │ ├── default_changed_01.json
│ │ │ │ ├── enum_as_string.json
│ │ │ │ ├── enum_values_changed.json
│ │ │ │ ├── format_check_01.json
│ │ │ │ ├── format_check_02.json
│ │ │ │ ├── global_parameter_no_order_change.json
│ │ │ │ ├── global_parameter_order_change.json
│ │ │ │ ├── long_running_operation.json
│ │ │ │ ├── misc_checks_01.json
│ │ │ │ ├── misc_checks_02.json
│ │ │ │ ├── missing_operation_id.json
│ │ │ │ ├── operation_check_01.json
│ │ │ │ ├── operation_check_02.json
│ │ │ │ ├── operation_check_03.json
│ │ │ │ ├── operation_check_04.json
│ │ │ │ ├── operation_check_05.json
│ │ │ │ ├── optional_parameter.json
│ │ │ │ ├── param_check_01.json
│ │ │ │ ├── parameter_location_change.json
│ │ │ │ ├── parameter_order_change.json
│ │ │ │ ├── property_required_status_changed.json
│ │ │ │ ├── readonly_changes.json
│ │ │ │ ├── recursive_model.json
│ │ │ │ ├── removed_definition.json
│ │ │ │ ├── removed_operation.json
│ │ │ │ ├── removed_operation_id.json
│ │ │ │ ├── removed_parameter.json
│ │ │ │ ├── removed_path.json
│ │ │ │ ├── removed_property.json
│ │ │ │ ├── required_parameter.json
│ │ │ │ ├── response_check_01.json
│ │ │ │ ├── type_changed.json
│ │ │ │ ├── type_changed_01.json
│ │ │ │ ├── version_check_01.json
│ │ │ │ ├── version_check_02.json
│ │ │ │ ├── version_check_03.json
│ │ │ │ ├── version_check_04.json
│ │ │ │ ├── xms_client_name_changed.json
│ │ │ │ ├── xms_enum_added.json
│ │ │ │ └── xms_enum_changed.json
│ │ │ │ └── old
│ │ │ │ ├── add_optional_property_01.json
│ │ │ │ ├── added_optional_property.json
│ │ │ │ ├── added_path.json
│ │ │ │ ├── added_property_in_response.json
│ │ │ │ ├── added_readonly_required_property.json
│ │ │ │ ├── added_required_property.json
│ │ │ │ ├── changed_operation_id.json
│ │ │ │ ├── common_parameter_check_01.json
│ │ │ │ ├── common_parameter_check_02.json
│ │ │ │ ├── common_parameter_check_03.json
│ │ │ │ ├── common_parameter_check_04.json
│ │ │ │ ├── default_changed_01.json
│ │ │ │ ├── enum_as_string.json
│ │ │ │ ├── enum_values_changed.json
│ │ │ │ ├── format_check_01.json
│ │ │ │ ├── format_check_02.json
│ │ │ │ ├── global_parameter_no_order_change.json
│ │ │ │ ├── global_parameter_order_change.json
│ │ │ │ ├── long_running_operation.json
│ │ │ │ ├── misc_checks_01.json
│ │ │ │ ├── misc_checks_02.json
│ │ │ │ ├── missing_operation_id.json
│ │ │ │ ├── operation_check_01.json
│ │ │ │ ├── operation_check_02.json
│ │ │ │ ├── operation_check_03.json
│ │ │ │ ├── operation_check_04.json
│ │ │ │ ├── operation_check_05.json
│ │ │ │ ├── optional_parameter.json
│ │ │ │ ├── param_check_01.json
│ │ │ │ ├── parameter_location_change.json
│ │ │ │ ├── parameter_order_change.json
│ │ │ │ ├── property_required_status_changed.json
│ │ │ │ ├── readonly_changes.json
│ │ │ │ ├── recursive_model.json
│ │ │ │ ├── removed_definition.json
│ │ │ │ ├── removed_operation.json
│ │ │ │ ├── removed_operation_id.json
│ │ │ │ ├── removed_parameter.json
│ │ │ │ ├── removed_path.json
│ │ │ │ ├── removed_property.json
│ │ │ │ ├── required_parameter.json
│ │ │ │ ├── response_check_01.json
│ │ │ │ ├── type_changed.json
│ │ │ │ ├── type_changed_01.json
│ │ │ │ ├── version_check_01.json
│ │ │ │ ├── version_check_02.json
│ │ │ │ ├── version_check_03.json
│ │ │ │ ├── version_check_04.json
│ │ │ │ ├── xms_client_name_changed.json
│ │ │ │ ├── xms_enum_added.json
│ │ │ │ └── xms_enum_changed.json
│ │ ├── SwaggerModelerCompareTests.cs
│ │ ├── app.config
│ │ └── packages.config
│ │ └── AutoRest.Swagger
│ │ ├── AutoRest.Swagger.csproj
│ │ ├── ComparisonContext.cs
│ │ ├── ComparisonMessage.cs
│ │ ├── ComparisonMessages.cs
│ │ ├── JsonComparisonMessage.cs
│ │ ├── JsonLocation.cs
│ │ ├── MessageTemplate.cs
│ │ ├── MessageType.cs
│ │ ├── Model
│ │ ├── ApiKeyLocation.cs
│ │ ├── DataType.cs
│ │ ├── ExternalDoc.cs
│ │ ├── Header.cs
│ │ ├── Info.cs
│ │ ├── OAuthFlow.cs
│ │ ├── Operation.cs
│ │ ├── ParameterLocation.cs
│ │ ├── Response.cs
│ │ ├── Schema.cs
│ │ ├── SecurityDefinition.cs
│ │ ├── SecuritySchemeType.cs
│ │ ├── ServiceDefinition.cs
│ │ ├── ServiceDefinitionMetadata.cs
│ │ ├── SpecObject.cs
│ │ ├── SwaggerBase.cs
│ │ ├── SwaggerObject.cs
│ │ ├── SwaggerParameter.cs
│ │ ├── TransferProtocolScheme.cs
│ │ └── XmsEnumExtension.cs
│ │ ├── PathLevelParameterConverter.cs
│ │ ├── Properties
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ │ ├── SwaggerModeler.cs
│ │ ├── SwaggerParser.cs
│ │ └── packages.config
└── tools
│ └── MSSharedLibKey.snk
├── package-lock.json
├── package.json
├── src
├── cli.ts
├── index.ts
├── lib
│ ├── commands
│ │ └── oad.ts
│ ├── util
│ │ ├── constants.ts
│ │ ├── logging.ts
│ │ ├── resolveSwagger.ts
│ │ └── utils.ts
│ ├── validate.ts
│ └── validators
│ │ └── openApiDiff.ts
└── test
│ ├── additionalPropertiesIsBooleanTest.ts
│ ├── commonParametersTest.ts
│ ├── compatiblePropertiesTest.ts
│ ├── expandsAllOfFullCoversTest.ts
│ ├── expandsAllOfModelsTest.ts
│ ├── fileUrl.ts
│ ├── full2ReversedTest.ts
│ ├── full2Test.ts
│ ├── fullReversedTest.ts
│ ├── fullTest.ts
│ ├── incompatiblePropertiesTest.ts
│ ├── moveIntoAllOfModelsTest.ts
│ ├── multipleLevelAllOfTest.ts
│ ├── operationLocationTest.ts
│ ├── requestBodyFormatNoLongerSupportedTest.ts
│ ├── responseBodyFormatNowSupportedTest.ts
│ ├── simpleTest.ts
│ ├── someChangesTest.ts
│ ├── specs
│ ├── additional-properties
│ │ ├── new.json
│ │ └── old.json
│ ├── common-parameters
│ │ ├── new.json
│ │ └── old.json
│ ├── compatible-properties.json
│ ├── expandsAllOf
│ │ ├── new
│ │ │ ├── expand_allOf_model.json
│ │ │ ├── move_properties_into_allof_model.json
│ │ │ ├── multi_level_allOf.json
│ │ │ └── property_format_change.json
│ │ └── old
│ │ │ ├── expand_allOf_model.json
│ │ │ ├── move_properties_into_allof_model.json
│ │ │ ├── multi_level_allOf.json
│ │ │ └── property_format_change.json
│ ├── full
│ │ ├── new
│ │ │ ├── openapi.json
│ │ │ ├── openapi2.json
│ │ │ └── readme.md
│ │ └── old
│ │ │ ├── openapi.json
│ │ │ └── readme.md
│ ├── full2
│ │ ├── source
│ │ │ ├── Microsoft.Compute
│ │ │ │ └── stable
│ │ │ │ │ └── 2017-12-01
│ │ │ │ │ ├── compute.json
│ │ │ │ │ └── runCommands.json
│ │ │ └── readme.md
│ │ └── target
│ │ │ ├── Microsoft.Compute
│ │ │ └── stable
│ │ │ │ └── 2018-04-01
│ │ │ │ ├── compute.json
│ │ │ │ ├── disk.json
│ │ │ │ └── runCommands.json
│ │ │ └── readme.md
│ ├── incompatible-properties
│ │ ├── refstring-object.json
│ │ ├── refstring-refobject.json
│ │ ├── string-object.json
│ │ └── string-refobject.json
│ ├── operation-location.json
│ ├── rule-1003
│ │ ├── case1.new.json
│ │ └── case1.old.json
│ ├── rule-1004
│ │ ├── case1.new.json
│ │ └── case1.old.json
│ ├── simple.json
│ ├── some-changes
│ │ ├── new.json
│ │ └── old.json
│ ├── xms-enum-name
│ │ ├── new.json
│ │ └── old.json
│ └── xmspath
│ │ ├── new.json
│ │ └── old.json
│ ├── utilTest.ts
│ ├── xmsEnumNameTest.ts
│ └── xmsPathTest.ts
└── tsconfig.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.bmp binary
2 | *.dll binary
3 | *.gif binary
4 | *.jpg binary
5 | *.png binary
6 | *.snk binary
7 | *.exe binary
8 | *.wmv binary
9 | *.mp4 binary
10 | *.ismv binary
11 | *.isma binary
12 |
13 | *.ascx text
14 | *.cmd text
15 | *.config text
16 | *.cs text diff=csharp
17 | *.csproj text merge=union
18 | *.edmx text
19 |
20 | *.htm text
21 | *.html text
22 |
23 | *.json text eol=lf
24 | *.ts text eol=lf
25 | *.js text eol=lf
26 |
27 | *.msbuild text
28 | *.nuspec text
29 |
30 | *.resx text
31 | *.ruleset text
32 | *.StyleCop text
33 | *.targets text
34 | *.txt text
35 | *.xml text
36 |
37 | *.sln text eol=crlf merge=union
38 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: ci
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | pull_request:
7 |
8 | jobs:
9 | ci:
10 | runs-on: ${{ matrix.os }}
11 | strategy:
12 | matrix:
13 | include:
14 | - os: ubuntu-latest
15 | target-folder: drop-linux
16 | - os: windows-latest
17 | target-folder: drop
18 |
19 | steps:
20 | - uses: actions/checkout@v4
21 |
22 | - uses: actions/setup-node@v4
23 | with:
24 | node-version: "20"
25 |
26 | - uses: actions/setup-dotnet@v4
27 | with:
28 | dotnet-version: "6"
29 |
30 | - name: npm ci
31 | run: npm ci
32 |
33 | - name: lint
34 | run: npm run lint
35 |
36 | - name: prettier
37 | run: npm run prettier
38 |
39 | - name: test
40 | run: npm test
41 |
--------------------------------------------------------------------------------
/.markdownlint.jsonc:
--------------------------------------------------------------------------------
1 | {
2 | // This repository is markdownlint-enabled.
3 | // Website: https://github.com/DavidAnson/markdownlint
4 | // VS Code extension: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
5 | //
6 | // The implicit, default set of rules is defined in:
7 | // https://github.com/DavidAnson/markdownlint/blob/v0.30.0/doc/Rules.md
8 |
9 | // MD013 - Line length
10 | // https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
11 | //
12 | // "line_length" : 120:
13 | // Allow lines of length 120 instead of the default 80. Keep in sync with guide lines .vscode/settings.json.
14 | //
15 | // "tables": false
16 | // Do not include tables. Breaking a line in a table to meet the line length would add a line break in the table
17 | // itself. We do not want that.
18 | //
19 | // "headings": false
20 | // Do not include headings. One cannot break lines in headings, and we sometimes need long ones, e.g. for FAQs.
21 | "MD013": { "line_length" : 120, "tables": false, "headings": false },
22 |
23 | // MD025 - Multiple top-level headings in the same document
24 | // https://github.com/DavidAnson/markdownlint/blob/main/doc/md025.md
25 | //
26 | // We like multiple top-headings.
27 | "MD025": false,
28 |
29 | // MD034 - Inline HTML
30 | // https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md
31 | //
32 | // Forbid using inline HTML elements except
. We use
within tables.
33 | "MD033": { "allowed_elements": ["br"]}
34 | }
35 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | *.json
2 | *.md
3 | *.jsonc
4 | .prettierrc
5 | azure-pipelines.yml
6 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": false,
3 | "printWidth": 140,
4 | "trailingComma": "none",
5 | "arrowParens": "avoid"
6 | }
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | // Use IntelliSense to find out which attributes exist for C# debugging
6 | // Use hover for the description of the existing attributes
7 | // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/openapi-diff/src/core/OpenApiDiff/bin/Debug/netcoreapp6.0/OpenApiDiff.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}/openapi-diff/src/core/OpenApiDiff",
16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17 | "console": "internalConsole",
18 | "stopAtEntry": false
19 | },
20 | {
21 | "name": ".NET Core Attach",
22 | "type": "coreclr",
23 | "request": "attach"
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | ],
4 | "azure-pipelines.1ESPipelineTemplatesSchemaFile": true
5 | }
6 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/openapi-diff/OpenApiDiff.sln",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary;ForceNoAlign"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/openapi-diff/OpenApiDiff.sln",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary;ForceNoAlign"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "--project",
36 | "${workspaceFolder}/openapi-diff/OpenApiDiff.sln"
37 | ],
38 | "problemMatcher": "$msCompile"
39 | }
40 | ]
41 | }
42 |
--------------------------------------------------------------------------------
/CredScanSuppressions.json:
--------------------------------------------------------------------------------
1 | {
2 | "tool": "Credential Scanner",
3 | "suppressions": [
4 | {
5 | "file": "node_modules\\superagent\\docs\\index.md",
6 | "_justification": "Additional CredScan searcher specific to my team"
7 | },
8 | {
9 | "file": "node_modules\\superagent\\docs\\test.html",
10 | "_justification": "Legitimate UT certificate file with private key"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation. All rights reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # About openapi-diff
2 |
3 | [![Build Status][build status]][build pipeline]
4 |
5 | This repository contains source code of `openapi-diff` aka `oad` aka "Breaking change detector tool" npm package.
6 | This package is invoked internally by the [azure-rest-api-specs] and [azure-rest-api-specs-pr] repos
7 | `Swagger Breaking Change` and `Breaking Change(Cross-Version)` GitHub checks, validating PRs submitted to them.
8 |
9 | For description of the overall process of which `oad` is part of, see https://aka.ms/azsdk/specreview.
10 |
11 | [build status]: https://dev.azure.com/azure-sdk/public/_apis/build/status/public.openapi-diff?branchName=main
12 | [build pipeline]: https://dev.azure.com/azure-sdk/public/_build/latest?definitionId=135&branchName=main
13 | [azure-rest-api-specs]: https://github.com/Azure/azure-rest-api-specs
14 | [azure-rest-api-specs-pr]: https://github.com/Azure/azure-rest-api-specs-pr
15 |
16 | ## npm package
17 |
18 | - [@azure/oad] 
19 | - [package.json]
20 |
21 | > [!CAUTION]
22 | > Do not use the package [oad] . It is deprecated and obsolete.
23 |
24 | [@azure/oad]: https://www.npmjs.com/package/@azure/oad
25 | [package.json]: /package.json
26 | [oad]: https://www.npmjs.com/package/oad
27 |
28 | ## How to run locally
29 |
30 | See relevant section in [CONTRIBUTING.md](./CONTRIBUTING.md)
31 |
32 |
--------------------------------------------------------------------------------
/docs/rules/1000.md:
--------------------------------------------------------------------------------
1 | ### 1000 - VersionsReversed
2 |
3 | **Description**: Checks whether [semantic version](http://semver.org/) is reversed from the previous specification.
4 |
5 | **Cause**: This is considered an unexpected change.
6 |
7 | **Example**: Version is changed from `2.0.0` to `1.0.0`.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2.0.0",
17 | ...
18 | ```
19 |
20 | New specification
21 | ```json5
22 | {
23 | "swagger": "2.0",
24 | "info": {
25 | "title": "swagger",
26 | "description": "The Azure Management API.",
27 | "version": "1.0.0",
28 | ...
29 | ```
30 |
--------------------------------------------------------------------------------
/docs/rules/1001.md:
--------------------------------------------------------------------------------
1 | ### 1001 - NoVersionChange
2 |
3 | **Description**: Checks whether version is changed from the previous specification.
4 |
5 | **Cause**: This is considered an noteworthy change.
6 |
7 | **Example**: Version is changed from `2017-05-01` to `2017-07-01`.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2017-05-01",
17 | ...
18 | ```
19 |
20 | New specification
21 | ```json5
22 | {
23 | "swagger": "2.0",
24 | "info": {
25 | "title": "swagger",
26 | "description": "The Azure Management API.",
27 | "version": "2017-07-01",
28 | ...
29 | ```
30 |
--------------------------------------------------------------------------------
/docs/rules/1002.md:
--------------------------------------------------------------------------------
1 | ### 1002 - ProtocolNoLongerSupported
2 |
3 | **Description**: Checks whether any supported `scheme` is changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: `http` scheme is no longer supported in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | ...
15 | "scheme": [
16 | "http",
17 | "https"
18 | ]
19 | ```
20 |
21 | New specification
22 | ```json5
23 | {
24 | "swagger": "2.0",
25 | "info": {
26 | ...
27 | "scheme": [
28 | "https"
29 | ]
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/rules/1003.md:
--------------------------------------------------------------------------------
1 | ### 1003 - RequestBodyFormatNoLongerSupported
2 |
3 | **Description**: Checks whether any supported `consumes` is changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: `text/json` format for body is no longer supported in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | ...
15 | "scheme": [
16 | "https"
17 | ],
18 | "consumes":[
19 | "application/json",
20 | "text/json"
21 | ]
22 | ```
23 |
24 | New specification
25 | ```json5
26 | {
27 | "swagger": "2.0",
28 | "info": {
29 | ...
30 | "scheme": [
31 | "https"
32 | ],
33 | "consumes":[
34 | "application/json"
35 | ]
36 | ```
37 |
--------------------------------------------------------------------------------
/docs/rules/1004.md:
--------------------------------------------------------------------------------
1 | ### 1004 - ResponseBodyFormatNowSupported
2 |
3 | **Description**: Checks whether any additional supported `produces` is now supported from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: `text/json` format is now supported in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | ...
15 | "scheme": [
16 | "https"
17 | ],
18 | "produces":[
19 | "application/json"
20 | ]
21 | ```
22 |
23 | New specification
24 | ```json5
25 | {
26 | "swagger": "2.0",
27 | "info": {
28 | ...
29 | "scheme": [
30 | "https"
31 | ],
32 | "produces":[
33 | "application/json",
34 | "text/json"
35 | ]
36 | ```
37 |
--------------------------------------------------------------------------------
/docs/rules/1005.md:
--------------------------------------------------------------------------------
1 | ### 1005 - RemovedPath
2 |
3 | **Description**: Checks whether an existing path is removed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change. This change requires new api-version.
6 |
7 | **Example**: Path `/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1` is being removed without revising api-version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
21 | "get": {
22 | ...
23 | },
24 | "put": {
25 | ...
26 | }
27 | },
28 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
29 | "get": {
30 | ...
31 | },
32 | "delete": {
33 | ...
34 | }
35 | }
36 | ...
37 | ...
38 | ```
39 |
40 | New specification
41 | ```json5
42 | {
43 | "swagger": "2.0",
44 | "info": {
45 | "title": "swagger",
46 | "description": "The Azure Management API.",
47 | "version": "2016-12-01",
48 | ...
49 | ...
50 | "paths": {
51 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
52 | "get": {
53 | ...
54 | },
55 | "put": {
56 | ...
57 | }
58 | }
59 | ...
60 | ...
61 | ```
62 |
--------------------------------------------------------------------------------
/docs/rules/1008.md:
--------------------------------------------------------------------------------
1 | ### 1008 - ModifiedOperationId
2 |
3 | **Description**: Checks whether an existing operation's `operationId` is changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change. This change requires new api-version.
6 |
7 | **Example**: `operationId` of Operation `get` from Path `/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1` is being updated without revising api-version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
21 | "get": {
22 | ...
23 | "operationId": "GetResource1",
24 | ...
25 | },
26 | "put": {
27 | ...
28 | }
29 | }
30 | ...
31 | ...
32 | ```
33 |
34 | New specification
35 | ```json5
36 | {
37 | "swagger": "2.0",
38 | "info": {
39 | "title": "swagger",
40 | "description": "The Azure Management API.",
41 | "version": "2016-12-01",
42 | ...
43 | ...
44 | "paths": {
45 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
46 | "get": {
47 | ...
48 | "operationId": "ListResource1",
49 | ...
50 | },
51 | "put": {
52 | ...
53 | }
54 | }
55 | ...
56 | ...
57 | ```
58 |
--------------------------------------------------------------------------------
/docs/rules/1011.md:
--------------------------------------------------------------------------------
1 | ### 1011 - AddingResponseCode
2 |
3 | **Description**: Checks whether any new response code is added from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Response code `204` is added to existing `delete` operation in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/{a}": {
21 | "delete": {
22 | ...
23 | "responses": {
24 | "200" : { ... }
25 | }
26 | ...
27 | }
28 | }
29 | ...
30 | ...
31 | ```
32 |
33 | New specification
34 | ```json5
35 | {
36 | "swagger": "2.0",
37 | "info": {
38 | "title": "swagger",
39 | "description": "The Azure Management API.",
40 | "version": "2016-12-01",
41 | ...
42 | ...
43 | "paths": {
44 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/{a}": {
45 | "delete": {
46 | ...
47 | "responses": {
48 | "200" : { ... },
49 | "204" : { ... }
50 | }
51 | ...
52 | }
53 | }
54 | ...
55 | ...
56 | ```
57 |
--------------------------------------------------------------------------------
/docs/rules/1012.md:
--------------------------------------------------------------------------------
1 | ### 1012 - RemovedResponseCode
2 |
3 | **Description**: Checks whether any existing response code is removed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Response code `204` is removed from existing `delete` operation in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/{a}": {
21 | "delete": {
22 | ...
23 | "responses": {
24 | "200" : { ... },
25 | "204" : { ... }
26 | }
27 | ...
28 | }
29 | }
30 | ...
31 | ...
32 | ```
33 |
34 | New specification
35 | ```json5
36 | {
37 | "swagger": "2.0",
38 | "info": {
39 | "title": "swagger",
40 | "description": "The Azure Management API.",
41 | "version": "2016-12-01",
42 | ...
43 | ...
44 | "paths": {
45 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/{a}": {
46 | "delete": {
47 | ...
48 | "responses": {
49 | "200" : { ... }
50 | }
51 | ...
52 | }
53 | }
54 | ...
55 | ...
56 | ```
57 |
--------------------------------------------------------------------------------
/docs/rules/1013.md:
--------------------------------------------------------------------------------
1 | ### 1013 - AddingHeader
2 |
3 | **Description**: Checks whether any new header is added from the previous specification.
4 |
5 | **Cause**: This is considered a change.
6 |
7 | **Example**: Response code `200` adds header `x-c` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/{a}": {
21 | "delete": {
22 | ...
23 | "responses": {
24 | "200" : {
25 | ...
26 | "headers": {
27 | "x-a": { "type": "string" },
28 | "x-b": { "type": "integer" }
29 | }
30 | },
31 | "204" : { ... }
32 | }
33 | ...
34 | }
35 | }
36 | ...
37 | ...
38 | ```
39 |
40 | New specification
41 | ```json5
42 | {
43 | "swagger": "2.0",
44 | "info": {
45 | "title": "swagger",
46 | "description": "The Azure Management API.",
47 | "version": "2016-12-01",
48 | ...
49 | ...
50 | "paths": {
51 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/{a}": {
52 | "delete": {
53 | ...
54 | "responses": {
55 | "200" : {
56 | ...
57 | "headers": {
58 | "x-a": { "type": "string" },
59 | "x-b": { "type": "integer" },
60 | "x-c": { "type": "integer" }
61 | }
62 | },
63 | "204" : { ... }
64 | }
65 | ...
66 | }
67 | }
68 | ...
69 | ...
70 | ```
71 |
--------------------------------------------------------------------------------
/docs/rules/1014.md:
--------------------------------------------------------------------------------
1 | ### 1014 - RemovingHeader
2 |
3 | **Description**: Checks whether any existing header is removed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Response code `200` removed header `x-b` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/{a}": {
21 | "delete": {
22 | ...
23 | "responses": {
24 | "200" : {
25 | ...
26 | "headers": {
27 | "x-a": { "type": "string" },
28 | "x-b": { "type": "integer" }
29 | }
30 | },
31 | "204" : { ... }
32 | }
33 | ...
34 | }
35 | }
36 | ...
37 | ...
38 | ```
39 |
40 | New specification
41 | ```json5
42 | {
43 | "swagger": "2.0",
44 | "info": {
45 | "title": "swagger",
46 | "description": "The Azure Management API.",
47 | "version": "2016-12-01",
48 | ...
49 | ...
50 | "paths": {
51 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/{a}": {
52 | "delete": {
53 | ...
54 | "responses": {
55 | "200" : {
56 | ...
57 | "headers": {
58 | "x-a": { "type": "string" }
59 | }
60 | },
61 | "204" : { ... }
62 | }
63 | ...
64 | }
65 | }
66 | ...
67 | ...
68 | ```
69 |
--------------------------------------------------------------------------------
/docs/rules/1019.md:
--------------------------------------------------------------------------------
1 | ### 1019 - RemovedEnumValue
2 |
3 | **Description**: Checks whether an existing enum property has removed allowed values from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change. This change requires new api-version.
6 |
7 | **Example**: Enum Property `b` is removing allowed values without revising api-version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "CreateParameters": {
22 | "properties": {
23 | "a": {
24 | "type": "string",
25 | "description": "Required. Property a."
26 | },
27 | "b": {
28 | "type": "string",
29 | "description": "Required. Enum Property b.",
30 | "enum": [ "b1", "b2", "b3", "b4" ]
31 | }
32 | },
33 | "required": [
34 | "a"
35 | ],
36 | "description": "The parameters used when create operation."
37 | },
38 | ...
39 | ```
40 |
41 | New specification
42 | ```json5
43 | {
44 | "swagger": "2.0",
45 | "info": {
46 | "title": "swagger",
47 | "description": "The Azure Management API.",
48 | "version": "2016-12-01",
49 | ...
50 | ...
51 | "definitions": {
52 | ...
53 | "CreateParameters": {
54 | "properties": {
55 | "a": {
56 | "type": "string",
57 | "description": "Required. Property a."
58 | },
59 | "b": {
60 | "type": "string",
61 | "description": "Required. Enum Property b.",
62 | "enum": [ "b1", "b2", "b4" ]
63 | }
64 | },
65 | "required": [
66 | "a"
67 | ],
68 | "description": "The parameters used when create operation."
69 | },
70 | ...
71 | ```
72 |
--------------------------------------------------------------------------------
/docs/rules/1023.md:
--------------------------------------------------------------------------------
1 | ### 1023 - TypeFormatChanged
2 |
3 | **Description**: Checks whether any existing property's [format](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#dataTypeFormat) element has changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change in most cases except widening integer("int32" -> "int64") in request and narrowing integer ("int64" -> "int32") in response which are not breaking change in new api-version.
6 |
7 | **Example**: Property `a` of Parameter `CreateParameters` changed format from `int64` to `int32` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "CreateParameters": {
22 | "properties": {
23 | "a": {
24 | "type": "integer",
25 | "description": "Property a.",
26 | "format": "int64"
27 | },
28 | ...
29 | ```
30 |
31 | New specification
32 | ```json5
33 | {
34 | "swagger": "2.0",
35 | "info": {
36 | "title": "swagger",
37 | "description": "The Azure Management API.",
38 | "version": "2016-12-01",
39 | ...
40 | ...
41 | "definitions": {
42 | ...
43 | "CreateParameters": {
44 | "properties": {
45 | "a": {
46 | "type": "integer",
47 | "description": "Property a.",
48 | "format": "int32"
49 | },
50 | ...
51 | ```
52 |
--------------------------------------------------------------------------------
/docs/rules/1024.md:
--------------------------------------------------------------------------------
1 | ### 1024 - ConstraintIsStronger
2 |
3 | **Description**: Checks whether any constraining in requests like `maximum`, `minimum`, `minLength`, `maxLength` etc. has been stronger from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Value of `maxItems` element of parameter `a` is changed from `5000` to `4000` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/api/Responses": {
21 | "get": {
22 | "parameters": [
23 | {
24 | "name": "a",
25 | "in": "header",
26 | "type": "array",
27 | "minItems": 11,
28 | "maxItems": 5000,
29 | "collectionFormat": "pipes",
30 | "items": {
31 | "type": "integer",
32 | "minimum": 11,
33 | "maximum": 21,
34 | "multipleOf": 4
35 | }
36 | },
37 | ...
38 | ```
39 |
40 | New specification
41 | ```json5
42 | {
43 | "swagger": "2.0",
44 | "info": {
45 | "title": "swagger",
46 | "description": "The Azure Management API.",
47 | "version": "2016-12-01",
48 | ...
49 | ...
50 | "paths": {
51 | "/api/Responses": {
52 | "get": {
53 | "parameters": [
54 | {
55 | "name": "a",
56 | "in": "header",
57 | "type": "array",
58 | "minItems": 11,
59 | "maxItems": 4000,
60 | "collectionFormat": "pipes",
61 | "items": {
62 | "type": "integer",
63 | "minimum": 11,
64 | "maximum": 21,
65 | "multipleOf": 4
66 | }
67 | },
68 | ...
69 | ```
70 |
--------------------------------------------------------------------------------
/docs/rules/1026.md:
--------------------------------------------------------------------------------
1 | ### 1026 - TypeChanged
2 |
3 | **Description**: Checks whether an existing property has changed the type from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change. This change requires new api-version.
6 |
7 | **Example**: Property `b` is being changed from `string` to `boolean` without revising api-version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "CreateParameters": {
22 | "properties": {
23 | "a": {
24 | "type": "string",
25 | "description": "Required. Property a."
26 | },
27 | "b": {
28 | "type": "string",
29 | "description": "Required. Property b."
30 | }
31 | },
32 | "required": [
33 | "a",
34 | "b"
35 | ],
36 | "description": "The parameters used when create operation."
37 | },
38 | ...
39 | ```
40 |
41 | New specification
42 | ```json5
43 | {
44 | "swagger": "2.0",
45 | "info": {
46 | "title": "swagger",
47 | "description": "The Azure Management API.",
48 | "version": "2016-12-01",
49 | ...
50 | ...
51 | "definitions": {
52 | ...
53 | "CreateParameters": {
54 | "properties": {
55 | "a": {
56 | "type": "string",
57 | "description": "Required. Property a."
58 | },
59 | "b": {
60 | "type": "boolean",
61 | "description": "Required. Property b."
62 | }
63 | },
64 | "required": [
65 | "a",
66 | "b"
67 | ],
68 | "description": "The parameters used when create operation."
69 | },
70 | ...
71 | ```
72 |
--------------------------------------------------------------------------------
/docs/rules/1027.md:
--------------------------------------------------------------------------------
1 | ### 1027 - DefaultValueChanged
2 |
3 | **Description**: Checks whether any existing property's `default` element has changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Default value of property `a` of Parameter `CreateParameters` changed from `Standard` to `Premium` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "CreateParameters": {
22 | "properties": {
23 | "a": {
24 | "type": "string",
25 | "description": "Property a.",
26 | "default": "Standard"
27 | },
28 | ...
29 | ```
30 |
31 | New specification
32 | ```json5
33 | {
34 | "swagger": "2.0",
35 | "info": {
36 | "title": "swagger",
37 | "description": "The Azure Management API.",
38 | "version": "2016-12-01",
39 | ...
40 | ...
41 | "definitions": {
42 | ...
43 | "CreateParameters": {
44 | "properties": {
45 | "a": {
46 | "type": "string",
47 | "description": "Property a.",
48 | "default": "Premium"
49 | },
50 | ...
51 | ```
52 |
--------------------------------------------------------------------------------
/docs/rules/1028.md:
--------------------------------------------------------------------------------
1 | ### 1028 - ArrayCollectionFormatChanged
2 |
3 | **Description**: Checks whether array's `collectionFormat` has changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Value of `collectionFormat` element of property `a` of Parameter `CreateParameters` changed from `pipes` to `csv` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "CreateParameters": {
22 | "properties": {
23 | "a": {
24 | "type": "array",
25 | "description": "Property a.",
26 | "minItems": 11,
27 | "maxItems": 5000,
28 | "collectionFormat": "pipes",
29 | "items": {
30 | "type": "integer",
31 | "minimum": 11,
32 | "maximum": 21,
33 | "multipleOf": 4
34 | }
35 | },
36 | ...
37 | ```
38 |
39 | New specification
40 | ```json5
41 | {
42 | "swagger": "2.0",
43 | "info": {
44 | "title": "swagger",
45 | "description": "The Azure Management API.",
46 | "version": "2016-12-01",
47 | ...
48 | ...
49 | "definitions": {
50 | ...
51 | "CreateParameters": {
52 | "properties": {
53 | "a": {
54 | "type": "array",
55 | "description": "Property a.",
56 | "minItems": 11,
57 | "maxItems": 5000,
58 | "collectionFormat": "csv",
59 | "items": {
60 | "type": "integer",
61 | "minimum": 11,
62 | "maximum": 21,
63 | "multipleOf": 4
64 | }
65 | },
66 | ...
67 | ```
68 |
--------------------------------------------------------------------------------
/docs/rules/1030.md:
--------------------------------------------------------------------------------
1 | ### 1030 - DifferentDiscriminator
2 |
3 | **Description**: Checks whether value of `discriminator` has changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Value of `discriminator` element of Parameter `Pet` changed from `petType` to `name` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "Pet": {
22 | "type": "object",
23 | "discriminator": "petType",
24 | "properties": {
25 | "name": {
26 | "type": "string"
27 | },
28 | "petType": {
29 | "type": "string"
30 | }
31 | },
32 | "required": [
33 | "name",
34 | "petType"
35 | ]
36 | },
37 | ...
38 | ```
39 |
40 | New specification
41 | ```json5
42 | {
43 | "swagger": "2.0",
44 | "info": {
45 | "title": "swagger",
46 | "description": "The Azure Management API.",
47 | "version": "2016-12-01",
48 | ...
49 | ...
50 | "definitions": {
51 | ...
52 | "Pet": {
53 | "type": "object",
54 | "discriminator": "name",
55 | "properties": {
56 | "name": {
57 | "type": "string"
58 | },
59 | "petType": {
60 | "type": "string"
61 | }
62 | },
63 | "required": [
64 | "name",
65 | "petType"
66 | ]
67 | },
68 | ...
69 | ```
70 |
--------------------------------------------------------------------------------
/docs/rules/1031.md:
--------------------------------------------------------------------------------
1 | ### 1031 - DifferentExtends
2 |
3 | **Description**: Checks whether any model's extend has changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**:
8 |
9 | Old specification
10 | ```json5
11 |
12 | ```
13 |
14 | New specification
15 | ```json5
16 |
17 | ```
18 |
--------------------------------------------------------------------------------
/docs/rules/1032.md:
--------------------------------------------------------------------------------
1 | ### 1032 - DifferentAllOf
2 |
3 | **Description**: Checks whether any model's `allOf` has changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Value of `allOf` element of Parameter `Cat` changed from `#definitions/Pet` to `#definitions/CustomPet` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "Pet": {
22 | "type": "object",
23 | "discriminator": "petType",
24 | "properties": {
25 | "name": {
26 | "type": "string"
27 | },
28 | "petType": {
29 | "type": "string"
30 | }
31 | ...
32 | }
33 | },
34 | "Cat": {
35 | "allOf": [{
36 | "$ref": "#definitions/Pet"
37 | }],
38 | ...
39 | }
40 | ...
41 | ```
42 |
43 | New specification
44 | ```json5
45 | {
46 | "swagger": "2.0",
47 | "info": {
48 | "title": "swagger",
49 | "description": "The Azure Management API.",
50 | "version": "2016-12-01",
51 | ...
52 | ...
53 | "definitions": {
54 | ...
55 | "Pet": {
56 | "type": "object",
57 | "discriminator": "petType",
58 | "properties": {
59 | "name": {
60 | "type": "string"
61 | },
62 | "petType": {
63 | "type": "string"
64 | }
65 | ...
66 | }
67 | },
68 | "Cat": {
69 | "allOf": [{
70 | "$ref": "#definitions/CustomPet"
71 | }],
72 | ...
73 | }
74 | ...
75 | ```
76 |
--------------------------------------------------------------------------------
/docs/rules/1034.md:
--------------------------------------------------------------------------------
1 | ### 1034 - AddedRequiredProperty
2 |
3 | **Description**: Checks whether a new required property has added from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change. This change requires new api-version.
6 |
7 | **Example**: Property `b` is being added without revising api-version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "CreateParameters": {
22 | "properties": {
23 | "a": {
24 | "type": "string",
25 | "description": "Required. Property a."
26 | },
27 | "b": {
28 | "type": "string",
29 | "description": "Required. Enum Property b.",
30 | "enum": [ "b1", "b2" ]
31 | }
32 | },
33 | "required": [
34 | "a"
35 | ],
36 | "description": "The parameters used when create operation."
37 | },
38 | ...
39 | ```
40 |
41 | New specification
42 | ```json5
43 | {
44 | "swagger": "2.0",
45 | "info": {
46 | "title": "swagger",
47 | "description": "The Azure Management API.",
48 | "version": "2016-12-01",
49 | ...
50 | ...
51 | "definitions": {
52 | ...
53 | "CreateParameters": {
54 | "properties": {
55 | "a": {
56 | "type": "string",
57 | "description": "Required. Property a."
58 | },
59 | "b": {
60 | "type": "string",
61 | "description": "Required. Enum Property b.",
62 | "enum": [ "b1", "b2" ]
63 | }
64 | },
65 | "required": [
66 | "a",
67 | "b"
68 | ],
69 | "description": "The parameters used when create operation."
70 | },
71 | ...
72 | ```
73 |
--------------------------------------------------------------------------------
/docs/rules/1035.md:
--------------------------------------------------------------------------------
1 | ### 1035 - RemovedOperation
2 |
3 | **Description**: Checks whether an existing operation from a path is removed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change. This change requires new api-version.
6 |
7 | **Example**: Operation `get` from Path `/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1` is being removed without revising api-version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
21 | "get": {
22 | ...
23 | },
24 | "put": {
25 | ...
26 | }
27 | },
28 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
29 | "get": {
30 | ...
31 | },
32 | "delete": {
33 | ...
34 | }
35 | }
36 | ...
37 | ...
38 | ```
39 |
40 | New specification
41 | ```json5
42 | {
43 | "swagger": "2.0",
44 | "info": {
45 | "title": "swagger",
46 | "description": "The Azure Management API.",
47 | "version": "2016-12-01",
48 | ...
49 | ...
50 | "paths": {
51 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
52 | "get": {
53 | ...
54 | },
55 | "put": {
56 | ...
57 | }
58 | },
59 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
60 | "post": {
61 | ...
62 | },
63 | "delete": {
64 | ...
65 | }
66 | }
67 | ...
68 | ...
69 | ```
70 |
--------------------------------------------------------------------------------
/docs/rules/1036.md:
--------------------------------------------------------------------------------
1 | ### 1036 - ConstraintChanged
2 |
3 | **Description**: Checks whether any property's constraint like `maximum`, `minimum`, `minLength`, `maxLength` etc. has changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Value of `maxItems` element of property `a` is changed from `5000` to `2000` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | "CreateParameters": {
22 | "properties": {
23 | "a": {
24 | "type": "array",
25 | "description": "Property a.",
26 | "minItems": 11,
27 | "maxItems": 5000,
28 | "collectionFormat": "pipes",
29 | "items": {
30 | "type": "integer",
31 | "minimum": 11,
32 | "maximum": 21,
33 | "multipleOf": 4
34 | }
35 | },
36 | ...
37 | ```
38 |
39 | New specification
40 | ```json5
41 | {
42 | "swagger": "2.0",
43 | "info": {
44 | "title": "swagger",
45 | "description": "The Azure Management API.",
46 | "version": "2016-12-01",
47 | ...
48 | ...
49 | "definitions": {
50 | ...
51 | "CreateParameters": {
52 | "properties": {
53 | "a": {
54 | "type": "array",
55 | "description": "Property a.",
56 | "minItems": 11,
57 | "maxItems": 2000,
58 | "collectionFormat": "pipes",
59 | "items": {
60 | "type": "integer",
61 | "minimum": 11,
62 | "maximum": 21,
63 | "multipleOf": 4
64 | }
65 | },
66 | ...
67 | ```
68 |
--------------------------------------------------------------------------------
/docs/rules/1038.md:
--------------------------------------------------------------------------------
1 | ### 1038 - AddedPath
2 |
3 | **Description**: Checks whether a new path is added from the previous specification.
4 |
5 | **Cause**: This is considered a additive change in new api-version but a breaking in same api-version.
6 |
7 | **Example**: New path `/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1` is being added.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
21 | "get": {
22 | ...
23 | },
24 | "put": {
25 | ...
26 | }
27 | }
28 | ...
29 | ...
30 | ```
31 |
32 | New specification
33 | ```json5
34 | {
35 | "swagger": "2.0",
36 | "info": {
37 | "title": "swagger",
38 | "description": "The Azure Management API.",
39 | "version": "2016-12-01",
40 | ...
41 | ...
42 | "paths": {
43 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
44 | "get": {
45 | ...
46 | },
47 | "put": {
48 | ...
49 | }
50 | },
51 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
52 | "get": {
53 | ...
54 | },
55 | "delete": {
56 | ...
57 | }
58 | }
59 | ...
60 | ...
61 | ```
62 |
--------------------------------------------------------------------------------
/docs/rules/1039.md:
--------------------------------------------------------------------------------
1 | ### 1039 - AddedOperation
2 |
3 | **Description**: Checks whether a new operation in an existing path is added from the previous specification.
4 |
5 | **Cause**: This is considered a additive change in new api-version but a breaking in same api-version.
6 |
7 | **Example**: Operation `get` in Path `/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1` is being added without revising api-version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
21 | "get": {
22 | ...
23 | },
24 | "put": {
25 | ...
26 | }
27 | },
28 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
29 | "post": {
30 | ...
31 | },
32 | "delete": {
33 | ...
34 | }
35 | }
36 | ...
37 | ...
38 | ```
39 |
40 | New specification
41 | ```json5
42 | {
43 | "swagger": "2.0",
44 | "info": {
45 | "title": "swagger",
46 | "description": "The Azure Management API.",
47 | "version": "2016-12-01",
48 | ...
49 | ...
50 | "paths": {
51 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
52 | "get": {
53 | ...
54 | },
55 | "put": {
56 | ...
57 | }
58 | },
59 | "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
60 | "get": {
61 | ...
62 | },
63 | "post": {
64 | ...
65 | },
66 | "delete": {
67 | ...
68 | }
69 | }
70 | ...
71 | ...
72 | ```
73 |
--------------------------------------------------------------------------------
/docs/rules/1042.md:
--------------------------------------------------------------------------------
1 | ### 1042 - ChangedParameterOrder
2 |
3 | **Description**: Check whether operation parameter order is changed. If operation parameter order changed, it causes SDK breaking change.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Related rules**
8 |
9 | - [1050 - ParameterLocationHasChanged](1050.md)
10 |
11 | **Example**: Parameter order change from `a, b, e` to `a, e, b`.
12 |
13 | Old specification
14 |
15 | ```json5
16 | "parameters": [
17 | {
18 | "name": "a",
19 | "in": "body",
20 | "required": true,
21 | "type": "string"
22 | },
23 | {
24 | "name": "b",
25 | "in": "body",
26 | "required": true,
27 | "type": "string"
28 | },
29 | {
30 | "name": "e",
31 | "in": "body",
32 | "type": "string"
33 | },
34 | ]
35 | ```
36 |
37 | New specification
38 |
39 | ```json5
40 | "parameters": [
41 | {
42 | "name": "a",
43 | "in": "body",
44 | "required": true,
45 | "type": "string"
46 | },
47 | {
48 | "name": "e",
49 | "in": "body",
50 | "type": "string"
51 | },
52 | {
53 | "name": "b",
54 | "in": "body",
55 | "required": true,
56 | "type": "string"
57 | },
58 | ]
59 | ```
60 |
--------------------------------------------------------------------------------
/docs/rules/1044.md:
--------------------------------------------------------------------------------
1 | ### 1044 - XmsLongRunningOperationChanged
2 |
3 | **Description**: Checks whether any operation's 'x-ms-long-running-operation' has changed from the previous specification.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: The `x-ms-long-running-operation` is changed from `false` to `true` in the new version.
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "paths": {
20 | ...
21 | "put": {
22 | "x-ms-long-running-operation": false,
23 | ...
24 | ```
25 |
26 | New specification
27 | ```json5
28 | {
29 | "swagger": "2.0",
30 | "info": {
31 | "title": "swagger",
32 | "description": "The Azure Management API.",
33 | "version": "2016-12-01",
34 | ...
35 | ...
36 | "paths": {
37 | ...
38 | "put": {
39 | "x-ms-long-running-operation": true,
40 | ...
41 | ```
42 |
--------------------------------------------------------------------------------
/docs/rules/1045.md:
--------------------------------------------------------------------------------
1 | ### 1045 - AddedOptionalProperty
2 |
3 | **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.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**: Property `c` is being added into model `Parameters` .
8 |
9 | Old specification
10 | ```json5
11 | {
12 | "swagger": "2.0",
13 | "info": {
14 | "title": "swagger",
15 | "description": "The Azure Management API.",
16 | "version": "2016-12-01",
17 | ...
18 | ...
19 | "definitions": {
20 | ...
21 | ...
22 | "Parameters": {
23 | "properties": {
24 | "a": {
25 | "type": "string",
26 | "description": "Required. Property a."
27 | },
28 | "b": {
29 | "type": "string",
30 | "description": "Required. Enum Property b.",
31 | "enum": [ "b1", "b2" ]
32 | }
33 | },
34 | "description": "The parameters used when get operation."
35 | },
36 | ...
37 | ```
38 |
39 | New specification
40 | ```json5
41 | {
42 | "swagger": "2.0",
43 | "info": {
44 | "title": "swagger",
45 | "description": "The Azure Management API.",
46 | "version": "2016-12-01",
47 | ...
48 | ...
49 | "definitions": {
50 | ...
51 | ...
52 | "Parameters": {
53 | "properties": {
54 | "a": {
55 | "type": "string",
56 | "description": "Required. Property a."
57 | },
58 | "b": {
59 | "type": "string",
60 | "description": "Required. Enum Property b.",
61 | "enum": [ "b1", "b2" ]
62 | },
63 | "c": {
64 | "type": "string",
65 | "description": "Property c."
66 | }
67 | },
68 | "description": "The parameters used when get operation."
69 | },
70 | ...
71 | ```
--------------------------------------------------------------------------------
/docs/rules/1047.md:
--------------------------------------------------------------------------------
1 | ### 1047 - XmsEnumChanged
2 |
3 | **Description**: Checks whether the x-ms-enum 'name' or 'modelAsString' is changed.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**:
8 | 1. x-ms-enum modelAsString is changed from 'false' to 'true'.
9 |
10 | Old specification
11 | ```json5
12 | {
13 | "type": "string",
14 | "description": "Required. Indicates the type of account.",
15 | "enum": [
16 | "Storage",
17 | "BlobStorage"
18 | ],
19 | "x-ms-enum": {
20 | "name": "Kind",
21 | "modelAsString": false
22 | }
23 | }
24 | ```
25 |
26 | New specification
27 | ```json5
28 | {
29 | "type": "string",
30 | "description": "Required. Indicates the type of account.",
31 | "enum": [
32 | "Storage",
33 | "BlobStorage"
34 | ],
35 | "x-ms-enum": {
36 | "name": "Kind",
37 | "modelAsString": true
38 | }
39 | }
40 | ```
41 |
--------------------------------------------------------------------------------
/docs/rules/1048.md:
--------------------------------------------------------------------------------
1 | ### 1048 - AddedXmsEnum
2 |
3 | **Description**: Checks whether the x-ms-enum is added.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**:
8 | 1. x-ms-enum is added in the new specification.
9 |
10 | Old specification
11 | ```json5
12 | {
13 | "type": "string",
14 | "description": "Required. Indicates the type of account.",
15 | "enum": [
16 | "Storage",
17 | "BlobStorage"
18 | ],
19 | }
20 | ```
21 |
22 | New specification
23 | ```json5
24 | {
25 | "type": "string",
26 | "description": "Required. Indicates the type of account.",
27 | "enum": [
28 | "Storage",
29 | "BlobStorage"
30 | ],
31 | "x-ms-enum": {
32 | "name": "Kind",
33 | "modelAsString": true
34 | }
35 | }
36 | ```
37 |
--------------------------------------------------------------------------------
/docs/rules/1049.md:
--------------------------------------------------------------------------------
1 | ### 1049 - RemovedXmsEnum
2 |
3 | **Description**: Checks whether the x-ms-enum is removed.
4 |
5 | **Cause**: This is considered a breaking change.
6 |
7 | **Example**:
8 | 1. x-ms-enum is removed in the new specification.
9 |
10 | Old specification
11 | ```json5
12 | {
13 | "type": "string",
14 | "description": "Required. Indicates the type of account.",
15 | "enum": [
16 | "Storage",
17 | "BlobStorage"
18 | ],
19 | "x-ms-enum": {
20 | "name": "Kind",
21 | "modelAsString": true
22 | }
23 | }
24 | ```
25 |
26 | New specification
27 | ```json5
28 | {
29 | "type": "string",
30 | "description": "Required. Indicates the type of account.",
31 | "enum": [
32 | "Storage",
33 | "BlobStorage"
34 | ],
35 | }
36 | ```
37 |
--------------------------------------------------------------------------------
/eng/image.yml:
--------------------------------------------------------------------------------
1 | # Default pool image selection. Set as variable so we can override at pipeline level
2 |
3 | variables:
4 | - name: LINUXPOOL
5 | value: azsdk-pool
6 | - name: WINDOWSPOOL
7 | value: azsdk-pool
8 | - name: MACPOOL
9 | value: Azure Pipelines
10 |
11 | - name: LINUXVMIMAGE
12 | value: ubuntu-24.04
13 | - name: LINUXNEXTVMIMAGE
14 | value: ubuntu-24.04
15 | - name: WINDOWSVMIMAGE
16 | value: windows-2022
17 | - name: MACVMIMAGE
18 | value: macos-11
19 |
20 | # Values required for pool.os field in 1es pipeline templates
21 | - name: LINUXOS
22 | value: linux
23 | - name: WINDOWSOS
24 | value: windows
25 | - name: MACOS
26 | value: macOS
27 |
--------------------------------------------------------------------------------
/eng/publish-1es-artifact.yml:
--------------------------------------------------------------------------------
1 | # This step is used to prevent duplication of artifact publishes when there is an issue that would prevent the overall success of the job.
2 | # Ensuring that we only publish when successful (and two a differently named artifact otherwise) will allow easy retry on a build pipeline
3 | # without running into the "cannot override artifact" failure when we finally do get a passing run.
4 |
5 | # ArtifactName - The name of the artifact in the "successful" case.
6 | # ArtifactPath - The path we will be publishing.
7 | # CustomCondition - Used if there is additional logic necessary to prevent attempt of publish.
8 | # SbomEnabled - Set whether to auto-inject 1es pipeline template sbom tasks
9 |
10 | parameters:
11 | ArtifactName: ""
12 | ArtifactPath: ""
13 | CustomCondition: true
14 | SbomEnabled: true
15 |
16 | steps:
17 | - pwsh: |
18 | if ($env:AGENT_JOBSTATUS -eq "Failed") {
19 | Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}-FailedAttempt$(System.JobAttempt)"
20 | } else {
21 | Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}"
22 | }
23 | condition: and(succeededOrFailed(), ${{ parameters.CustomCondition }})
24 | displayName: Set Artifact Name $(Agent.JobStatus)
25 |
26 | - task: 1ES.PublishPipelineArtifact@1
27 | condition: and(succeededOrFailed(), ${{ parameters.CustomCondition }})
28 | displayName: "Publish ${{ parameters.ArtifactName }} Artifacts"
29 | inputs:
30 | artifactName: "$(PublishArtifactName)"
31 | targetPath: "${{ parameters.ArtifactPath }}"
32 | sbomEnabled: ${{ parameters.SbomEnabled }}
33 |
--------------------------------------------------------------------------------
/eng/scripts/determine-release-tag.ps1:
--------------------------------------------------------------------------------
1 | # Read the package.json file
2 | $packageJsonPath = "$PSScriptRoot/../../package.json"
3 | $packageJson = Get-Content $packageJsonPath -Raw | ConvertFrom-Json
4 |
5 | # Function to check if a version is non-GA
6 | function Is-NonGA($version) {
7 | return $version -match "-(alpha|beta|rc|pre)"
8 | }
9 |
10 | $pkgVersion = $packageJson.version
11 |
12 | if (Is-NonGA($pkgVersion)) {
13 | Write-Host "##vso[task.setvariable variable=Tag;]beta"
14 | }
15 | else {
16 | Write-Host "##vso[task.setvariable variable=Tag;]latest"
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/eng/test-steps.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | - name: ArtifactName
3 | type: string
4 | default: "drop"
5 |
6 | steps:
7 | - task: UseDotNet@2
8 | inputs:
9 | version: 6.x
10 | - script: npm ci
11 | displayName: npm ci
12 | - script: npm run lint
13 | displayName: lint
14 | - script: npm run prettier
15 | displayName: prettier
16 | - script: npm test
17 | displayName: test
18 | - script: npm pack
19 | displayName: pack
20 | - task: CopyFiles@2
21 | displayName: "Copy Files to Staging"
22 | inputs:
23 | Contents: "*.tgz"
24 | TargetFolder: $(Build.ArtifactStagingDirectory)
25 |
26 | - template: /eng/publish-1es-artifact.yml
27 | parameters:
28 | ArtifactName: ${{ parameters.ArtifactName }}
29 | ArtifactPath: $(Build.ArtifactStagingDirectory)
30 |
--------------------------------------------------------------------------------
/openapi-diff/src/common/common-package-references.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/openapi-diff/src/common/common.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1.0.1
4 | $(MsBuildThisFileDirectory)
5 | true
6 |
7 | $(MsBuildThisFileDirectory)
8 | $(Common)../../
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/openapi-diff/src/common/copy-resource-to-output.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Always
5 |
6 |
7 |
--------------------------------------------------------------------------------
/openapi-diff/src/common/enumerate-inputs.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/openapi-diff/src/common/package-info.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Copyright (c) Microsoft Corporation
4 |
5 | http://go.microsoft.com/fwlink/?LinkID=288890
6 | https://github.com/Azure/AutoRest
7 | https://raw.githubusercontent.com/Microsoft/dotnet/master/LICENSE
8 | true
9 |
10 | true
11 | $(SolutionDir)/tools/MSSharedLibKey.snk
12 | true
13 |
14 |
--------------------------------------------------------------------------------
/openapi-diff/src/common/project-library.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 |
--------------------------------------------------------------------------------
/openapi-diff/src/common/project-xunittest.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/openapi-diff/src/core/OpenApiDiff.Core/Logging/LogMessageSeverity.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace OpenApiDiff.Core.Logging
5 | {
6 | ///
7 | /// severity of the log message.
8 | ///
9 | public enum Category
10 | {
11 | Info,
12 | Warning,
13 | Error
14 | }
15 | }
--------------------------------------------------------------------------------
/openapi-diff/src/core/OpenApiDiff.Core/OpenApiDiff.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | OpenApiDiff.Core
9 | Microsoft AutoRest
10 | 7.3
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | True
29 | True
30 | Resources.resx
31 |
32 |
33 |
34 |
35 | PublicResXFileCodeGenerator
36 | Resources.Designer.cs
37 |
38 |
39 |
--------------------------------------------------------------------------------
/openapi-diff/src/core/OpenApiDiff.Core/SettingsAliasAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace OpenApiDiff.Core
7 | {
8 | ///
9 | /// Attribute used for extending parameters with aliases.
10 | ///
11 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
12 | public sealed class SettingsAliasAttribute : Attribute
13 | {
14 | ///
15 | /// Initializes a new instance of SettingsAliasAttribute.
16 | ///
17 | public SettingsAliasAttribute()
18 | { }
19 |
20 | ///
21 | /// Initializes a new instance of SettingsAliasAttribute with an alias.
22 | ///
23 | /// The alias for the setting.
24 | public SettingsAliasAttribute(string alias)
25 | {
26 | Alias = alias;
27 | }
28 |
29 | public string Alias { get; private set; }
30 | }
31 | }
--------------------------------------------------------------------------------
/openapi-diff/src/core/OpenApiDiff.Core/SettingsInfoAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace OpenApiDiff.Core
7 | {
8 | ///
9 | /// Helper attribute used for documentation generation in AutoRest command line interface.
10 | ///
11 | [AttributeUsage(AttributeTargets.Property)]
12 | public sealed class SettingsInfoAttribute : Attribute
13 | {
14 | private string _documentation;
15 | ///
16 | /// Initializes a new instance of SettingsInfoAttribute with documentation and required flag.
17 | ///
18 | /// Documentation body.
19 | /// If set indicates that the property is a required command
20 | /// line argument.
21 | public SettingsInfoAttribute(string documentation, bool isRequired)
22 | {
23 | _documentation = documentation;
24 | IsRequired = isRequired;
25 | }
26 |
27 | ///
28 | /// Initializes a new instance of SettingsInfoAttribute with documentation.
29 | /// IsRequired defaults to false.
30 | ///
31 | /// Documentation body.
32 | public SettingsInfoAttribute(string documentation) :
33 | this(documentation, false)
34 | {
35 | }
36 |
37 | ///
38 | /// Documentation text of the settings property.
39 | ///
40 | public string Documentation { get { return _documentation; } }
41 |
42 | ///
43 | /// True if property is required, false otherwise.
44 | ///
45 | public bool IsRequired { get; set; }
46 | }
47 | }
--------------------------------------------------------------------------------
/openapi-diff/src/core/OpenApiDiff/HelpExample.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace OpenApiDiff
5 | {
6 | ///
7 | /// Structure that represents an example in generated help.
8 | ///
9 | public struct HelpExample
10 | {
11 | ///
12 | /// Gets or sets example plain text description.
13 | ///
14 | public string Description { get; set; }
15 |
16 | ///
17 | /// Gets or sets example code.
18 | ///
19 | public string Example { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/openapi-diff/src/core/OpenApiDiff/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using AutoRest.Swagger;
5 | using System;
6 | using OpenApiDiff.Core;
7 | using OpenApiDiff.Properties;
8 | using System.IO;
9 | using System.Linq;
10 |
11 | namespace OpenApiDiff
12 | {
13 | internal class Program
14 | {
15 | private static int Main(string[] args)
16 | {
17 | var settings = Settings.GetInstance(args);
18 |
19 | if (settings.ShowHelp)
20 | {
21 | Console.WriteLine(HelpGenerator.Generate(Resources.HelpTextTemplate, settings));
22 | return 0;
23 | }
24 |
25 | try
26 | {
27 | settings.Validate();
28 | }
29 | catch (Exception ex)
30 | {
31 | Console.WriteLine(ex.Message);
32 | return 1;
33 | }
34 |
35 | var modeler = new SwaggerModeler();
36 |
37 | var swaggerPrev = File.ReadAllText(settings.OldSpec);
38 | var swaggerNew = File.ReadAllText(settings.NewSpec);
39 |
40 | var messages = modeler.Compare(
41 | settings.OldSpec,
42 | swaggerPrev,
43 | settings.NewSpec,
44 | swaggerNew,
45 | settings
46 | );
47 |
48 | Console.WriteLine("[");
49 | Console.WriteLine(string.Join(",\n", messages.Select(v => v.GetValidationMessagesAsJson())));
50 | Console.WriteLine("]");
51 |
52 | return 0;
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/added_path.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "added_path",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [
9 | "http",
10 | "https"
11 | ],
12 | "paths": {
13 | "/api/Paths": {
14 | "get": {
15 | "tag": [
16 | "Paths"
17 | ],
18 | "operationId": "Paths_Get",
19 | "produces": [
20 | "text/plain"
21 | ],
22 | "parameters": [],
23 | "responses": {}
24 | }
25 | },
26 | "/api/Operations": {
27 | "get": {
28 | "tag": [
29 | "Operations"
30 | ],
31 | "operationId": "Operations_Get",
32 | "produces": [
33 | "text/plain"
34 | ],
35 | "parameters": [],
36 | "responses": {}
37 | },
38 | "post": {
39 | "tag": [ "Operations" ],
40 | "operationId": "Operations_Post",
41 | "produces": [
42 | "text/plain"
43 | ],
44 | "parameters": [],
45 | "responses": {}
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/added_readonly_required_property.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "description": "Enum.",
37 | "enum": [ "a1", "a2", "a3" ]
38 |
39 | },
40 | "b": {
41 | "type": "string",
42 | "description": "Enum.",
43 | "enum": [ "b1" ],
44 | "readOnly": true
45 | }
46 | },
47 | "required": [ "b" ]
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/added_required_property.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "description": "Enum.",
37 | "enum": [ "a1", "a2", "a3" ]
38 |
39 | },
40 | "b": {
41 | "type": "string",
42 | "description": "Enum.",
43 | "enum": [ "b1" ]
44 | }
45 | },
46 | "required": [ "b" ]
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/changed_operation_id.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "changed_operation_id",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_List",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "operationId": "Operations_Get",
25 | "produces": [
26 | "text/plain"
27 | ],
28 | "parameters": [],
29 | "responses": {}
30 | },
31 | "post": {
32 | "tag": [ "Operations" ],
33 | "operationId": "Operations_Update",
34 | "produces": [
35 | "text/plain"
36 | ],
37 | "parameters": [],
38 | "responses": {}
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/common_parameter_check_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "common_parameter_check_01",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Operations": {
11 | "parameters": [
12 | {
13 | "name": "database",
14 | "in": "body",
15 | "type": "string"
16 | },
17 | {
18 | "name": "database2",
19 | "in": "body",
20 | "type": "string"
21 | }
22 | ],
23 | "get": {
24 | "tag": [ "Operations" ],
25 | "operationId": "Operations_Get",
26 | "produces": [
27 | "text/plain"
28 | ],
29 | "responses": {}
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/common_parameter_check_02.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "common_parameter_check_02",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Operations": {
11 | "parameters": [
12 | {
13 | "name": "p2",
14 | "in": "header",
15 | "type": "string"
16 | },
17 | {
18 | "name": "p3",
19 | "in": "body",
20 | "type": "string",
21 | "required": true
22 | },
23 | {
24 | "name": "p4",
25 | "in": "body",
26 | "type": "string"
27 | }
28 | ],
29 | "get": {
30 | "tag": [ "Operations" ],
31 | "operationId": "Operations_Get",
32 | "produces": [
33 | "text/plain"
34 | ],
35 | "responses": {}
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/common_parameter_check_03.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "common_parameter_check_03",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Operations": {
11 | "parameters": [
12 | {
13 | "name": "p2",
14 | "in": "header",
15 | "type": "string"
16 | },
17 | {
18 | "name": "p3",
19 | "in": "body",
20 | "type": "string",
21 | "required": true
22 | }
23 | ],
24 | "get": {
25 | "tag": [ "Operations" ],
26 | "operationId": "Operations_Get",
27 | "produces": [
28 | "text/plain"
29 | ],
30 | "responses": {},
31 | "parameters": [
32 | {
33 | "name": "p1",
34 | "in": "body",
35 | "type": "string",
36 | "required": true
37 | },
38 | {
39 | "name": "p2",
40 | "in": "body",
41 | "type": "string"
42 | },
43 | {
44 | "name": "p3",
45 | "in": "body",
46 | "type": "string"
47 | }
48 | ]
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/common_parameter_check_04.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "common_parameter_check_04",
5 | "version": "1.0"
6 | },
7 | "parameters": {
8 | "P0": {
9 | "name": "p0",
10 | "in": "body",
11 | "type": "string",
12 | "required": true
13 | },
14 | "P1": {
15 | "name": "p1",
16 | "in": "body",
17 | "type": "string"
18 | }
19 | },
20 | "host": "localhost:8000",
21 | "schemes": [ "http", "https" ],
22 | "paths": {
23 | "/api/Operations": {
24 | "parameters": [
25 | {
26 | "$ref": "#/parameters/P0"
27 | },
28 | {
29 | "$ref": "#/parameters/P1"
30 | }
31 | ],
32 | "get": {
33 | "tag": [ "Operations" ],
34 | "operationId": "Operations_Get",
35 | "produces": [
36 | "text/plain"
37 | ],
38 | "responses": {}
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/enum_as_string.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
38 | },
39 | "b": {
40 | "type": "string",
41 | "enum": [
42 | "A",
43 | "B",
44 | "C"
45 | ],
46 | "x-ms-enum": {
47 | "name": "ResourceIdentityType"
48 | },
49 | "description": "This property shows the number of databases returned."
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/enum_values_changed.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "enum_values_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "description": "Enum.",
37 | "enum": [ "a1", "a2" ]
38 |
39 | },
40 | "b": {
41 | "type": "string",
42 | "description": "Enum.",
43 | "enum": [ "b1", "b2", "b3" ]
44 | },
45 | "c": {
46 | "type": "string",
47 | "description": "Enum.",
48 | "enum": [ "c1"]
49 | }
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/format_check_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "2018-01-01",
5 | "title": "Schema of Azure Storage events published to Azure Event Grid",
6 | "description": "Describes the schema of the Azure Storage events published to Azure Event Grid. This corresponds to the Data property of an EventGridEvent."
7 | },
8 | "paths": {},
9 | "definitions": {
10 | "StorageBlobCreatedEventData": {
11 | "description": "Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobCreated event.",
12 | "type": "object",
13 | "properties": {
14 | "contentLength": {
15 | "description": "The size of the blob in bytes. This is the same as what would be returned in the Content-Length header from the blob.",
16 | "type": "integer",
17 | "format": "int64"
18 | }
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/format_check_02.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "2018-01-01",
5 | "title": "Schema of Azure Storage events published to Azure Event Grid",
6 | "description": "Describes the schema of the Azure Storage events published to Azure Event Grid. This corresponds to the Data property of an EventGridEvent."
7 | },
8 | "paths": {},
9 | "definitions": {
10 | "StorageBlobCreatedEventData": {
11 | "description": "Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobCreated event.",
12 | "type": "object",
13 | "properties": {
14 | "contentLength": {
15 | "description": "The size of the blob in bytes. This is the same as what would be returned in the Content-Length header from the blob.",
16 | "type": "integer"
17 | }
18 | }
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/long_running_operation.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ],
28 | "x-ms-long-running-operation": true
29 | }
30 | }
31 | },
32 | "definitions": {
33 | "Database": {
34 | "properties": {
35 | "a": {
36 | "type": "string",
37 | "readOnly": true,
38 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
39 | },
40 | "b": {
41 | "type": "string",
42 | "enum": [
43 | "A",
44 | "B",
45 | "C"
46 | ],
47 | "x-ms-enum": {
48 | "name": "ResourceIdentityType",
49 | "modelAsString": true
50 | },
51 | "description": "This property shows the number of databases returned."
52 | }
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/missing_operation_id.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "changed_operation_id",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "produces": [
25 | "text/plain"
26 | ],
27 | "parameters": [],
28 | "responses": {}
29 | },
30 | "post": {
31 | "tag": [ "Operations" ],
32 | "operationId": "Operations_Post",
33 | "produces": [
34 | "text/plain"
35 | ],
36 | "parameters": [],
37 | "responses": {}
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/operation_check_03.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "operation_check_03",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters": {
11 | "get": {
12 | "tag": [ "Responses" ],
13 | "operationId": "Responses_Get",
14 | "parameters": [
15 | {
16 | "name": "x-bo",
17 | "in": "header",
18 | "type": "string",
19 | "required": false
20 | },
21 | {
22 | "name": "x-br",
23 | "in": "header",
24 | "type": "string",
25 | "required": true
26 | },
27 | {
28 | "name": "x-co",
29 | "in": "header",
30 | "type": "integer",
31 | "required": false
32 | },
33 | {
34 | "name": "x-cr",
35 | "in": "header",
36 | "type": "integer",
37 | "required": true
38 | }
39 |
40 | ]
41 | }
42 | },
43 | "/api/Responses": {
44 | "get": {
45 | "tag": [ "Responses" ],
46 | "operationId": "Responses_Get",
47 | "parameters": [],
48 | "responses": {
49 | "200": {
50 | "headers": {
51 | "x-b": { "type": "string" },
52 | "x-c": { "type": "integer" }
53 | }
54 | }
55 | }
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/optional_parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "required_parameter",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters/{a}": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [
18 | {
19 | "name": "a",
20 | "in": "path",
21 | "required": true,
22 | "type": "string"
23 | },
24 | {
25 | "name": "b",
26 | "in": "query",
27 | "required": true,
28 | "type": "string"
29 | },
30 | {
31 | "name": "d",
32 | "in": "query",
33 | "required": true,
34 | "type": "string"
35 | },
36 | {
37 | "name": "e",
38 | "in": "query",
39 | "type": "string"
40 | },
41 | {
42 | "name": "g",
43 | "in": "query",
44 | "required": false,
45 | "type": "string"
46 | }
47 | ]
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/parameter_order_change.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "parameter_order_change",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters/{a}": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [
18 | {
19 | "name": "a",
20 | "in": "path",
21 | "required": true,
22 | "type": "string"
23 | },
24 | {
25 | "name": "b",
26 | "in": "query",
27 | "required": true,
28 | "type": "string"
29 | },
30 | {
31 | "name": "e",
32 | "in": "query",
33 | "type": "string"
34 | },
35 | {
36 | "name": "d",
37 | "in": "query",
38 | "required": true,
39 | "type": "string"
40 | },
41 | {
42 | "name": "f",
43 | "in": "query",
44 | "required": true,
45 | "type": "string",
46 | "enum": [ "theonlyvalue" ]
47 | }
48 | ]
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/removed_definition.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "removed_definition",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
38 | },
39 | "b": {
40 | "type": "integer",
41 | "readOnly": true,
42 | "default": 0,
43 | "description": "This property shows the number of databases returned."
44 | }
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/removed_operation.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "removed_operation",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "operationId": "Operations_Get",
25 | "produces": [
26 | "text/plain"
27 | ],
28 | "parameters": [],
29 | "responses": {}
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/removed_operation_id.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "changed_operation_id",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "produces": [
25 | "text/plain"
26 | ],
27 | "parameters": [],
28 | "responses": {}
29 | },
30 | "post": {
31 | "tag": [ "Operations" ],
32 | "operationId": "Operations_Post",
33 | "produces": [
34 | "text/plain"
35 | ],
36 | "parameters": [],
37 | "responses": {}
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/removed_parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "removed_parameter",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters/{a}": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": []
18 | }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/removed_path.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "removed_path",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "operationId": "Operations_Get",
25 | "produces": [
26 | "text/plain"
27 | ],
28 | "parameters": [],
29 | "responses": {}
30 | },
31 | "post": {
32 | "tag": [ "Operations" ],
33 | "operationId": "Operations_Post",
34 | "produces": [
35 | "text/plain"
36 | ],
37 | "parameters": [],
38 | "responses": {}
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/required_parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "required_parameter",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters/{a}": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [
18 | {
19 | "name": "a",
20 | "in": "path",
21 | "required": true,
22 | "type": "string"
23 | },
24 | {
25 | "name": "b",
26 | "in": "query",
27 | "required": true,
28 | "type": "string"
29 | },
30 | {
31 | "name": "d",
32 | "in": "query",
33 | "required": true,
34 | "type": "string"
35 | },
36 | {
37 | "name": "e",
38 | "in": "query",
39 | "required": true,
40 | "type": "string"
41 | },
42 | {
43 | "name": "g",
44 | "in": "query",
45 | "required": true,
46 | "type": "string"
47 | }
48 | ]
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/type_changed.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "integer",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
38 | },
39 | "b": {
40 | "type": "integer",
41 | "readOnly": true,
42 | "default": 0,
43 | "description": "This property shows the number of databases returned."
44 | }
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/type_changed_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "object",
36 | "readOnly": true,
37 | "properties": {
38 | "b": {
39 | "type": "string",
40 | "readOnly": true
41 | }
42 | },
43 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
44 | },
45 | "b": {
46 | "type": "integer",
47 | "readOnly": true,
48 | "default": 0,
49 | "description": "This property shows the number of databases returned."
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/version_check_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "version_check_01",
5 | "version": "2.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http" ]
9 | }
10 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/version_check_02.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "version_check_02",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http" ]
9 | }
10 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/version_check_03.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "version_check_03",
5 | "version": "1.1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http" ]
9 | }
10 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/version_check_04.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "version_check_04",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http" ]
9 | }
10 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/xms_enum_added.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation.",
38 | "x-ms-enum": {
39 | "name": "ResourceIdentityType",
40 | "modelAsString": true
41 | }
42 | },
43 | "b": {
44 | "type": "string",
45 | "enum": [
46 | "A",
47 | "B",
48 | "C"
49 | ],
50 | "description": "This property shows the number of databases returned."
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/new/xms_enum_changed.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
38 | },
39 | "b": {
40 | "type": "string",
41 | "enum": [
42 | "A",
43 | "B",
44 | "C"
45 | ],
46 | "x-ms-enum": {
47 | "name": "ResourceIdentityTypeNew",
48 | "modelAsString": false
49 | },
50 | "description": "This property shows the number of databases returned."
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/added_path.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "added_path",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [
9 | "http",
10 | "https"
11 | ],
12 | "paths": {
13 | "/api/Operations": {
14 | "get": {
15 | "tag": [
16 | "Operations"
17 | ],
18 | "operationId": "Operations_Get",
19 | "produces": [
20 | "text/plain"
21 | ],
22 | "parameters": [],
23 | "responses": {}
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/added_readonly_required_property.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "description": "Enum.",
37 | "enum": [ "a1", "a2", "a3" ]
38 |
39 | },
40 | "b": {
41 | "type": "string",
42 | "description": "Enum.",
43 | "enum": [ "b1" ],
44 | "readOnly": true
45 | }
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/added_required_property.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "description": "Enum.",
37 | "enum": [ "a1", "a2", "a3" ]
38 |
39 | },
40 | "b": {
41 | "type": "string",
42 | "description": "Enum.",
43 | "enum": [ "b1" ]
44 | }
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/changed_operation_id.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "changed_operation_id",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "operationId": "Operations_Get",
25 | "produces": [
26 | "text/plain"
27 | ],
28 | "parameters": [],
29 | "responses": {}
30 | },
31 | "post": {
32 | "tag": [ "Operations" ],
33 | "operationId": "Operations_Post",
34 | "produces": [
35 | "text/plain"
36 | ],
37 | "parameters": [],
38 | "responses": {}
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/common_parameter_check_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "common_parameter_check_01",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Operations": {
11 | "parameters": [
12 | {
13 | "name": "database",
14 | "in": "body",
15 | "type": "string"
16 | }
17 | ],
18 | "get": {
19 | "tag": [ "Operations" ],
20 | "operationId": "Operations_Get",
21 | "produces": [
22 | "text/plain"
23 | ],
24 | "responses": {}
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/common_parameter_check_02.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "common_parameter_check_02",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Operations": {
11 | "parameters": [
12 | {
13 | "name": "p1",
14 | "in": "body",
15 | "type": "string",
16 | "required": true
17 | },
18 | {
19 | "name": "p2",
20 | "in": "body",
21 | "type": "string"
22 | },
23 | {
24 | "name": "p3",
25 | "in": "body",
26 | "type": "string"
27 | },
28 | {
29 | "name": "p4",
30 | "in": "body",
31 | "type": "string",
32 | "required": true
33 | }
34 | ],
35 | "get": {
36 | "tag": [ "Operations" ],
37 | "operationId": "Operations_Get",
38 | "produces": [
39 | "text/plain"
40 | ],
41 | "responses": {}
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/common_parameter_check_03.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "common_parameter_check_03",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Operations": {
11 | "parameters": [
12 | {
13 | "name": "p1",
14 | "in": "body",
15 | "type": "object"
16 | },
17 | {
18 | "name": "p2",
19 | "in": "body",
20 | "type": "string"
21 | },
22 | {
23 | "name": "p3",
24 | "in": "body",
25 | "type": "string"
26 | }
27 | ],
28 | "get": {
29 | "tag": [ "Operations" ],
30 | "operationId": "Operations_Get",
31 | "produces": [
32 | "text/plain"
33 | ],
34 | "responses": {},
35 | "parameters": [
36 | {
37 | "name": "p1",
38 | "in": "body",
39 | "type": "string",
40 | "required": true
41 | },
42 | {
43 | "name": "p2",
44 | "in": "body",
45 | "type": "string"
46 | },
47 | {
48 | "name": "p3",
49 | "in": "body",
50 | "type": "string"
51 | }
52 | ]
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/common_parameter_check_04.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "common_parameter_check_04",
5 | "version": "1.0"
6 | },
7 | "parameters": {
8 | "P0": {
9 | "name": "p0",
10 | "in": "body",
11 | "type": "string"
12 | },
13 | "P1": {
14 | "name": "p1",
15 | "in": "body",
16 | "type": "string"
17 | }
18 | },
19 | "host": "localhost:8000",
20 | "schemes": [ "http", "https" ],
21 | "paths": {
22 | "/api/Operations": {
23 | "parameters": [
24 | {
25 | "$ref": "#/parameters/P0"
26 | },
27 | {
28 | "$ref": "#/parameters/P1"
29 | }
30 | ],
31 | "get": {
32 | "tag": [ "Operations" ],
33 | "operationId": "Operations_Get",
34 | "produces": [
35 | "text/plain"
36 | ],
37 | "responses": {}
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/enum_as_string.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
38 | },
39 | "b": {
40 | "type": "string",
41 | "enum": [
42 | "A",
43 | "B"
44 | ],
45 | "x-ms-enum": {
46 | "name": "ResourceIdentityType",
47 | "modelAsString": true
48 | },
49 | "description": "This property shows the number of databases returned."
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/enum_values_changed.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "enum_values_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "description": "Enum.",
37 | "enum": [ "a1", "a2", "a3" ]
38 |
39 | },
40 | "b": {
41 | "type": "string",
42 | "description": "Enum.",
43 | "enum": [ "b1" ]
44 | },
45 | "c": {
46 | "type": "string",
47 | "description": "Enum."
48 | }
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/format_check_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "2018-01-01",
5 | "title": "Schema of Azure Storage events published to Azure Event Grid",
6 | "description": "Describes the schema of the Azure Storage events published to Azure Event Grid. This corresponds to the Data property of an EventGridEvent."
7 | },
8 | "paths": {},
9 | "definitions": {
10 | "StorageBlobCreatedEventData": {
11 | "description": "Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobCreated event.",
12 | "type": "object",
13 | "properties": {
14 | "contentLength": {
15 | "description": "The size of the blob in bytes. This is the same as what would be returned in the Content-Length header from the blob.",
16 | "type": "integer"
17 | }
18 | }
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/format_check_02.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "2018-01-01",
5 | "title": "Schema of Azure Storage events published to Azure Event Grid",
6 | "description": "Describes the schema of the Azure Storage events published to Azure Event Grid. This corresponds to the Data property of an EventGridEvent."
7 | },
8 | "paths": {},
9 | "definitions": {
10 | "StorageBlobCreatedEventData": {
11 | "description": "Schema of the Data property of an EventGridEvent for an Microsoft.Storage.BlobCreated event.",
12 | "type": "object",
13 | "properties": {
14 | "contentLength": {
15 | "description": "The size of the blob in bytes. This is the same as what would be returned in the Content-Length header from the blob.",
16 | "type": "integer",
17 | "format": "int64"
18 | }
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/long_running_operation.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ],
28 | "x-ms-long-running-operation": false
29 | }
30 | }
31 | },
32 | "definitions": {
33 | "Database": {
34 | "properties": {
35 | "a": {
36 | "type": "string",
37 | "readOnly": true,
38 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
39 | },
40 | "b": {
41 | "type": "string",
42 | "enum": [
43 | "A",
44 | "B",
45 | "C"
46 | ],
47 | "x-ms-enum": {
48 | "name": "ResourceIdentityType",
49 | "modelAsString": true
50 | },
51 | "description": "This property shows the number of databases returned."
52 | }
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/missing_operation_id.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "changed_operation_id",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "produces": [
25 | "text/plain"
26 | ],
27 | "parameters": [],
28 | "responses": {}
29 | },
30 | "post": {
31 | "tag": [ "Operations" ],
32 | "operationId": "Operations_Post",
33 | "produces": [
34 | "text/plain"
35 | ],
36 | "parameters": [],
37 | "responses": {}
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/operation_check_03.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "operation_check_03",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters": {
11 | "get": {
12 | "tag": [ "Responses" ],
13 | "operationId": "Responses_Get",
14 | "parameters": [
15 | {
16 | "name": "x-ao",
17 | "in": "header",
18 | "type": "integer",
19 | "required": false
20 | },
21 | {
22 | "name": "x-ar",
23 | "in": "header",
24 | "type": "integer",
25 | "required": true
26 | },
27 | {
28 | "name": "x-bo",
29 | "in": "header",
30 | "type": "integer",
31 | "required": false
32 | },
33 | {
34 | "name": "x-br",
35 | "in": "header",
36 | "type": "integer",
37 | "required": true
38 | }
39 | ]
40 | }
41 | },
42 | "/api/Responses": {
43 | "get": {
44 | "tag": [ "Responses" ],
45 | "operationId": "Responses_Get",
46 | "parameters": [],
47 | "responses": {
48 | "200": {
49 | "headers": {
50 | "x-a": { "type": "integer" },
51 | "x-b": { "type": "integer" }
52 | }
53 | }
54 | }
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/optional_parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "required_parameter",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters/{a}": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [
18 | {
19 | "name": "a",
20 | "in": "path",
21 | "required": true,
22 | "type": "string"
23 | },
24 | {
25 | "name": "b",
26 | "in": "query",
27 | "required": true,
28 | "type": "string"
29 | },
30 | {
31 | "name": "d",
32 | "in": "query",
33 | "required": true,
34 | "type": "string"
35 | },
36 | {
37 | "name": "e",
38 | "in": "query",
39 | "type": "string"
40 | },
41 | {
42 | "name": "f",
43 | "in": "query",
44 | "required": false,
45 | "type": "string",
46 | "enum": [ "theonlyvalue" ]
47 | }
48 | ]
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/parameter_location_change.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "parameter_location_change",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [
18 | {
19 | "name": "implicit_from_method_to_client",
20 | "in": "query",
21 | "type": "string"
22 | },
23 | {
24 | "$ref": "#/parameters/GlobalFromClientToMethodParam"
25 | },
26 | {
27 | "$ref": "#/parameters/GlobalFromClientToClientParam"
28 | },
29 | {
30 | "$ref": "#/parameters/FromImplicitGlobalClientToImplicitMethod"
31 | }
32 | ]
33 | }
34 | }
35 | },
36 | "parameters": {
37 | "GlobalFromClientToMethodParam": {
38 | "name": "global_from_client_to_method",
39 | "in": "query",
40 | "type": "string"
41 | },
42 | "GlobalFromClientToClientParam": {
43 | "name": "global_from_client_to_client",
44 | "in": "query",
45 | "type": "string"
46 | },
47 | "FromImplicitGlobalClientToImplicitMethod": {
48 | "name": "from_implicit_global_client_to_implicit_method",
49 | "in": "query",
50 | "type": "string"
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/parameter_order_change.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "parameter_order_change",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters/{a}": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [
18 | {
19 | "name": "a",
20 | "in": "path",
21 | "required": true,
22 | "type": "string"
23 | },
24 | {
25 | "name": "b",
26 | "in": "query",
27 | "required": true,
28 | "type": "string"
29 | },
30 | {
31 | "name": "d",
32 | "in": "query",
33 | "required": true,
34 | "type": "string"
35 | },
36 | {
37 | "name": "e",
38 | "in": "query",
39 | "type": "string"
40 | },
41 | {
42 | "name": "f",
43 | "in": "query",
44 | "required": true,
45 | "type": "string",
46 | "enum": [ "theonlyvalue" ]
47 | }
48 | ]
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/removed_definition.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "removed_definition",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/DatabaseList" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "DatabaseList": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
38 | },
39 | "b": {
40 | "type": "integer",
41 | "readOnly": true,
42 | "default": 0,
43 | "description": "This property shows the number of databases returned."
44 | }
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/removed_operation.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "removed_operation",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "operationId": "Operations_Get",
25 | "produces": [
26 | "text/plain"
27 | ],
28 | "parameters": [],
29 | "responses": {}
30 | },
31 | "post": {
32 | "tag": [ "Operations" ],
33 | "operationId": "Operations_Post",
34 | "produces": [
35 | "text/plain"
36 | ],
37 | "parameters": [],
38 | "responses": {}
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/removed_operation_id.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "changed_operation_id",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Paths": {
11 | "get": {
12 | "tag": [ "Paths" ],
13 | "operationId": "Paths_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [],
18 | "responses": {}
19 | }
20 | },
21 | "/api/Operations": {
22 | "get": {
23 | "tag": [ "Operations" ],
24 | "operationId": "Operations_Get",
25 | "produces": [
26 | "text/plain"
27 | ],
28 | "parameters": [],
29 | "responses": {}
30 | },
31 | "post": {
32 | "tag": [ "Operations" ],
33 | "operationId": "Operations_Post",
34 | "produces": [
35 | "text/plain"
36 | ],
37 | "parameters": [],
38 | "responses": {}
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/removed_parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "removed_parameter",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters/{a}": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [
18 | {
19 | "name": "path_param_req",
20 | "in": "path",
21 | "required": true,
22 | "type": "string"
23 | },
24 | {
25 | "name": "query_param_req",
26 | "in": "query",
27 | "required": true,
28 | "type": "string"
29 | },
30 | {
31 | "name": "body_param_req",
32 | "in": "body",
33 | "required": true,
34 | "type": "string"
35 | },
36 | {
37 | "name": "path_param",
38 | "in": "path",
39 | "type": "string"
40 | },
41 | {
42 | "name": "query_param",
43 | "in": "query",
44 | "type": "string"
45 | },
46 | {
47 | "name": "body_param",
48 | "in": "body",
49 | "type": "string"
50 | },
51 | ]
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/required_parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "required_parameter",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "paths": {
10 | "/api/Parameters/{a}": {
11 | "get": {
12 | "tag": [ "Parameters" ],
13 | "operationId": "Parameters_Get",
14 | "produces": [
15 | "text/plain"
16 | ],
17 | "parameters": [
18 | {
19 | "name": "a",
20 | "in": "path",
21 | "required": true,
22 | "type": "string"
23 | },
24 | {
25 | "name": "b",
26 | "in": "query",
27 | "required": true,
28 | "type": "string"
29 | },
30 | {
31 | "name": "d",
32 | "in": "query",
33 | "required": true,
34 | "type": "string"
35 | },
36 | {
37 | "name": "e",
38 | "in": "query",
39 | "type": "string"
40 | },
41 | {
42 | "name": "f",
43 | "in": "query",
44 | "required": true,
45 | "type": "string",
46 | "enum": [ "theonlyvalue" ]
47 | }
48 | ]
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/type_changed.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
38 | },
39 | "b": {
40 | "type": "integer",
41 | "readOnly": true,
42 | "default": 0,
43 | "description": "This property shows the number of databases returned."
44 | }
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/type_changed_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "readOnly": true,
36 | "properties": {
37 | "b": {
38 | "type": "string",
39 | "readOnly": true
40 | }
41 | },
42 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
43 | },
44 | "b": {
45 | "type": "integer",
46 | "readOnly": true,
47 | "default": 0,
48 | "description": "This property shows the number of databases returned."
49 | }
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/version_check_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "version_check_01",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ]
9 | }
10 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/version_check_02.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "version_check_02",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ]
9 | }
10 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/version_check_03.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "version_check_03",
5 | "version": "1.0.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ]
9 | }
10 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/version_check_04.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "version_check_04",
5 | "version": "2.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http" ]
9 | }
10 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/xms_enum_added.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation.",
38 | "enum": [
39 | "A",
40 | "B",
41 | "C"
42 | ]
43 | },
44 | "b": {
45 | "type": "string",
46 | "enum": [
47 | "A",
48 | "B",
49 | "C"
50 | ],
51 | "x-ms-enum": {
52 | "name": "ResourceIdentityType",
53 | "modelAsString": true
54 | },
55 | "description": "This property shows the number of databases returned."
56 | }
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/Resource/Swagger/old/xms_enum_changed.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": 2.0,
3 | "info": {
4 | "title": "type_changed",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tag": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "type": "object",
25 | "schema": { "$ref": "#/definitions/Database" }
26 | }
27 | ]
28 | }
29 | }
30 | },
31 | "definitions": {
32 | "Database": {
33 | "properties": {
34 | "a": {
35 | "type": "string",
36 | "readOnly": true,
37 | "description": "This is a system generated property.\nThe _rid value is empty for this operation."
38 | },
39 | "b": {
40 | "type": "string",
41 | "enum": [
42 | "A",
43 | "B",
44 | "C"
45 | ],
46 | "x-ms-enum": {
47 | "name": "ResourceIdentityType"
48 | },
49 | "description": "This property shows the number of databases returned."
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/AutoRest.Swagger.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | AutoRest.Swagger
9 | Microsoft AutoRest Generator Extensions
10 | 7.3
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/JsonComparisonMessage.cs:
--------------------------------------------------------------------------------
1 | namespace AutoRest.Swagger
2 | {
3 | sealed class JsonComparisonMessage
4 | {
5 | public string id;
6 |
7 | public string code;
8 |
9 | public string message;
10 |
11 | public JsonLocation old;
12 |
13 | public JsonLocation @new;
14 |
15 | public string type;
16 |
17 | public string docUrl;
18 |
19 | public string mode;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/JsonLocation.cs:
--------------------------------------------------------------------------------
1 | namespace AutoRest.Swagger
2 | {
3 | sealed class JsonLocation
4 | {
5 | public string @ref;
6 |
7 | public string path;
8 |
9 | public string location;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/MessageTemplate.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace AutoRest.Swagger
3 | {
4 | public class MessageTemplate
5 | {
6 | public MessageTemplate()
7 | {
8 | }
9 |
10 | public MessageTemplate(int id, string code, string message, MessageType type)
11 | {
12 | Code = code;
13 | Id = id;
14 | Message = message;
15 | Type = type;
16 | }
17 |
18 | public int Id { get; set; }
19 |
20 | public string Code { get; set; }
21 |
22 | public string Message { get; set; }
23 |
24 | public MessageType Type { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/MessageType.cs:
--------------------------------------------------------------------------------
1 | namespace AutoRest.Swagger
2 | {
3 | public enum MessageType
4 | {
5 | Addition,
6 | Update,
7 | Removal
8 | }
9 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/ApiKeyLocation.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace AutoRest.Swagger.Model
5 | {
6 | public enum ApiKeyLocation
7 | {
8 | None,
9 | Query,
10 | Header
11 | }
12 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/DataType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace AutoRest.Swagger.Model
5 | {
6 | ///
7 | /// Swagger data type.
8 | ///
9 | public enum DataType
10 | {
11 | None,
12 | String,
13 | Number,
14 | Integer,
15 | Boolean,
16 | Array,
17 | File,
18 | Object
19 | }
20 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/ExternalDoc.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace AutoRest.Swagger.Model
5 | {
6 | ///
7 | /// Allows referencing an external resource for extended documentation.
8 | ///
9 | public class ExternalDoc
10 | {
11 | ///
12 | /// Url of external Swagger doc.
13 | ///
14 | public string Url { get; set; }
15 |
16 | ///
17 | /// Description of external Swagger doc.
18 | ///
19 | public string Description { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/Header.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace AutoRest.Swagger.Model
7 | {
8 | ///
9 | /// Swagger header object.
10 | ///
11 | public class Header : SwaggerObject
12 | {
13 | }
14 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/Info.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Newtonsoft.Json;
6 |
7 | namespace AutoRest.Swagger.Model
8 | {
9 | ///
10 | /// The object provides metadata about the API.
11 | /// The metadata can be used by the clients if needed, and can be presented
12 | /// in the Swagger-UI for convenience.
13 | ///
14 | public class Info : SpecObject
15 | {
16 | public string Title { get; set; }
17 |
18 | public string Version { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/OAuthFlow.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace AutoRest.Swagger.Model
5 | {
6 | public enum OAuthFlow
7 | {
8 | None,
9 | Implicit,
10 | Password,
11 | Application,
12 | AccessCode
13 | }
14 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/ParameterLocation.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace AutoRest.Swagger.Model
5 | {
6 | ///
7 | /// The location of the parameter.
8 | ///
9 | public enum ParameterLocation
10 | {
11 | None,
12 | Query,
13 | Header,
14 | Path,
15 | FormData,
16 | Body
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/SecurityDefinition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace AutoRest.Swagger.Model
7 | {
8 | ///
9 | /// Security Scheme Object - https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#security-scheme-object-
10 | ///
11 | public class SecurityDefinition
12 | {
13 | public string Description { get; set; }
14 |
15 | public string Name { get; set; }
16 |
17 | public ApiKeyLocation In { get; set; }
18 |
19 | public OAuthFlow Flow { get; set; }
20 |
21 | public string AuthorizationUrl { get; set; }
22 |
23 | public string TokenUrl { get; set; }
24 |
25 | ///
26 | /// Lists the available scopes for an OAuth2 security scheme.
27 | /// Key is scope serviceTypeName and the value is short description
28 | ///
29 | public Dictionary Scopes { get; set; }
30 | }
31 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/SecuritySchemeType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace AutoRest.Swagger.Model
5 | {
6 | public enum SecuritySchemeType
7 | {
8 | None,
9 | Basic,
10 | ApiKey,
11 | OAuth2
12 | }
13 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/SpecObject.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace AutoRest.Swagger.Model
7 | {
8 | public abstract class SpecObject : SwaggerBase
9 | {
10 | }
11 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/SwaggerBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Newtonsoft.Json;
6 | using System.Collections.Generic;
7 |
8 | namespace AutoRest.Swagger.Model
9 | {
10 | public abstract class SwaggerBase
11 | {
12 | public SwaggerBase()
13 | {
14 | Extensions = new Dictionary();
15 | }
16 |
17 | ///
18 | /// Vendor extensions.
19 | ///
20 | [JsonExtensionData]
21 | public Dictionary Extensions { get; set; }
22 |
23 | ///
24 | /// Compare a modified document node (this) to a previous one and look for breaking as well as non-breaking changes.
25 | ///
26 | /// The modified document context.
27 | /// The original document model.
28 | /// A list of messages from the comparison.
29 | public virtual IEnumerable Compare(
30 | ComparisonContext context,
31 | T previous
32 | )
33 | {
34 | if (previous == null)
35 | throw new ArgumentNullException("previous");
36 | if (context == null)
37 | throw new ArgumentNullException("context");
38 |
39 | yield break;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/TransferProtocolScheme.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | namespace AutoRest.Swagger.Model
5 | {
6 | ///
7 | /// The transfer protocol of the API.
8 | ///
9 | public enum TransferProtocolScheme
10 | {
11 | None,
12 | Http,
13 | Https,
14 | Ws,
15 | Wss
16 | }
17 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/Model/XmsEnumExtension.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel;
8 |
9 | namespace AutoRest.Swagger.Model
10 | {
11 | ///
12 | /// The object provides metadata about the API.
13 | /// The metadata can be used by the clients if needed, and can be presented
14 | /// in the Swagger-UI for convenience.
15 | ///
16 |
17 | public class XmsEnumValue
18 | {
19 | public dynamic value;
20 | public string description;
21 | public string name;
22 | }
23 |
24 | public class XmsEnumExtension
25 | {
26 | public string Name { get; set; }
27 |
28 | [DefaultValue(true)]
29 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
30 | public Boolean ModelAsString { get; set; }
31 |
32 | public IList values { get; set; }
33 | }
34 | }
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/SwaggerModeler.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using AutoRest.Swagger.Model;
5 | using OpenApiDiff.Core;
6 | using System.Collections.Generic;
7 |
8 | namespace AutoRest.Swagger
9 | {
10 | public class SwaggerModeler
11 | {
12 | ///
13 | /// Copares two versions of the same service specification.
14 | ///
15 | /// a file name of the old swagger document
16 | /// a content of the old swagger document
17 | /// a file name of the new swagger document
18 | /// a content of the new swagger document
19 | ///
20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
21 | public IEnumerable Compare(
22 | string fileNameOld,
23 | string swaggerOld,
24 | string fileNameNew,
25 | string swaggerNew,
26 | Settings settings = null
27 | )
28 | {
29 | var oldDefintion = SwaggerParser.Parse(swaggerOld, fileNameOld);
30 | var newDefintion = SwaggerParser.Parse(swaggerNew, fileNameNew);
31 |
32 | var context = new ComparisonContext(oldDefintion, newDefintion, settings);
33 |
34 | var comparisonMessages = newDefintion.Typed.Compare(context, oldDefintion.Typed);
35 |
36 | return comparisonMessages;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/SwaggerParser.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using AutoRest.Swagger.Model;
6 | using Newtonsoft.Json;
7 | using Newtonsoft.Json.Linq;
8 | using OpenApiDiff.Core;
9 | using AutoRest.Swagger.JsonConverters;
10 |
11 | namespace AutoRest.Swagger
12 | {
13 | public static class SwaggerParser
14 | {
15 | public static JsonDocument Parse(string swaggerDocument, string fileName)
16 | {
17 | var settings = new JsonSerializerSettings
18 | {
19 | TypeNameHandling = TypeNameHandling.None,
20 | MetadataPropertyHandling = MetadataPropertyHandling.Ignore
21 | };
22 | settings.Converters.Add(new PathLevelParameterConverter(swaggerDocument));
23 |
24 | var raw = JToken.Parse(swaggerDocument);
25 |
26 | var swagger = JsonConvert.DeserializeObject(swaggerDocument, settings);
27 |
28 | return raw.ToJsonDocument(
29 | swagger,
30 | fileName
31 | );
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/openapi-diff/src/modeler/AutoRest.Swagger/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/openapi-diff/tools/MSSharedLibKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure/openapi-diff/c048232a23595e0ce4568f0ab18baa4b2cf7cc03/openapi-diff/tools/MSSharedLibKey.snk
--------------------------------------------------------------------------------
/src/cli.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | // Licensed under the MIT License. See License.txt in the project root for license information.
5 |
6 | import yargs from "yargs"
7 | import { log } from "./lib/util/logging"
8 |
9 | const defaultLogDir = log.directory
10 | const packageVersion = require("../package.json").version
11 |
12 | yargs
13 | .version(packageVersion)
14 | .commandDir("lib/commands")
15 | .option("h", { alias: "help" })
16 | .option("l", {
17 | alias: "logLevel",
18 | describe: "Set the logging level for console.",
19 | choices: ["off", "json", "error", "warn", "info", "verbose", "debug", "silly"],
20 | default: "warn"
21 | })
22 | .option("f", {
23 | alias: "logFilepath",
24 | describe:
25 | `Set the log file path. It must be an absolute filepath. ` +
26 | `By default the logs will stored in a timestamp based log file at "${defaultLogDir}".`
27 | })
28 | .global(["h", "l", "f"])
29 | .help().argv
30 |
31 | if (yargs.argv._.length === 0 && yargs.argv.h === false) {
32 | yargs.coerce("help", function (arg) {
33 | return true
34 | }).argv
35 | }
36 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | // Easy to use methods from validate.js
5 | export { log } from "./lib/util/logging"
6 | export { compare, compareTags } from "./lib/validate"
7 |
8 | // Classes
9 | export { OpenApiDiff, Messages, Message, ChangeProperties } from "./lib/validators/openApiDiff"
10 |
11 | // Constants
12 | export const Constants = require("./lib/util/constants")
13 |
--------------------------------------------------------------------------------
/src/lib/commands/oad.ts:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License. See License.txt in the project root for license information.
3 |
4 | import { log } from "../util/logging"
5 | import { compareTags, compare } from "../validate"
6 |
7 | export const command = "compare "
8 |
9 | export const describe = "Compares old and new open api specification for breaking changes."
10 |
11 | export const builder = {
12 | j: {
13 | alias: "inJson",
14 | describe: "A boolean flag indicating whether output format of the messages is json.",
15 | boolean: true,
16 | default: true
17 | },
18 | o: {
19 | alias: "oldTagName",
20 | describe: "The tag name for the old specification file. If included it indicates that the old spec file is a readme file"
21 | },
22 | n: {
23 | alias: "newTagName",
24 | describe: "The tag name for the new specification file. If included it indicates that the new spec file is a readme file"
25 | }
26 | }
27 |
28 | export type Argv = {
29 | readonly oldSpec: string
30 | readonly o?: string
31 | readonly newSpec: string
32 | readonly n?: string
33 | readonly logLevel?: unknown
34 | readonly f?: unknown
35 | readonly j?: unknown
36 | }
37 |
38 | export const handler = (argv: Argv) => {
39 | log.debug(argv)
40 | const oldSpec = argv.oldSpec
41 | const oldTag = argv.o
42 | const newSpec = argv.newSpec
43 | const newTag = argv.n
44 | const vOptions = {
45 | consoleLogLevel: argv.logLevel,
46 | logFilepath: argv.f,
47 | json: argv.j
48 | }
49 |
50 | const compareFunc = oldTag && newTag ? compareTags(oldSpec, oldTag, newSpec, newTag, vOptions) : compare(oldSpec, newSpec, vOptions)
51 |
52 | return compareFunc
53 | .then(result => {
54 | console.log(result)
55 | })
56 | .catch(err => {
57 | console.log(err)
58 | process.exitCode = 1
59 | })
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/compatiblePropertiesTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | // This test is part of regression test suite for https://github.com/Azure/azure-sdk-tools/issues/5981
7 | // Given a property with given type and name
8 | // When another property with the same name and compatible type is referenced
9 | // Then no issue is reported, as this is a valid scenario
10 | //
11 | // Also ensures that $ref are resolved when determining if types are compatible.
12 | // For example, these should be compatible:
13 | // 1. "bar": { "type":"string" }
14 | // 2. "bar": { "$ref":"#/definitions/MyString" }, "MyString": { "type": "string" }
15 | test("compatible-properties", async () => {
16 | const diff = new OpenApiDiff({})
17 | const file = "src/test/specs/compatible-properties.json"
18 | const resultStr = await diff.compare(file, file)
19 | const result = JSON.parse(resultStr)
20 | const filePath = fileUrl(path.resolve(file))
21 | const expected = [
22 | {
23 | code: "NoVersionChange",
24 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1001.md",
25 | id: "1001",
26 | message: "The versions have not changed.",
27 | mode: "Update",
28 | new: {
29 | ref: `${filePath}#`,
30 | path: "",
31 | location: `${filePath}:1:1`
32 | },
33 | old: {
34 | ref: `${filePath}#`,
35 | path: "",
36 | location: `${filePath}:1:1`
37 | },
38 | type: "Info"
39 | }
40 | ]
41 | assert.deepStrictEqual(result, expected)
42 | })
43 |
--------------------------------------------------------------------------------
/src/test/fileUrl.ts:
--------------------------------------------------------------------------------
1 | export const fileUrl = (absPath: string) => {
2 | return "file:///" + absPath.replace(/^\//, "").split("\\").join("/")
3 | }
4 |
--------------------------------------------------------------------------------
/src/test/full2ReversedTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import { Messages, OpenApiDiff } from ".."
3 |
4 | test("full2 reversed", async () => {
5 | const source = {
6 | url: "src/test/specs/full2/target/readme.md",
7 | tag: "package-compute-2018-04"
8 | }
9 |
10 | const target = {
11 | url: "src/test/specs/full2/source/readme.md",
12 | tag: "package-compute-only-2017-12"
13 | }
14 |
15 | const diff = new OpenApiDiff({})
16 | const resultStr = await diff.compare(source.url, target.url, source.tag, target.tag)
17 | const result: Messages = JSON.parse(resultStr)
18 | for (const v of result) {
19 | assert.deepStrictEqual(v.old.location !== undefined || v.new.location !== undefined, true)
20 | }
21 | })
22 |
--------------------------------------------------------------------------------
/src/test/full2Test.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import { Messages, OpenApiDiff } from ".."
3 |
4 | test("full2", async () => {
5 | const source = {
6 | url: "src/test/specs/full2/source/readme.md",
7 | tag: "package-compute-only-2017-12"
8 | }
9 |
10 | const target = {
11 | url: "src/test/specs/full2/target/readme.md",
12 | tag: "package-compute-2018-04"
13 | }
14 |
15 | const diff = new OpenApiDiff({})
16 | const resultStr = await diff.compare(source.url, target.url, source.tag, target.tag)
17 | const result: Messages = JSON.parse(resultStr)
18 | for (const v of result) {
19 | assert.deepStrictEqual(v.old.location !== undefined || v.new.location !== undefined, true)
20 | }
21 | })
22 |
--------------------------------------------------------------------------------
/src/test/fullReversedTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | test("full reversed", async () => {
7 | const oldFile = "src/test/specs/full/new/readme.md"
8 | const newFile = "src/test/specs/full/old/readme.md"
9 | const diff = new OpenApiDiff({})
10 | const resultStr = await diff.compare(oldFile, newFile, "2019", "2019")
11 | const result = JSON.parse(resultStr)
12 | const oldFilePath = fileUrl(path.resolve("src/test/specs/full/new/openapi.json"))
13 | const oldFilePath2 = fileUrl(path.resolve("src/test/specs/full/new/openapi2.json"))
14 | const newFilePath = fileUrl(path.resolve("src/test/specs/full/old/openapi.json"))
15 | const expected = [
16 | {
17 | code: "NoVersionChange",
18 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1001.md",
19 | id: "1001",
20 | message: "The versions have not changed.",
21 | mode: "Update",
22 | new: {
23 | ref: `${newFilePath}#`,
24 | location: `${newFilePath}:1:1`,
25 | path: ""
26 | },
27 | old: {
28 | ref: `${oldFilePath}#`,
29 | location: `${oldFilePath}:1:1`,
30 | path: ""
31 | },
32 | type: "Info"
33 | },
34 | {
35 | code: "RemovedPath",
36 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1005.md",
37 | id: "1005",
38 | message: "The new version is missing a path that was found in the old version. Was path '/x' removed or restructured?",
39 | mode: "Removal",
40 | old: {
41 | location: `${oldFilePath2}:8:5`,
42 | path: "paths./x",
43 | ref: `${oldFilePath2}#/paths/~1x`
44 | },
45 | new: {},
46 | type: "Error"
47 | }
48 | ]
49 | assert.deepStrictEqual(result, expected)
50 | })
51 |
--------------------------------------------------------------------------------
/src/test/fullTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | test("full", async () => {
7 | const oldFile = "src/test/specs/full/old/readme.md"
8 | const newFile = "src/test/specs/full/new/readme.md"
9 | const diff = new OpenApiDiff({})
10 | const resultStr = await diff.compare(oldFile, newFile, "2019", "2019")
11 | const result = JSON.parse(resultStr)
12 | const newFilePath = fileUrl(path.resolve("src/test/specs/full/new/openapi.json").replace(/^\//, ""))
13 | const newFilePath2 = fileUrl(path.resolve("src/test/specs/full/new/openapi2.json"))
14 | const oldFilePath = fileUrl(path.resolve("src/test/specs/full/old/openapi.json"))
15 | const expected = [
16 | {
17 | code: "NoVersionChange",
18 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1001.md",
19 | id: "1001",
20 | message: "The versions have not changed.",
21 | mode: "Update",
22 | new: {
23 | ref: `${newFilePath}#`,
24 | location: `${newFilePath}:1:1`,
25 | path: ""
26 | },
27 | old: {
28 | ref: `${oldFilePath}#`,
29 | location: `${oldFilePath}:1:1`,
30 | path: ""
31 | },
32 | type: "Info"
33 | },
34 | {
35 | code: "AddedPath",
36 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1038.md",
37 | id: "1038",
38 | message: "The new version is adding a path that was not found in the old version.",
39 | mode: "Addition",
40 | new: {
41 | location: `${newFilePath2}:8:5`,
42 | path: "paths./x",
43 | ref: `${newFilePath2}#/paths/~1x`
44 | },
45 | old: {},
46 | type: "Info"
47 | }
48 | ]
49 | assert.deepStrictEqual(result, expected)
50 | })
51 |
--------------------------------------------------------------------------------
/src/test/operationLocationTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from "../index"
4 | import { fileUrl } from "./fileUrl"
5 |
6 | // Regression test for bug #310
7 | test("diffing a spec with operation-location bug with itself does not throw", async () => {
8 | const diff = new OpenApiDiff({})
9 | const file = "src/test/specs/operation-location.json"
10 | const resultStr = await diff.compare(file, file)
11 | const result = JSON.parse(resultStr)
12 | const filePath = fileUrl(path.resolve(file))
13 | const expected = [
14 | {
15 | code: "NoVersionChange",
16 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1001.md",
17 | id: "1001",
18 | message: "The versions have not changed.",
19 | mode: "Update",
20 | new: {
21 | ref: `${filePath}#`,
22 | path: "",
23 | location: `${filePath}:1:1`
24 | },
25 | old: {
26 | ref: `${filePath}#`,
27 | path: "",
28 | location: `${filePath}:1:1`
29 | },
30 | type: "Info"
31 | }
32 | ]
33 | assert.deepStrictEqual(result, expected)
34 | })
35 |
--------------------------------------------------------------------------------
/src/test/requestBodyFormatNoLongerSupportedTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | test("flags 1003 - RequestBodyFormatNoLongerSupported", async () => {
7 | const diff = new OpenApiDiff({})
8 | const oldFile = "src/test/specs/rule-1003/case1.old.json"
9 | const newFile = "src/test/specs/rule-1003/case1.new.json"
10 | const resultStr = await diff.compare(oldFile, newFile)
11 | const result = JSON.parse(resultStr)
12 | const newFilePath = fileUrl(path.resolve(newFile))
13 | const oldFilePath = fileUrl(path.resolve(oldFile))
14 | const expected = [
15 | {
16 | id: "1003",
17 | code: "RequestBodyFormatNoLongerSupported",
18 | message: "The new version does not support 'text/plain' as a request body format.",
19 | mode: "Removal",
20 | old: {
21 | ref: `${oldFilePath}#/consumes`,
22 | path: "paths./pets.post.consumes",
23 | location: `${oldFilePath}:7:3`
24 | },
25 | new: {
26 | ref: `${newFilePath}#/consumes`,
27 | path: "paths./pets.post.consumes",
28 | location: `${newFilePath}:7:3`
29 | },
30 | type: "Warning",
31 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1003.md"
32 | }
33 | ]
34 | assert.deepStrictEqual(result, expected)
35 | })
36 |
--------------------------------------------------------------------------------
/src/test/responseBodyFormatNowSupportedTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | test("flags 1004 - ResponseBodyFormatNowSupported", async () => {
7 | const diff = new OpenApiDiff({})
8 | const oldFile = "src/test/specs/rule-1004/case1.old.json"
9 | const newFile = "src/test/specs/rule-1004/case1.new.json"
10 | const resultStr = await diff.compare(oldFile, newFile)
11 | const result = JSON.parse(resultStr)
12 | const newFilePath = fileUrl(path.resolve(newFile))
13 | const oldFilePath = fileUrl(path.resolve(oldFile))
14 | const expected = [
15 | {
16 | id: "1004",
17 | code: "ResponseBodyFormatNowSupported",
18 | message: "The old version did not support 'text/plain' as a response body format.",
19 | mode: "Addition",
20 | old: {
21 | ref: `${oldFilePath}#/produces`,
22 | path: "paths./pets.get.produces",
23 | location: `${oldFilePath}:7:3`
24 | },
25 | new: {
26 | ref: `${newFilePath}#/produces`,
27 | path: "paths./pets.get.produces",
28 | location: `${newFilePath}:7:3`
29 | },
30 | type: "Warning",
31 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1004.md"
32 | }
33 | ]
34 | assert.deepStrictEqual(result, expected)
35 | })
36 |
--------------------------------------------------------------------------------
/src/test/simpleTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | test("simple", async () => {
7 | const diff = new OpenApiDiff({})
8 | const file = "src/test/specs/simple.json"
9 | const resultStr = await diff.compare(file, file)
10 | const result = JSON.parse(resultStr)
11 | const filePath = fileUrl(path.resolve(file))
12 | const expected = [
13 | {
14 | code: "NoVersionChange",
15 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1001.md",
16 | id: "1001",
17 | message: "The versions have not changed.",
18 | mode: "Update",
19 | new: {
20 | ref: `${filePath}#`,
21 | path: "",
22 | location: `${filePath}:1:1`
23 | },
24 | old: {
25 | ref: `${filePath}#`,
26 | path: "",
27 | location: `${filePath}:1:1`
28 | },
29 | type: "Info"
30 | }
31 | ]
32 | assert.deepStrictEqual(result, expected)
33 | })
34 |
--------------------------------------------------------------------------------
/src/test/someChangesTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | test("some-changes", async () => {
7 | const diff = new OpenApiDiff({})
8 | const oldFile = "src/test/specs/some-changes/old.json"
9 | const newFile = "src/test/specs/some-changes/new.json"
10 | const resultStr = await diff.compare(oldFile, newFile)
11 | const result = JSON.parse(resultStr)
12 | const newFilePath = fileUrl(path.resolve(newFile))
13 | const oldFilePath = fileUrl(path.resolve(oldFile))
14 | const expected = [
15 | {
16 | code: "NoVersionChange",
17 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1001.md",
18 | id: "1001",
19 | message: "The versions have not changed.",
20 | mode: "Update",
21 | new: {
22 | ref: `${newFilePath}#`,
23 | location: `${newFilePath}:1:1`,
24 | path: ""
25 | },
26 | old: {
27 | ref: `${oldFilePath}#`,
28 | location: `${oldFilePath}:1:1`,
29 | path: ""
30 | },
31 | type: "Info"
32 | },
33 | {
34 | code: "AddedPath",
35 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1038.md",
36 | id: "1038",
37 | message: "The new version is adding a path that was not found in the old version.",
38 | mode: "Addition",
39 | new: {
40 | location: `${newFilePath}:8:5`,
41 | path: "paths./x",
42 | ref: `${newFilePath}#/paths/~1x`
43 | },
44 | old: {},
45 | type: "Info"
46 | }
47 | ]
48 | assert.deepStrictEqual(result, expected)
49 | })
50 |
--------------------------------------------------------------------------------
/src/test/specs/additional-properties/new.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "common_parameter_check_04",
5 | "version": "1.0"
6 | },
7 | "parameters": {
8 | "P0": {
9 | "name": "p0",
10 | "in": "query",
11 | "type": "string"
12 | },
13 | "P2": {
14 | "name": "p2",
15 | "in": "body",
16 | "schema": {
17 | "type": "object",
18 | "additionalProperties": true
19 | }
20 | }
21 | },
22 | "host": "localhost:8000",
23 | "schemes": [ "http", "https" ],
24 | "paths": {
25 | "/api/Operations": {
26 | "parameters": [
27 | {
28 | "$ref": "#/parameters/P0"
29 | },
30 | {
31 | "$ref": "#/parameters/P2"
32 | }
33 | ],
34 | "get": {
35 | "operationId": "Operations_Get",
36 | "produces": [
37 | "text/plain"
38 | ],
39 | "responses": {
40 | "default": {
41 | "description": "Error response describing why the operation failed.",
42 | "schema": {
43 | "additionalProperties": true
44 | }
45 | },
46 | "200": {
47 | "description": "operation successfully .",
48 | "schema": {
49 | "$ref":"#/definitions/Foo"
50 | }
51 | }
52 | }
53 | }
54 | }
55 | },
56 | "definitions": {
57 | "Foo": {
58 | "type":"object",
59 | "properties": {
60 | "bar": {
61 | "type":"object",
62 | "additionalProperties":true
63 | }
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/test/specs/additional-properties/old.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "common_parameter_check_04",
5 | "version": "1.0"
6 | },
7 | "parameters": {
8 | "P0": {
9 | "name": "p0",
10 | "in": "query",
11 | "type": "string"
12 | },
13 | "P2": {
14 | "name": "p2",
15 | "in": "body",
16 | "schema": {
17 | "type": "object",
18 | "additionalProperties": false
19 | }
20 | }
21 | },
22 | "host": "localhost:8000",
23 | "schemes": [ "http", "https" ],
24 | "paths": {
25 | "/api/Operations": {
26 | "parameters": [
27 | {
28 | "$ref": "#/parameters/P0"
29 | },
30 | {
31 | "$ref": "#/parameters/P2"
32 | }
33 | ],
34 | "get": {
35 | "operationId": "Operations_Get",
36 | "produces": [
37 | "text/plain"
38 | ],
39 | "responses": {
40 | "default": {
41 | "description": "Error response describing why the operation failed.",
42 | "schema": {
43 | "additionalProperties": true
44 | }
45 | },
46 | "200": {
47 | "description": "operation successfully .",
48 | "schema": {
49 | "$ref":"#/definitions/Foo"
50 | }
51 | }
52 | }
53 | }
54 | }
55 | },
56 | "definitions": {
57 | "Foo": {
58 | "type":"object",
59 | "properties": {
60 | "bar": {
61 | "type":"object",
62 | "additionalProperties":true
63 | }
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/test/specs/common-parameters/new.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "common_parameter_check_04",
5 | "version": "1.0"
6 | },
7 | "parameters": {
8 | "P0": {
9 | "name": "p0",
10 | "in": "query",
11 | "type": "string"
12 | },
13 | "P2": {
14 | "name": "p2",
15 | "in": "query",
16 | "type": "string"
17 | }
18 | },
19 | "host": "localhost:8000",
20 | "schemes": [ "http", "https" ],
21 | "paths": {
22 | "/api/Operations": {
23 | "parameters": [
24 | {
25 | "$ref": "#/parameters/P0"
26 | },
27 | {
28 | "$ref": "#/parameters/P2"
29 | }
30 | ],
31 | "get": {
32 | "operationId": "Operations_Get",
33 | "produces": [
34 | "text/plain"
35 | ],
36 | "responses": {
37 | "default": {
38 | "description": "Error response describing why the operation failed.",
39 | "schema": {}
40 | }
41 | }
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/specs/common-parameters/old.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "common_parameter_check_04",
5 | "version": "1.0"
6 | },
7 | "parameters": {
8 | "P0": {
9 | "name": "p0",
10 | "in": "query",
11 | "type": "string"
12 | },
13 | "P1": {
14 | "name": "p1",
15 | "in": "query",
16 | "type": "string"
17 | }
18 | },
19 | "host": "localhost:8000",
20 | "schemes": [ "http", "https" ],
21 | "paths": {
22 | "/api/Operations": {
23 | "parameters": [
24 | {
25 | "$ref": "#/parameters/P0"
26 | },
27 | {
28 | "$ref": "#/parameters/P1"
29 | }
30 | ],
31 | "get": {
32 | "operationId": "Operations_Get",
33 | "produces": [
34 | "text/plain"
35 | ],
36 | "responses": {
37 | "default": {
38 | "description": "Error response describing why the operation failed.",
39 | "schema": {
40 | }
41 | }
42 | }
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/specs/compatible-properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "compatible-properties",
5 | "version": "1.0"
6 | },
7 | "paths": {
8 | },
9 | "definitions": {
10 | "Foo": {
11 | "type":"object",
12 | "properties": {
13 | "string-string": {
14 | "type":"string"
15 | },
16 | "string-refstring": {
17 | "type":"string"
18 | },
19 | "refstring-string": {
20 | "$ref": "#/definitions/MyString"
21 | },
22 | "refstring-refstring": {
23 | "$ref": "#/definitions/MyString"
24 | }
25 | },
26 | "allOf": [
27 | {
28 | "$ref": "#/definitions/Foo2"
29 | }
30 | ]
31 | },
32 | "Foo2": {
33 | "type":"object",
34 | "properties": {
35 | "string-string": {
36 | "type":"string"
37 | },
38 | "string-refstring": {
39 | "$ref": "#/definitions/MyString"
40 | },
41 | "refstring-string": {
42 | "type":"string"
43 | },
44 | "refstring-refstring": {
45 | "$ref": "#/definitions/MyString"
46 | }
47 | }
48 | },
49 | "MyString": {
50 | "type": "string"
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/specs/expandsAllOf/new/expand_allOf_model.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tags": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "schema": { "$ref": "#/definitions/Database" }
25 | }
26 | ],
27 | "responses": {
28 | "default": {
29 | "description": "default"
30 | }
31 | }
32 | }
33 | }
34 | },
35 | "definitions": {
36 | "Database": {
37 | "properties": {
38 | "a": {
39 | "type": "string",
40 | "description": "Enum.",
41 | "enum": [ "a1", "a2", "a3" ]
42 |
43 | },
44 | "b": {
45 | "type": "string",
46 | "description": "Enum.",
47 | "enum": [ "b1" ]
48 | }
49 | },
50 | "required": [ "a","b" ]
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/specs/expandsAllOf/new/move_properties_into_allof_model.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tags": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "schema": { "$ref": "#/definitions/Database" }
25 | }
26 | ],
27 | "responses": {
28 | "default": {
29 | "description": "default response"
30 | }
31 | }
32 | }
33 | }
34 | },
35 | "definitions": {
36 | "Database": {
37 | "properties": {
38 | "a": {
39 | "type": "string",
40 | "description": "Enum.",
41 | "enum": [ "a1", "a2", "a3" ]
42 | }
43 | },
44 | "allOf":[
45 | { "$ref":"#/definitions/DataBaseProperties"}
46 | ],
47 | "required": [ "b" ]
48 | },
49 | "DataBaseProperties" :{
50 | "properties": {
51 | "b": {
52 | "type": "string",
53 | "description": "Enum.",
54 | "enum": [ "b1" ]
55 | }
56 | },
57 | "required": [ "b" ]
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/specs/expandsAllOf/new/multi_level_allOf.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tags": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "schema": { "$ref": "#/definitions/Database" }
25 | }
26 | ],
27 | "responses": {
28 | "default": {
29 | "description": "default"
30 | }
31 | }
32 | }
33 | }
34 | },
35 | "definitions": {
36 | "Database": {
37 | "properties": {
38 | "a": {
39 | "type": "string",
40 | "description": "Enum.",
41 | "enum": [ "a1", "a2", "a3" ]
42 |
43 | },
44 | "b": {
45 | "type": "string",
46 | "description": "Enum.",
47 | "enum": [ "b1" ]
48 | },
49 | "c":{
50 | "type":"integer",
51 | "format": "int32",
52 | "description": "inter"
53 | }
54 | },
55 | "required": [ "a","b" ]
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/specs/expandsAllOf/new/property_format_change.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": ["http", "https"],
9 | "consumes": ["text/plain", "text/json"],
10 | "produces": ["text/plain"],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tags": ["Parameters"],
15 | "operationId": "Parameters_Put",
16 | "produces": ["text/plain"],
17 | "parameters": [
18 | {
19 | "name": "database",
20 | "in": "body",
21 | "required": true,
22 | "schema": { "$ref": "#/definitions/Database" }
23 | }
24 | ],
25 | "responses": {
26 | "default": {
27 | "description": "default response"
28 | }
29 | }
30 | }
31 | }
32 | },
33 | "definitions": {
34 | "Database": {
35 | "properties": {
36 | "a": {
37 | "type": "string",
38 | "description": "Enum.",
39 | "enum": ["a1", "a2", "a3"]
40 | },
41 | "b": {
42 | "type": "string",
43 | "description": "Enum."
44 | }
45 | },
46 | "required": ["b","a"]
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/specs/expandsAllOf/old/expand_allOf_model.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tags": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "schema": { "$ref": "#/definitions/Database" }
25 | }
26 | ],
27 | "responses": {
28 | "default": {
29 | "description": "default"
30 | }
31 | }
32 | }
33 | }
34 | },
35 | "definitions": {
36 | "Database": {
37 | "properties": {
38 | "a": {
39 | "type": "string",
40 | "description": "Enum.",
41 | "enum": [ "a1", "a2", "a3" ]
42 | }
43 | },
44 | "allOf":[
45 | { "$ref":"#/definitions/DataBaseProperties"}
46 | ],
47 | "required": [ "a" ]
48 | },
49 | "DataBaseProperties" :{
50 | "properties" : {
51 | "b": {
52 | "type": "string",
53 | "description": "Enum.",
54 | "enum": [
55 | "b1"
56 | ]
57 | }
58 | },
59 | "required":["b"]
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/test/specs/expandsAllOf/old/move_properties_into_allof_model.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tags": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "schema": { "$ref": "#/definitions/Database" }
25 | }
26 | ],
27 | "responses": {
28 | "default": {
29 | "description": "default"
30 | }
31 | }
32 | }
33 | }
34 | },
35 | "definitions": {
36 | "Database": {
37 | "properties": {
38 | "a": {
39 | "type": "string",
40 | "description": "Enum.",
41 | "enum": [ "a1", "a2", "a3" ]
42 |
43 | },
44 | "b": {
45 | "type": "string",
46 | "description": "Enum.",
47 | "enum": [ "b1" ]
48 | }
49 | },
50 | "required": [ "b" ]
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/specs/expandsAllOf/old/multi_level_allOf.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": [ "http", "https" ],
9 | "consumes": [ "text/plain", "text/json" ],
10 | "produces": [ "text/plain" ],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tags": [ "Parameters" ],
15 | "operationId": "Parameters_Put",
16 | "produces": [
17 | "text/plain"
18 | ],
19 | "parameters": [
20 | {
21 | "name": "database",
22 | "in": "body",
23 | "required": true,
24 | "schema": { "$ref": "#/definitions/Database" }
25 | }
26 | ],
27 | "responses": {
28 | "default": {
29 | "description": "default"
30 | }
31 | }
32 | }
33 | }
34 | },
35 | "definitions": {
36 | "Database": {
37 | "properties": {
38 | "a": {
39 | "type": "string",
40 | "description": "Enum.",
41 | "enum": [ "a1", "a2", "a3" ]
42 | }
43 | },
44 | "allOf":[
45 | { "$ref":"#/definitions/BaseProperties"}
46 | ],
47 | "required": [ "a" ]
48 | },
49 | "DataBaseProperties" :{
50 | "properties" : {
51 | "b": {
52 | "type": "string",
53 | "description": "Enum.",
54 | "enum": [
55 | "b1"
56 | ]
57 | },
58 | "c":{
59 | "type":"integer",
60 | "format": "int32",
61 | "description": "inter"
62 | }
63 | },
64 | "required":["b"]
65 | },
66 | "BaseProperties" :{
67 | "allOf": [
68 | {
69 | "$ref": "#/definitions/DataBaseProperties"
70 | }
71 | ]
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/test/specs/expandsAllOf/old/property_format_change.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "added_required_property",
5 | "version": "1.0"
6 | },
7 | "host": "localhost:8000",
8 | "schemes": ["http", "https"],
9 | "consumes": ["text/plain", "text/json"],
10 | "produces": ["text/plain"],
11 | "paths": {
12 | "/api/Parameters": {
13 | "put": {
14 | "tags": ["Parameters"],
15 | "operationId": "Parameters_Put",
16 | "produces": ["text/plain"],
17 | "parameters": [
18 | {
19 | "name": "database",
20 | "in": "body",
21 | "required": true,
22 | "schema": { "$ref": "#/definitions/Database" }
23 | }
24 | ],
25 | "responses": {
26 | "default": {
27 | "description": "default response"
28 | }
29 | }
30 | }
31 | }
32 | },
33 | "definitions": {
34 | "Database": {
35 | "properties": {
36 | "a": {
37 | "type": "string",
38 | "description": "Enum.",
39 | "enum": ["a1", "a2", "a3"]
40 | }
41 | },
42 | "allOf": [{ "$ref": "#/definitions/DataBaseProperties" }],
43 | "required": ["b"]
44 | },
45 | "DataBaseProperties": {
46 | "properties": {
47 | "b": {
48 | "type": "integer",
49 | "description": "Enum.",
50 | "format": "int32"
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/specs/full/new/openapi.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "0"
6 | },
7 | "paths": {
8 | }
9 | }
--------------------------------------------------------------------------------
/src/test/specs/full/new/openapi2.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "0"
6 | },
7 | "paths": {
8 | "/x": {
9 |
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/test/specs/full/new/readme.md:
--------------------------------------------------------------------------------
1 | # New
2 |
3 | > see https://aka.ms/autorest
4 |
5 | ```yaml $(tag) == '2019'
6 | input-file:
7 | - openapi.json
8 | - openapi2.json
9 | ```
--------------------------------------------------------------------------------
/src/test/specs/full/old/openapi.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "0"
6 | },
7 | "paths": {}
8 | }
--------------------------------------------------------------------------------
/src/test/specs/full/old/readme.md:
--------------------------------------------------------------------------------
1 | # Old
2 |
3 | > see https://aka.ms/autorest
4 |
5 | ```yaml $(tag) == '2019'
6 | input-file:
7 | - openapi.json
8 | ```
9 |
--------------------------------------------------------------------------------
/src/test/specs/incompatible-properties/refstring-object.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "incompatible-properties-refstring-object",
5 | "version": "1.0"
6 | },
7 | "paths": {},
8 | "definitions": {
9 | "Foo": {
10 | "type": "object",
11 | "properties": {
12 | "refstring-object": {
13 | "$ref": "#/definitions/MyString"
14 | }
15 | },
16 | "allOf": [
17 | {
18 | "$ref": "#/definitions/Foo2"
19 | }
20 | ]
21 | },
22 | "Foo2": {
23 | "type": "object",
24 | "properties": {
25 | "refstring-object": {
26 | "type": "object"
27 | }
28 | }
29 | },
30 | "MyString": {
31 | "type": "string"
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/specs/incompatible-properties/refstring-refobject.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "incompatible-properties-refstring-refobject",
5 | "version": "1.0"
6 | },
7 | "paths": {},
8 | "definitions": {
9 | "Foo": {
10 | "type": "object",
11 | "properties": {
12 | "refstring-refobject": {
13 | "$ref": "#/definitions/MyString"
14 | }
15 | },
16 | "allOf": [
17 | {
18 | "$ref": "#/definitions/Foo2"
19 | }
20 | ]
21 | },
22 | "Foo2": {
23 | "type": "object",
24 | "properties": {
25 | "refstring-refobject": {
26 | "$ref": "#/definitions/MyObject"
27 | }
28 | }
29 | },
30 | "MyObject": {
31 | "type": "object"
32 | },
33 | "MyString": {
34 | "type": "string"
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/specs/incompatible-properties/string-object.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "incompatible-properties-string-object",
5 | "version": "1.0"
6 | },
7 | "paths": {},
8 | "definitions": {
9 | "Foo": {
10 | "type": "object",
11 | "properties": {
12 | "string-object": {
13 | "type": "string"
14 | }
15 | },
16 | "allOf": [
17 | {
18 | "$ref": "#/definitions/Foo2"
19 | }
20 | ]
21 | },
22 | "Foo2": {
23 | "type": "object",
24 | "properties": {
25 | "string-object": {
26 | "type": "object"
27 | }
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/specs/incompatible-properties/string-refobject.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "incompatible-properties-string-refobject",
5 | "version": "1.0"
6 | },
7 | "paths": {},
8 | "definitions": {
9 | "Foo": {
10 | "type": "object",
11 | "properties": {
12 | "string-refobject": {
13 | "type": "string"
14 | }
15 | },
16 | "allOf": [
17 | {
18 | "$ref": "#/definitions/Foo2"
19 | }
20 | ]
21 | },
22 | "Foo2": {
23 | "type": "object",
24 | "properties": {
25 | "string-refobject": {
26 | "$ref": "#/definitions/MyObject"
27 | }
28 | }
29 | },
30 | "MyObject": {
31 | "type": "object"
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/specs/operation-location.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "operation-location",
5 | "version": "1.0"
6 | },
7 | "paths": {
8 | "/foo": {
9 | "post": {
10 | "responses": {
11 | "201": {
12 | "description": "Created",
13 | "schema": {
14 | "$ref": "#/definitions/Consent"
15 | },
16 | "headers": {
17 | "Operation-Id": {
18 | "type": "string",
19 | "description": "ID of the operation."
20 | },
21 | "Operation-Location": {
22 | "description": "The location of the operation job. Use this URL to monitor operation status.",
23 | "type": "string",
24 | "format": "uri"
25 | }
26 | }
27 | },
28 | "default": {
29 | "description": "An error occurred.",
30 | "schema": {
31 | "$ref": "#/definitions/ErrorResponse"
32 | }
33 | }
34 | },
35 | "x-ms-long-running-operation": true,
36 | "x-ms-long-running-operation-options": {
37 | "final-state-via": "operation-location"
38 | }
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/specs/rule-1003/case1.new.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "2021-06-26"
6 | },
7 | "consumes":[
8 | "application/json"
9 | ],
10 | "paths": {
11 | "/pets": {
12 | "post": {
13 | "summary": "post",
14 | "operationId": "post_pets",
15 | "parameters": [
16 | {
17 | "name": "body",
18 | "in": "body",
19 | "required": true,
20 | "description": "body",
21 | "schema": {
22 | "description": "body"
23 | }
24 | }
25 | ],
26 | "responses": {
27 | "200": {
28 | "description": "success"
29 | }
30 | }
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/test/specs/rule-1003/case1.old.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "2021-06-25"
6 | },
7 | "consumes":[
8 | "application/json",
9 | "text/plain"
10 | ],
11 | "paths": {
12 | "/pets": {
13 | "post": {
14 | "summary": "post",
15 | "operationId": "post_pets",
16 | "parameters": [
17 | {
18 | "name": "body",
19 | "in": "body",
20 | "required": true,
21 | "description": "body",
22 | "schema": {
23 | "description": "body"
24 | }
25 | }
26 | ],
27 | "responses": {
28 | "200": {
29 | "description": "success"
30 | }
31 | }
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/src/test/specs/rule-1004/case1.new.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "2021-06-26"
6 | },
7 | "produces":[
8 | "application/json",
9 | "text/plain"
10 | ],
11 | "paths": {
12 | "/pets": {
13 | "get": {
14 | "summary": "get",
15 | "operationId": "list_pets",
16 | "responses": {
17 | "200": {
18 | "description": "success"
19 | }
20 | }
21 | }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/test/specs/rule-1004/case1.old.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "2021-06-25"
6 | },
7 | "produces":[
8 | "application/json"
9 | ],
10 | "paths": {
11 | "/pets": {
12 | "get": {
13 | "summary": "get",
14 | "operationId": "list_pets",
15 | "responses": {
16 | "200": {
17 | "description": "success"
18 | }
19 | }
20 | }
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/test/specs/simple.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "0"
6 | },
7 | "paths": {}
8 | }
--------------------------------------------------------------------------------
/src/test/specs/some-changes/new.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "0"
6 | },
7 | "paths": {
8 | "/x": {
9 |
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/test/specs/some-changes/old.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "title",
5 | "version": "0"
6 | },
7 | "paths": {}
8 | }
--------------------------------------------------------------------------------
/src/test/specs/xms-enum-name/new.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "xms-enum-name",
5 | "version": "1.0"
6 | },
7 | "paths": {
8 | },
9 | "definitions": {
10 | "Foo": {
11 | "type":"object",
12 | "properties": {
13 | "bar": {
14 | "type":"string",
15 | "enum": [
16 | "baz"
17 | ],
18 | "x-ms-enum": {
19 | "modelAsString": false
20 | }
21 | }
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/specs/xms-enum-name/old.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "xms-enum-name",
5 | "version": "1.0"
6 | },
7 | "paths": {
8 | },
9 | "definitions": {
10 | "Foo": {
11 | "type":"object",
12 | "properties": {
13 | "bar": {
14 | "type":"string",
15 | "enum": [
16 | "baz"
17 | ],
18 | "x-ms-enum": {
19 | "name": "Foo",
20 | "modelAsString": false
21 | }
22 | }
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/specs/xmspath/new.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "common_parameter_check_04",
5 | "version": "1.0"
6 | },
7 | "parameters": {
8 | "P0": {
9 | "name": "p0",
10 | "in": "query",
11 | "type": "string"
12 | },
13 | "P2": {
14 | "name": "p2",
15 | "in": "query",
16 | "type": "string"
17 | }
18 | },
19 | "host": "localhost:8000",
20 | "schemes": [ "http", "https" ],
21 | "x-ms-paths": {
22 | "/api/Operations": {
23 | "parameters": [
24 | {
25 | "$ref": "#/parameters/P0"
26 | },
27 | {
28 | "$ref": "#/parameters/P2"
29 | }
30 | ],
31 | "get": {
32 | "operationId": "Operations_Get",
33 | "produces": [
34 | "text/plain"
35 | ],
36 | "responses": {
37 | "default": {
38 | "description": "Error response describing why the operation failed.",
39 | "schema": {}
40 | }
41 | }
42 | }
43 | },
44 | "?does-not-start-with-slash": {}
45 | },
46 | "paths": {
47 | "/api/Operations1": {
48 | "parameters": [
49 | {
50 | "$ref": "#/parameters/P0"
51 | },
52 | {
53 | "$ref": "#/parameters/P2"
54 | }
55 | ],
56 | "post": {
57 | "operationId": "Operations_Post",
58 | "produces": [
59 | "text/plain"
60 | ],
61 | "responses": {
62 | "default": {
63 | "description": "Error response describing why the operation failed.",
64 | "schema": {}
65 | }
66 | }
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/test/specs/xmspath/old.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "common_parameter_check_04",
5 | "version": "1.0"
6 | },
7 | "parameters": {
8 | "P0": {
9 | "name": "p0",
10 | "in": "query",
11 | "type": "string"
12 | },
13 | "P2": {
14 | "name": "p2",
15 | "in": "query",
16 | "type": "string"
17 | }
18 | },
19 | "host": "localhost:8000",
20 | "schemes": [ "http", "https" ],
21 | "paths": {
22 | "/api/Operations": {
23 | "parameters": [
24 | {
25 | "$ref": "#/parameters/P0"
26 | },
27 | {
28 | "$ref": "#/parameters/P2"
29 | }
30 | ],
31 | "get": {
32 | "operationId": "Operations_Get",
33 | "produces": [
34 | "text/plain"
35 | ],
36 | "responses": {
37 | "default": {
38 | "description": "Error response describing why the operation failed.",
39 | "schema": {}
40 | }
41 | }
42 | }
43 | },
44 | "/api/Operations1": {
45 | "parameters": [
46 | {
47 | "$ref": "#/parameters/P0"
48 | },
49 | {
50 | "$ref": "#/parameters/P2"
51 | }
52 | ],
53 | "post": {
54 | "operationId": "Operations_Post",
55 | "produces": [
56 | "text/plain"
57 | ],
58 | "responses": {
59 | "default": {
60 | "description": "Error response describing why the operation failed.",
61 | "schema": {}
62 | }
63 | }
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/test/utilTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import { pathToJsonPointer } from "../lib/util/utils"
3 |
4 | describe("index", () => {
5 | it("get json point from json path", () => {
6 | let result = pathToJsonPointer("paths['Mircosoft.Compute/resoucemaneger'].operation.get[1].past")
7 | assert.equal(result, "/paths/Mircosoft.Compute~1resoucemaneger/operation/get/1/past")
8 | result = pathToJsonPointer("")
9 | assert.equal(result, "")
10 | result = pathToJsonPointer("paths['Mircosoft.Compute~resoucemaneger/test'].operation.get[1].past")
11 | assert.equal(result, "/paths/Mircosoft.Compute~0resoucemaneger~1test/operation/get/1/past")
12 | result = pathToJsonPointer("paths['Mircosoft.Compute~resouce.maneger/test'].operation.get[1].past")
13 | assert.equal(result, "/paths/Mircosoft.Compute~0resouce.maneger~1test/operation/get/1/past")
14 | result = pathToJsonPointer(
15 | "paths['/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}" +
16 | "/providers/Microsoft.Network/loadBalancers/{loadBalancerName}'].put.parameters[3]"
17 | )
18 | assert.equal(
19 | result,
20 | "/paths/~1subscriptions~1{subscriptionId}~1resourceGroups~1" +
21 | "{resourceGroupName}~1providers~1Microsoft.Network~1loadBalancers~1{loadBalancerName}/put/parameters/3"
22 | )
23 | })
24 | })
25 |
--------------------------------------------------------------------------------
/src/test/xmsEnumNameTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | test("xms-enum-name", async () => {
7 | const diff = new OpenApiDiff({})
8 | const oldFile = "src/test/specs/xms-enum-name/old.json"
9 | const newFile = "src/test/specs/xms-enum-name/new.json"
10 | const resultStr = await diff.compare(oldFile, newFile)
11 | const result = JSON.parse(resultStr)
12 | const newFilePath = fileUrl(path.resolve(newFile))
13 | const oldFilePath = fileUrl(path.resolve(oldFile))
14 | const expected = [
15 | {
16 | code: "NoVersionChange",
17 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1001.md",
18 | id: "1001",
19 | message: "The versions have not changed.",
20 | mode: "Update",
21 | new: {
22 | ref: `${newFilePath}#`,
23 | path: "",
24 | location: `${newFilePath}:1:1`
25 | },
26 | old: {
27 | ref: `${oldFilePath}#`,
28 | path: "",
29 | location: `${oldFilePath}:1:1`
30 | },
31 | type: "Info"
32 | },
33 | {
34 | code: "XmsEnumChanged",
35 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1047.md",
36 | id: "1047",
37 | message: "The new version has a different x-ms-enum 'name' than the previous one.",
38 | mode: "Update",
39 | new: {
40 | ref: `${newFilePath}#/definitions/Foo/properties/bar`,
41 | path: "definitions.Foo.properties.bar",
42 | location: `${newFilePath}:13:9`
43 | },
44 | old: {
45 | ref: `${oldFilePath}#/definitions/Foo/properties/bar`,
46 | path: "definitions.Foo.properties.bar",
47 | location: `${oldFilePath}:13:9`
48 | },
49 | type: "Error"
50 | }
51 | ]
52 | assert.deepStrictEqual(result, expected)
53 | })
54 |
--------------------------------------------------------------------------------
/src/test/xmsPathTest.ts:
--------------------------------------------------------------------------------
1 | import * as assert from "assert"
2 | import * as path from "path"
3 | import { OpenApiDiff } from ".."
4 | import { fileUrl } from "./fileUrl"
5 |
6 | test("xms-path", async () => {
7 | const diff = new OpenApiDiff({})
8 | const oldFile = "src/test/specs/xmspath/old.json"
9 | const newFile = "src/test/specs/xmspath/new.json"
10 | const resultStr = await diff.compare(oldFile, newFile)
11 | const result = JSON.parse(resultStr)
12 | const newFilePath = fileUrl(path.resolve(newFile))
13 | const oldFilePath = fileUrl(path.resolve(oldFile))
14 | const expected = [
15 | {
16 | code: "NoVersionChange",
17 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1001.md",
18 | id: "1001",
19 | message: "The versions have not changed.",
20 | mode: "Update",
21 | new: {
22 | ref: `${newFilePath}#`,
23 | location: `${newFilePath}:1:1`,
24 | path: ""
25 | },
26 | old: {
27 | ref: `${oldFilePath}#`,
28 | location: `${oldFilePath}:1:1`,
29 | path: ""
30 | },
31 | type: "Info"
32 | },
33 | {
34 | code: "AddedPath",
35 | docUrl: "https://github.com/Azure/openapi-diff/tree/master/docs/rules/1038.md",
36 | id: "1038",
37 | message: "The new version is adding a path that was not found in the old version.",
38 | mode: "Addition",
39 | new: {
40 | ref: `${newFilePath}#/x-ms-paths/?does-not-start-with-slash`,
41 | location: `${newFilePath}:44:5`,
42 | path: "paths.?does-not-start-with-slash"
43 | },
44 | old: {},
45 | type: "Info"
46 | }
47 | ]
48 | assert.deepStrictEqual(result, expected)
49 | })
50 |
--------------------------------------------------------------------------------