Git Product home page Git Product logo

azure-openapi-arm-validator's Introduction

Contributing

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Build dependencies

  • Node (6.9.5 or higher)
  • Node Package Manager
  • Typescript (2.3.0 or higher)

Build scripts

How to build

The first step would be to run npm install so we have all the required modules installed.

How to build the whole repo

gulp build

How to build the typescript repo

gulp build/typescript

How to build the dotnet repo

To restore the dotnet packages

gulp restore/dotnet

This builds the dotnet projects.

gulp build/dotnet

How to test

To run all tests under the repo

gulp test

How to run the typescript tests

gulp test/typescript

How to run the dotnet tests

gulp test/dotnet

How to debug the dotnet repo

This extension runs the validation on two threads:

  • Individual merge state: validates each individual OpenAPI file.
  • Composed merge state: validates the full OpenAPI spec.

For debugging both composed and individual merge state at the same time

autorest input/file --validation --azure-arm-validator --use=path/to/your/repo/sr
c/dotnet/AutoRest --azure-arm-validator.debugger 

For debugging composed merge state

autorest input/file --validation --azure-arm-validator --use=path/to/your/repo/sr
c/dotnet/AutoRest --azure-arm-validator.composed-debugger 

For debugging individual merge state

autorest --input-file=path/to/swagger --validation --azure-arm-validator --use=path/to/your/repo/sr
c/dotnet/AutoRest --azure-arm-validator.individual-debugger 

How to debug the typescript repo

Temporarily change the start script in src/typescript/package.json to "start": "node --inspect-brk ./index.js". Then run:

autorest input/file --validation --azure-arm-validator --use=path/to/your/repo/src/typescript

The typescript repo can be debugged with VS Code or Chrome.

How to write a new validation rule using typescript

  1. Add a typescript file under azure-openapi-validator directory named same as the name of the rule. Add the id, name, severity, category, mergeState, openapiType, appliesTo_JsonQuery properties to the rule. appliesTo_JsonQuery is the node(s) to which the rule needs to be applied. This is evaluated using JsonPaths. Please refer here for a brief tutorial about JsonPaths.
  2. Next, implement the run method under the rule that actually does the validation. Add a reference to this script file under src/typescript/azure-openapi-validator/index.ts.
  3. Lastly add a test case for the validation rule, by adding a test json/yaml under src/typescript/azure-openapi-validator/tests/resources and a script under src/typescript/azure-openapi-validator/tests depending on the type of the validation rule.

How to publish

azure-openapi-arm-validator's People

Contributors

microsoftopensource avatar msftgits avatar sarangan12 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.