3.3.3 • Published 1 month ago

oav v3.3.3

Weekly downloads
3,289
License
MIT
Repository
github
Last release
1 month ago

openapi-validation-tools oav

Package version

Build Status code style: prettier

Regression: Build Status How to fix this

Tools for validating OpenAPI (Swagger) files.

Requirements

  • node.js version > 10.x

You can install the latest stable release of node.js from here. For a machine with a linux flavored OS, please follow the node.js installation instructions over here

How to install the tool

npm install -g oav@latest

Command usage:

$ oav -h    Commands:
  analyze-dependency                        analyze swagger resource type
                                            dependency.
  analyze-report <newman-report-path>       analyze report. default format:
                                            newman json report
  example-quality <spec-path>               Performs example quality validation
                                            of x-ms-examples and examples
                                            present in the spec.
  extract-xmsexamples <spec-path>           Extracts the x-ms-examples for a
  <recordings>                              given swagger from the .NET session
                                            recordings and saves them in a file.
  generate-collection                       Generate postman collection file
                                            from API scenario.
  generate-examples [spec-path]             Generate swagger examples from real
                                            payload records.
  generate-report [raw-report-path]         Generate report from postman report.
  generate-api-scenario                     Generate swagger examples from real
                                            payload records.
  generate-static-api-scenario              Generate API-scenario from swagger.
  run-api-scenario <api-scenario>           newman runner run API scenario
                                            file.                 [aliases: run]
  validate-example <spec-path>              Performs validation of x-ms-examples
                                            and examples present in the spec.
  validate-spec <spec-path>                 Performs semantic validation of the
                                            spec.
  validate-traffic <traffic-path>           Validate traffic payload against the
  <spec-path>                               spec.
  traffic-convert <input-dir>               Showcase what it would look like to 
  <output-dir>                              transform a directory full of 
                                            [azure-sdk/test-proxy](https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy) 
                                            recordings files into traffic payloads 
                                            consumable by traffic validation command in oav
  

Options:
  --version          Show version number                               [boolean]
  -l, --logLevel     Set the logging level for console.
  [choices: "off", "json", "error", "warn", "info", "verbose", "debug", "silly"]
                                                               [default: "info"]
  -f, --logFilepath  Set the log file path. It must be an absolute filepath. By
                     default the logs will stored in a timestamp based log file
                     at "/home/ruowan/oav_output".
  -p, --pretty       Pretty print
  -h, --help         Show help                                         [boolean]

What does the tool do? What issues does the tool catch?

  • Semantic validation Semantic validation enforces correctness on the swagger specific elements. Such as paths and operations. Ensure the element definition meet the OpenApi 2.0 specification.
  • Model validation Model validation enforces correctness between example and swagger. It checks whether definitions for request parameters and responses, match an expected input/output payload of the service.

    Examples of issues detected:

    • Required properties not sent in requests or responses
    • Defined types not matching the value provided in the payload
    • Constraints on properties not met
    • Enumeration values that don’t match the value used by the service.

      Model validation requires example payloads (request/response) of the service, so the data can be matched with the defined models. See x-ms-examples extension on how to specify the examples/payloads. Swagger “examples” is also supported and data included there is validated as well. To get the most benefit from this tool, make sure to have the simplest and most complex examples possible as part of x-ms-examples.

    • Please take a look at the redis-cache swagger spec as an example for providing "x-ms-examples" over here.

    • The examples need to be provided in a separate file in the examples directory under the api-version directory azure-rest-api-specs/arm-<yourService>/<api-version>/examples/<exampleName>.json. You can take a look over here for the structure of examples.

    • We require you to provide us a minimum (just required properties/parameters of the request/response) and a maximum (full blown) example. Feel free to provide more examples as deemed necessary.

    • We have provided schemas for examples to be provided in the examples directory. It can be found over here. This will help you with intellisense and validation.

    • If you are using vscode to edit your swaggers in the azure-rest-api-specs repo then everything should work out of the box as the schemas have been added in the .vscode/settings.json file over here.

    • If you are using Visual Studio then you can use the urls provided in the settings.json file and put them in the drop down list at the top of a json file when the file is opened in VS.

How does this tool fit with others

Swagger specs validation could be split in the following:

  1. Schema validation
  2. Semantic validation
  3. Model definition validation
  4. Swagger operations execution (against mocked data or live tests)
  5. Human-eye review to complement the above

In the context of “azure-rest-api-specs” repo:

  • #1 is being performed on every PR as part of CI.
  • #2 and #3 are performed by the tool currently in openapi-validation-tools repo and by AutoRest linter. We’re working towards integrating them into CI for “azure-rest-api-specs” repo.
  • #4 is not available yet, though we’re starting to work on it.
  • #5 will be done by the approvers of PRs in “azure-rest-api-specs”, as this won’t be automated.

Run API test

OAV support run API test against Azure and validate request and response. You could define API scenario file which compose with several swagger example files and then use oav to execute it. For more details about API test, please refer to this API scenario documentation.

npm.io

Live Validation Mode

  • A Live Validation mode has been added to OAV with the purpose of enabling validation of live traffic.
  • Usage (here is a sample of a request-response pair):
const liveValidatorOptions = {
  git: {
    url: "https://github.com/Azure/azure-rest-api-specs.git",
    shouldClone: true,
  },
  directory: path.resolve(os.homedir(), "cloneRepo"),
  swaggerPathsPattern: "/specification/**/resource-manager/**/*.json",
  isPathCaseSensitive: false,
  shouldModelImplicitDefaultResponse: true,
};

const apiValidator = new oav.LiveValidator(liveValidatorOptions);
await apiValidator.initialize(); // Note that for a large number of specs this can take some time.

// After `initialize()` finishes we are ready to validate
const validationResult = apiValidator.validateLiveRequestResponse(requestResponsePair);

Regression testing

Output of the OAV tool has been snapshotted and committed to the repo. The regression test may be run on a sample or all of https://github.com/azure/azure-rest-api-specs. If there are changes to the snapshots the build produces a git patch file as an artifact which may be used to update the snapshots.

Fast Regression (~10mins) is used for merge validation

Slow Regression (~1 hour) is run after merge and should be fixed if it fails

Fixing regression builds

  1. Go to the failed build
  2. Download the artifact patch file
  3. In the OAV directory run git apply <path to patch file>
  4. Commit the patched changes and create a pull request
  5. Validate that the changes look ok and don't represent a breaking change in OAV
  6. Merge the PR

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

3.3.3

1 month ago

3.3.2-beta.4

2 months ago

3.3.2-beta.3

2 months ago

3.3.2-beta.1

2 months ago

3.3.2-beta.2

2 months ago

3.2.13

6 months ago

3.2.12

6 months ago

3.3.1

4 months ago

3.3.0

5 months ago

3.2.11

9 months ago

3.2.10

9 months ago

3.2.12-beta.1

7 months ago

3.2.8

12 months ago

3.2.9-beta.1

12 months ago

3.3.0-beta.2

1 year ago

3.3.0-beta.1

1 year ago

3.3.0-beta.4

1 year ago

3.3.0-beta.3

1 year ago

3.3.0-beta.5

1 year ago

3.2.6

1 year ago

3.2.5

1 year ago

3.2.4

1 year ago

3.2.6-beta.2

1 year ago

3.2.6-beta.1

1 year ago

3.2.2

1 year ago

3.2.0

1 year ago

3.2.3

1 year ago

3.1.0

1 year ago

3.2.4-beta

1 year ago

3.2.0-beta

1 year ago

3.3.0-beta

1 year ago

3.2.1-beta

1 year ago

3.2.1-beta.3

1 year ago

3.2.1-beta.2

1 year ago

3.2.1-beta.1

1 year ago

3.1.0-beta

2 years ago

3.0.5-beta.5

2 years ago

3.0.5-beta.4

2 years ago

3.0.5-beta.3

2 years ago

3.0.5-beta.2

2 years ago

3.1.0-beta.1

2 years ago

3.1.0-beta.2

1 year ago

3.0.2-beta

2 years ago

3.0.3-beta.3

2 years ago

3.0.3-beta.1

2 years ago

3.0.3-beta.2

2 years ago

3.0.0-beta.5

2 years ago

3.0.0-beta.4

2 years ago

3.0.0-beta.7

2 years ago

3.0.0-beta.6

2 years ago

3.0.0-beta.9

2 years ago

3.0.0-beta.8

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.4-beta

2 years ago

3.0.5-beta

2 years ago

3.0.4-beta.1

2 years ago

3.0.4-beta.2

2 years ago

3.0.1-beta.1

2 years ago

3.0.1-beta.2

2 years ago

3.0.1-beta.3

2 years ago

3.0.1-beta.4

2 years ago

3.0.1-beta.5

2 years ago

3.0.1-beta.6

2 years ago

3.0.5-beta.1

2 years ago

3.0.1-beta

2 years ago

3.0.3-beta

2 years ago

2.12.2

2 years ago

3.0.0-beta.1

2 years ago

3.0.0-beta.0

2 years ago

3.0.0-beta.3

2 years ago

3.0.0-beta.2

2 years ago

2.12.0

2 years ago

2.12.1

2 years ago

2.11.9

2 years ago

2.11.10

2 years ago

2.12.0-beta.1

2 years ago

2.12.0-beta.0

2 years ago

2.12.0-beta.3

2 years ago

2.12.0-beta.2

2 years ago

2.12.0-beta.4

2 years ago

2.11.1

2 years ago

2.11.6

2 years ago

2.11.7

2 years ago

2.11.4

2 years ago

2.11.5

2 years ago

2.11.2

2 years ago

2.11.3

2 years ago

2.11.3-beta

2 years ago

2.11.0

2 years ago

2.10.2

2 years ago

2.10.3

2 years ago

2.10.1

2 years ago

2.10.0

2 years ago

2.9.0

2 years ago

2.9.1

2 years ago

2.8.3

3 years ago

2.8.2

3 years ago

2.8.1

3 years ago

2.8.0

3 years ago

2.7.2

3 years ago

2.7.0

3 years ago

2.6.1

3 years ago

2.5.9

3 years ago

2.5.8

3 years ago

2.5.7

3 years ago

2.5.6

3 years ago

2.5.5

3 years ago

2.5.4

3 years ago

2.5.3

3 years ago

2.4.0

3 years ago

2.3.3

3 years ago

0.23.2

3 years ago

2.5.0

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.3.2

3 years ago

0.23.1

3 years ago

2.3.1

3 years ago

2.3.0

3 years ago

2.2.7

3 years ago

2.2.6

3 years ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

0.22.9

3 years ago

0.22.8

3 years ago

0.22.7

4 years ago

0.22.6

4 years ago

0.22.5

4 years ago

0.22.4

4 years ago

0.22.3

4 years ago

0.22.2

4 years ago

0.22.1

4 years ago

0.21.7

4 years ago

0.21.6

4 years ago

0.21.6-beta.1

4 years ago

0.21.5

4 years ago

0.21.4-beta.1

4 years ago

0.21.4

4 years ago

0.21.3

4 years ago

0.21.2-beta.1

4 years ago

0.21.2

4 years ago

0.21.1

4 years ago

0.20.12

4 years ago

0.20.11

4 years ago

0.20.10

4 years ago

0.20.9

4 years ago

0.20.8

4 years ago

0.20.7-beta.1

4 years ago

0.20.7

4 years ago

0.20.6

4 years ago

0.20.6-beta.1

4 years ago

0.20.5-beta.2

4 years ago

0.20.5-beta.1

4 years ago

0.20.5-beta

4 years ago

0.20.4

4 years ago

0.20.3

4 years ago

0.20.2-beta.2

4 years ago

0.20.2-beta.1

4 years ago

0.20.2-beta.0

4 years ago

0.20.2

4 years ago

0.20.1

4 years ago

0.20.0

4 years ago

0.19.9

4 years ago

0.19.9-beta.1

4 years ago

0.19.8

4 years ago

0.19.7-beta.6

4 years ago

0.19.7-beta.5

4 years ago

0.19.7

4 years ago

0.19.7-beta.4

5 years ago

0.19.7-beta.3

5 years ago

0.19.7-beta.2

5 years ago

0.19.7-beta.1

5 years ago

0.19.7-beta.0

5 years ago

0.19.6

5 years ago

0.19.5

5 years ago

0.19.4

5 years ago

0.19.3

5 years ago

0.19.2

5 years ago

0.19.1

5 years ago

0.19.0

5 years ago

0.18.6

5 years ago

0.18.5

5 years ago

0.18.4

5 years ago

0.18.3

5 years ago

0.18.2

5 years ago

0.18.1

5 years ago

0.18.0

5 years ago

0.17.0

5 years ago

0.16.1

5 years ago

0.15.4

5 years ago

0.15.3

5 years ago

0.15.2

5 years ago

0.15.1

5 years ago

0.15.0

5 years ago

0.14.8

5 years ago

0.14.7

5 years ago

0.14.6

5 years ago

0.14.5

5 years ago

0.14.4

5 years ago

0.14.3

5 years ago

0.14.2

5 years ago

0.14.1

5 years ago

0.14.0

5 years ago

0.13.6

5 years ago

0.13.5

5 years ago

0.13.4

5 years ago

0.13.3

5 years ago

0.13.2

5 years ago

0.13.0

5 years ago

0.12.0

5 years ago

0.11.1

5 years ago

0.11.0

5 years ago

0.10.4

5 years ago

0.10.3

5 years ago

0.10.2

5 years ago

0.10.1

5 years ago

0.10.0

5 years ago

0.9.7

5 years ago

0.9.6

5 years ago

0.9.5

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.14

5 years ago

0.7.13

5 years ago

0.7.11

5 years ago

0.7.10

5 years ago

0.7.9

5 years ago

0.7.8

5 years ago

0.7.7

5 years ago

0.7.6

5 years ago

0.7.5

5 years ago

0.7.4

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.5

6 years ago

0.6.4

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.13

6 years ago

0.5.12

6 years ago

0.5.11

6 years ago

0.5.10

6 years ago

0.5.9

6 years ago

0.5.8

6 years ago

0.5.7

6 years ago

0.5.6

6 years ago

0.5.5

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.70

6 years ago

0.4.69

6 years ago

0.4.68

6 years ago

0.4.67

6 years ago

0.4.66

6 years ago

0.4.65

6 years ago

0.4.64

6 years ago

0.4.63

6 years ago

0.4.62

6 years ago

0.4.61

6 years ago

0.4.60

6 years ago

0.4.59

6 years ago

0.4.58

6 years ago

0.4.57

6 years ago

0.4.56

6 years ago

0.4.54

6 years ago

0.4.51

6 years ago

0.4.50

6 years ago

0.4.49

6 years ago

0.4.48

6 years ago

0.4.44

6 years ago

0.4.43

6 years ago

0.4.42

6 years ago

0.4.41

6 years ago

0.4.38

6 years ago

0.4.37

6 years ago

0.4.36

6 years ago

0.4.35

6 years ago

0.4.34

6 years ago

0.4.33

6 years ago

0.4.32

6 years ago

0.4.31

6 years ago

0.4.30

6 years ago

0.4.29

6 years ago

0.4.28

6 years ago

0.4.27

6 years ago

0.4.26

6 years ago

0.4.25

6 years ago

0.4.24

6 years ago

0.4.23

6 years ago

0.4.22

6 years ago

0.4.21

6 years ago

0.4.20

6 years ago

0.4.19

6 years ago

0.4.18

6 years ago

0.4.17

6 years ago

0.4.16

6 years ago

0.4.15

6 years ago

0.4.14

6 years ago

0.4.13

7 years ago

0.4.12

7 years ago

0.4.11

7 years ago

0.4.10

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago