├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── ci.yml │ ├── documentation.md │ ├── feature_request.md │ └── question.md ├── PULL_REQUEST_TEMPLATE.md ├── config.yml ├── readme │ └── images │ │ ├── Layer5-MeshMentors.png │ │ ├── community.svg │ │ ├── slack-128.png │ │ └── slack-dark-128.png ├── release-drafter.yml ├── stale.yml ├── welcome │ └── Layer5-celebration.png └── workflows │ ├── build-and-release.yml │ ├── build.yml │ ├── release-drafter.yml │ └── slack.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING-gitflow.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── SECURITY.md ├── helper ├── createQuery.js ├── output.js └── toJSONSchema.js ├── index.js ├── package-lock.json └── package.json /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug Report 3 | about: Report an issue to help improve the project. 4 | title: '' 5 | labels: 'kind/bug' 6 | assignees: '' 7 | --- 8 | #### Description 9 | 10 | 11 | #### Expected Behavior 12 | 13 | 14 | #### Screenshots/Logs 15 | 16 | 17 | #### Environment: 18 | - Meshery Version: 19 | - Kubernetes Version: 20 | - Host OS: 21 | - Browser: 22 | 23 | 31 | - 🎨 Wireframes and [designs for Layer5 site](https://www.figma.com/file/5ZwEkSJwUPitURD59YHMEN/Layer5-Designs) in Figma [(open invite)](https://www.figma.com/team_invite/redeem/qJy1c95qirjgWQODApilR9) -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🛠 Continuous Integration / DevOps 3 | about: Improve or update workflows or other automation 4 | title: '[CI]' 5 | labels: 'area/ci' 6 | assignees: '' 7 | --- 8 | #### Current Behavior 9 | 10 | 11 | #### Desired Behavior 12 | 13 | 14 | #### Implementation 15 | 16 | 17 | #### Acceptance Tests 18 | 19 | 20 | #### Reference: 21 | - [Meshery Build & Release Strategy](https://docs.google.com/document/d/11nAxYtz2SUusCYZ0JeNRrOLIxkgmmbUVWz63MBZV2oE/edit#) 22 | - 🎨 Wireframes and [designs for Layer5 site](https://www.figma.com/file/5ZwEkSJwUPitURD59YHMEN/Layer5-Designs) in Figma [(open invite)](https://www.figma.com/team_invite/redeem/qJy1c95qirjgWQODApilR9) 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 📄 Documentation issue 3 | about: Issues related to documentation. 4 | title: '[Docs]' 5 | labels: 'area/docs' 6 | assignees: '' 7 | --- 8 | **Current State:** 9 | 10 | **Desired State:** 11 | 12 | --- 13 | **Contributor Resources** 14 | - [Meshery documentation site](https://docs.meshery.io/) 15 | - [Meshery documentation source](https://github.com/layer5io/meshery/tree/master/docs) 16 | - [Instructions for contributing to documentation](https://github.com/layer5io/meshery/blob/master/CONTRIBUTING.md#documentation-contribution-flow) 17 | - 🎨 Wireframes and [designs for Layer5 site](https://www.figma.com/file/5ZwEkSJwUPitURD59YHMEN/Layer5-Designs) in Figma [(open invite)](https://www.figma.com/team_invite/redeem/qJy1c95qirjgWQODApilR9) 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 💡 Feature Request 3 | about: Suggest an enhancement to Meshery. 4 | title: '' 5 | labels: 'kind/enhancement' 6 | assignees: '' 7 | --- 8 | #### Current Behavior 9 | 10 | 11 | #### Desired Behavior 12 | 13 | 14 | #### Implementation 15 | 16 | 17 | #### Acceptance Tests 18 | 19 | 20 | #### Mockups 21 | 22 | 23 | --- 24 | **[Contributor Guide](https://docs.meshery.io/project/contributing)** 25 | - 🎨 Wireframes and [designs for Layer5 site](https://www.figma.com/file/5ZwEkSJwUPitURD59YHMEN/Layer5-Designs) in Figma [(open invite)](https://www.figma.com/team_invite/redeem/qJy1c95qirjgWQODApilR9) 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: 🙋🏾🙋🏼‍Question 4 | url: https://github.com/layer5io/meshery/discussions/new 5 | about: Submit your question using GitHub Discussions. 6 | - 🎨 Wireframes and [designs for Layer5 site](https://www.figma.com/file/5ZwEkSJwUPitURD59YHMEN/Layer5-Designs) in Figma [(open invite)](https://www.figma.com/team_invite/redeem/qJy1c95qirjgWQODApilR9) -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Description** 2 | 3 | This PR fixes # 4 | 5 | **Notes for Reviewers** 6 | 7 | 8 | **[Signed commits](../CONTRIBUTING.md#signing-off-on-commits-developer-certificate-of-origin)** 9 | - [ ] Yes, I signed my commits. 10 | 11 | 12 | 24 | -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome 3 | # Comment to be posted to on first time issues 4 | newIssueWelcomeComment: > 5 | Thanks for opening this issue. A contributor will be by to give feedback soon. In the meantime, please review the [Layer5 Community Welcome Guide](https://docs.google.com/document/d/17OPtDE_rdnPQxmk2Kauhm3GwXF1R5dZ3Cj8qZLKdo5E/edit?usp=sharing) and sure to join the [community Slack](http://slack.layer5.io/). 6 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome 7 | # Comment to be posted to on PRs from first time contributors in your repository 8 | newPRWelcomeComment: > 9 | Yay, your first pull request! :thumbsup: A contributor will be by to give feedback soon. In the meantime, please review the [Layer5 Community Welcome Guide](https://docs.google.com/document/d/17OPtDE_rdnPQxmk2Kauhm3GwXF1R5dZ3Cj8qZLKdo5E/edit?usp=sharing) and sure to join the [community Slack](http://slack.layer5.io/). 10 | 11 | Be sure to double-check that you have signed your commits. Here are instructions for [making signing an implicit activity while peforming a commit](../CONTRIBUTING.md#signing-off-on-commits-developer-certificate-of-origin). 12 | 13 | 14 | #------------------------------------------------------------------------------- 15 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge 16 | # Comment to be posted to on pull requests merged by a first time user 17 | firstPRMergeComment: > 18 |         Thank you for contributing to the Layer5 community! :tada: 19 | \ 20 | \ 21 | ![Congrats!](https://github.com/layer5io/layer5/blob/master/.github/welcome/Layer5-celebration.png) 22 | \ 23 | \ 24 |         :star: Please leave a [star on the project](../stargazers). :smile: 25 | 26 | 27 | #------------------------------------------------------------------------------- 28 | # Configuration for request-info - https://github.com/behaviorbot/request-info 29 | # Comment to reply with 30 | requestInfoReplyComment: > 31 | Thanks for opening this issue. We welcome all input! If you could provide a little more information, this will greatly aide in its resolution. :thumbsup: 32 | # *OPTIONAL* Add a list of people whose Issues/PRs will not be commented on 33 | # keys must be GitHub usernames 34 | #requestInfoUserstoExclude: 35 | # - layer5io/maintainers 36 | 37 | 38 | #------------------------------------------------------------------------------- 39 | # Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot 40 | # *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic 41 | # Anything higher than this threshold will be marked as toxic and commented on 42 | sentimentBotToxicityThreshold: .9 43 | 44 | # *Required* Comment to reply with 45 | sentimentBotReplyComment: > 46 | Please be sure to review the code of conduct and be respectful of other users. // @layer5io/maintainers 47 | 48 | -------------------------------------------------------------------------------- /.github/readme/images/Layer5-MeshMentors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/layer5io/kubeopenapi-jsonschema/f4b36601234dd9c995c08db7a8ad6dc5145c7f30/.github/readme/images/Layer5-MeshMentors.png -------------------------------------------------------------------------------- /.github/readme/images/community.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/readme/images/slack-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/layer5io/kubeopenapi-jsonschema/f4b36601234dd9c995c08db7a8ad6dc5145c7f30/.github/readme/images/slack-128.png -------------------------------------------------------------------------------- /.github/readme/images/slack-dark-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/layer5io/kubeopenapi-jsonschema/f4b36601234dd9c995c08db7a8ad6dc5145c7f30/.github/readme/images/slack-dark-128.png -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: 'v$NEXT_PATCH_VERSION' 2 | tag-template: 'v$NEXT_PATCH_VERSION' 3 | categories: 4 | - title: '🚀 Features' 5 | labels: 6 | - 'kind/feature' 7 | - 'kind/enhancement' 8 | - title: '🐛 Bug Fixes' 9 | labels: 10 | - 'fix' 11 | - 'bugfix' 12 | - 'kind/bug' 13 | - title: '🧰 Maintenance' 14 | labels: 15 | - 'kind/chore' 16 | - 'chore' 17 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 18 | template: | 19 | ## What's New 20 | $CHANGES 21 | 22 | ## Contributors 23 | 24 | Thank you to our contributors for making this release possible: 25 | $CONTRIBUTORS -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 45 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 10 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - issue/willfix 8 | # Label to use when marking an issue as stale 9 | staleLabel: issue/stale 10 | # Comment to post when marking an issue as stale. Set to `false` to disable 11 | markComment: > 12 | This issue has been automatically marked as stale because it has not had 13 | recent activity. It will be closed if no further activity occurs. Thank you 14 | for your contributions. 15 | # Comment to post when closing a stale issue. Set to `false` to disable 16 | closeComment: > 17 | This issue is being automatically closed due to inactivity. 18 | However, you may choose to reopen this issue. 19 | -------------------------------------------------------------------------------- /.github/welcome/Layer5-celebration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/layer5io/kubeopenapi-jsonschema/f4b36601234dd9c995c08db7a8ad6dc5145c7f30/.github/welcome/Layer5-celebration.png -------------------------------------------------------------------------------- /.github/workflows/build-and-release.yml: -------------------------------------------------------------------------------- 1 | name: Build and Release 2 | on: 3 | release: 4 | types: [published] 5 | 6 | jobs: 7 | build_and_release: 8 | name: Build and release 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout code 12 | uses: actions/checkout@v2 13 | - name: Setup Node.js 14 | uses: actions/setup-node@v2 15 | with: 16 | node-version: 12.9.1 17 | cache: 'npm' 18 | - name: Setup dependencies 19 | run: | 20 | npm ci 21 | npm i -g nexe 22 | - name: Build artifacts 23 | run: make 24 | - name: Release artifacts 25 | uses: ncipollo/release-action@v1 26 | with: 27 | artifacts: 'kubeopenapi-jsonschema*' 28 | allowUpdates: true 29 | omitBodyDuringUpdate: true 30 | omitNameDuringUpdate: true 31 | token: ${{ secrets.GITHUB_TOKEN }} 32 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - 'master' 6 | tags: 7 | - 'v*' 8 | 9 | jobs: 10 | build: 11 | name: Build 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v3 16 | - name: Setup Node.js 17 | uses: actions/setup-node@v3.1.1 18 | with: 19 | node-version: 12.9.1 20 | cache: 'npm' 21 | - name: Setup dependencies 22 | run: | 23 | npm ci 24 | npm i -g nexe 25 | - name: Build artifacts 26 | run: make 27 | 28 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | # our release branch 6 | branches: 7 | - master 8 | 9 | jobs: 10 | update_release_draft: 11 | runs-on: ubuntu-latest 12 | steps: 13 | # Drafts your next Release notes as Pull Requests are merged into "master" 14 | - uses: release-drafter/release-drafter@v5 15 | with: 16 | config-name: release-drafter.yml 17 | env: 18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/slack.yml: -------------------------------------------------------------------------------- 1 | name: Slack Notify on Star 2 | on: watch 3 | jobs: 4 | star-notify: 5 | name: Notify Slack on star 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Get current star count 9 | run: | 10 | echo "STARS=$(curl --silent 'https://api.github.com/repos/layer5io/kubeopenapi-jsonschema' -H 'Accept: application/vnd.github.preview' | jq '.stargazers_count')" >> $GITHUB_ENV 11 | - name: Notify slack 12 | env: 13 | SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} 14 | uses: pullreminders/slack-action@master 15 | with: 16 | args: '{\"channel\":\"CSK7N9TGX\",\"text\":\"Someone just starred kubeopenapi-jsonschema! (https://github.com/layer5io/kubeopenapi-jsonschema/stargazers) Total ⭐️: ${{env.STARS}}\"}' 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | # vendor/ 16 | node_modules 17 | 18 | *.yaml 19 | openapi-jsonschema* 20 | 21 | .vscode/* -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Layer5 Community Code of Conduct 2 | 3 | The Layer5 community follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). 4 | 5 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting community@layer5.io. 6 | -------------------------------------------------------------------------------- /CONTRIBUTING-gitflow.md: -------------------------------------------------------------------------------- 1 | # Working by Forking 2 | Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or just head straight to the command line: 3 | 4 | ## Clone your fork to your local machine 5 | ``` 6 | git clone git@github.com:USERNAME/FORKED-PROJECT.git 7 | ``` 8 | Keeping Your Fork Up to Date 9 | While this isn't an absolutely necessary step, if you plan on doing anything more than just a tiny quick fix, you'll want to make sure you keep your fork up to date by tracking the original "upstream" repo that you forked. To do this, you'll need to add a remote: 10 | 11 | ## Add 'upstream' repo to list of remotes 12 | ``` 13 | git remote add upstream https://github.com/layer5io/meshery.git 14 | ``` 15 | ("meshery" is used as the example repo. Be sure to reference the _actual_ repo you're contributing to e.g. "meshery-linkerd"). 16 | 17 | ## Verify the new remote named 'upstream' 18 | ``` 19 | git remote -v 20 | ``` 21 | Whenever you want to update your fork with the latest upstream changes, you'll need to first fetch the upstream repo's branches and latest commits to bring them into your repository: 22 | 23 | ## Fetch from upstream remote 24 | ``` 25 | git fetch upstream 26 | ``` 27 | 28 | ## View all branches, including those from upstream 29 | ``` 30 | git branch -va 31 | ``` 32 | Now, checkout your own master branch and merge the upstream repo's master branch: 33 | 34 | ## Checkout your master branch and merge upstream 35 | ``` 36 | git checkout master 37 | git merge upstream/master 38 | ``` 39 | If there are no unique commits on the local master branch, git will simply perform a fast-forward. However, if you have been making changes on master (in the vast majority of cases you probably shouldn't be - see the next section, you may have to deal with conflicts. When doing so, be careful to respect the changes made upstream. 40 | 41 | Now, your local master branch is up-to-date with everything modified upstream. 42 | 43 | **Create a Branch** (doing your work) 44 | Whenever you begin work on a new feature or bugfix, it's important that you create a new branch. Not only is it proper git workflow, but it also keeps your changes organized and separated from the master branch so that you can easily submit and manage multiple pull requests for every task you complete. 45 | 46 | To create a new branch and start working on it, peform the following flow. 47 | 48 | ## Checkout the master branch - you want your new branch to come from master 49 | ``` 50 | git checkout master 51 | ``` 52 | 53 | ## Create a new branch (give your branch its own simple informative name) 54 | For enhancements use `feature/your_username/issue#` or `feature/your_username/name_of_feature` 55 | 56 | For bugs use `bug/your_username/issue#` or `bug/your_username/name_of_bug` 57 | 58 | ``` 59 | git branch feature/jdoe/567 60 | ``` 61 | 62 | ## Switch to your new branch 63 | ``` 64 | git checkout feature/jdoe/567 65 | ``` 66 | Now, go to town hacking away and making whatever changes you want to. 67 | 68 | ## Submitting your changes (a Pull Request) 69 | Prior to submitting your pull request, you might want to do a few things to clean up your branch and make it as simple as possible for the original repo's maintainer to test, accept, and merge your work. 70 | 71 | In the time that you've been working on your changes, if any commits have been made to the upstream master branch, you will need to rebase your development branch so that merging it will be a simple fast-forward that won't require any conflict resolution work. 72 | 73 | ## Fetch upstream master and merge with your repo's master branch 74 | ``` 75 | git fetch upstream 76 | git checkout master 77 | git merge upstream/master 78 | ``` 79 | 80 | ## If there were any new commits, rebase your development branch 81 | ``` 82 | git checkout feature/jdoe/567 83 | git rebase master 84 | ``` 85 | Now, it may be desirable to squash some of your smaller commits down into a small number of larger more cohesive commits. You can do this with an interactive rebase: 86 | 87 | ## Rebase all commits on your development branch 88 | ``` 89 | git checkout 90 | git rebase -i master 91 | ``` 92 | This will open up a text editor where you can specify which commits to squash. 93 | 94 | ## Submitting 95 | Once you've committed and pushed all of your changes to GitHub, go to the page for your fork on GitHub, select your development branch, and click the pull request button. If you need to make any adjustments to your pull request, just push the updates to GitHub. Your pull request will automatically track the changes on your development branch and update. 96 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Overview 2 | Please do! Thanks for your help improving the project! :balloon: 3 | 4 | All contributors are welcome. Please see the [newcomers welcome guide](https://docs.google.com/document/d/17OPtDE_rdnPQxmk2Kauhm3GwXF1R5dZ3Cj8qZLKdo5E/edit) for how, where and why to contribute. This project is community-built and welcomes collaboration. Contributors are expected to adhere to our [Code of Conduct](.CODE_OF_CONDUCT.md). 5 | 6 | Not sure where to start? First, see the [newcomers welcome guide](https://docs.google.com/document/d/17OPtDE_rdnPQxmk2Kauhm3GwXF1R5dZ3Cj8qZLKdo5E/edit). Grab an open issue with the [help-wanted label](../../labels/help%20wanted) and jump in. Join the [Slack account](http://slack.layer5.io) and engage in conversation. Create a [new issue](/../../issues/new/choose) if needed. All [pull requests](/../../pulls) should reference an open [issue](/../../issues). Include keywords in your pull request descriptions, as well as commit messages, to [automatically close issues in GitHub](https://help.github.com/en/github/managing-your-work-on-github/closing-issues-using-keywords). 7 | 8 | **Sections** 9 | - General Contribution Flow 10 | - Developer Certificate of Origin 11 | 12 | Relevant coding style guidelines are the Go Code Review Comments and the Formatting and style section of Peter Bourgon's Go: Best Practices for Production Environments. 13 | 14 | # General Contribution Flow 15 | 16 | In order to contribute to Meshery, please follow the fork-and-pull request workflow described [here](./CONTRIBUTING-gitflow.md). 17 | 18 | ## Signing-off on Commits (Developer Certificate of Origin) 19 | 20 | To contribute to this project, you must agree to the Developer Certificate of 21 | Origin (DCO) for each commit you make. The DCO is a simple statement that you, 22 | as a contributor, have the legal right to make the contribution. 23 | 24 | See the [DCO](https://developercertificate.org) file for the full text of what you must agree to 25 | and how it works [here](https://github.com/probot/dco#how-it-works). 26 | To signify that you agree to the DCO for contributions, you simply add a line to each of your 27 | git commit messages: 28 | 29 | ``` 30 | Signed-off-by: Jane Smith 31 | ``` 32 | 33 | In most cases, you can add this signoff to your commit automatically with the 34 | `-s` or `--signoff` flag to `git commit`. You must use your real name and a reachable email 35 | address (sorry, no pseudonyms or anonymous contributions). An example of signing off on a commit: 36 | ``` 37 | $ commit -s -m “my commit message w/signoff” 38 | ``` 39 | 40 | To ensure all your commits are signed, you may choose to add this alias to your global ```.gitconfig```: 41 | 42 | *~/.gitconfig* 43 | ``` 44 | [alias] 45 | amend = commit -s --amend 46 | cm = commit -s -m 47 | commit = commit -s 48 | ``` 49 | Or you may configure your IDE, for example, Visual Studio Code to automatically sign-off commits for you: 50 | 51 | 52 | 53 | ## Documentation Contribution Flow 54 | Please contribute! Layer5 documentation uses Jekyll and GitHub Pages to host docs sites. Learn more about [Layer5's documentation framework](https://docs.google.com/document/d/17guuaxb0xsfutBCzyj2CT6OZiFnMu9w4PzoILXhRXSo/edit?usp=sharing). The process of contributing follows this flow: 55 | 56 | 1. Create a fork, if you have not already, by following the steps described [here](./CONTRIBUTING-gitflow.md) 57 | 1. In the local copy of your fork, navigate to the docs folder. 58 | `cd docs` 59 | 1. Create and checkout a new branch to make changes within 60 | `git checkout -b ` 61 | 1. Edit/add documentation. 62 | `vi .md` 63 | 1. Run site locally to preview changes. 64 | `make site` 65 | 1. Commit, [sign-off](#commit-signing), and push changes to your remote branch. 66 | `git push origin ` 67 | 1. Open a pull request (in your web browser) against the repo. 68 | 69 | 70 | #### Tests 71 | Users can now test their code on their local machine against the CI checks implemented using `make run-tests`. 72 | 73 | To test code changes on your local machine, run the following command: 74 | ``` 75 | make run-tests 76 | ``` 77 | 78 | #### Building Docker image 79 | To build a Docker image of the project, please ensure you have `Docker` installed to be able to build the image. Now, run the following command to build the Docker image: 80 | ```sh 81 | make docker 82 | ``` 83 | 84 | ### UI Lint Rules 85 | 86 | Layer5 uses ES-Lint to maintain code quality & consistency in our UI Code. 87 | 88 | # Reviews 89 | All contributors are invited to review pull requests. See this short video on [how to review a pull request](https://www.youtube.com/watch?v=isLfo7jfE6g&feature=youtu.be). 90 | 91 | # New to Git? 92 | Resources: https://lab.github.com and https://try.github.com/ 93 | 94 | ### License 95 | 96 | This repository and site are available as open source under the terms of the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0). 97 | 98 | ### About Layer5 99 | 100 | **Community First** 101 |

The Layer5 community represents the largest collection of service mesh projects and their maintainers in the world.

102 | 103 | **Open Source First** 104 |

Our projects establish industry standards and enable service developers, owners, and operators with repeatable patterns and best practices for managing all aspects of distributed services. Our shared commitment to the open source spirit push the Layer5 community and its projects forward.

105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2020 Layer5, Inc. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | make: linux darwin windows 2 | 3 | # 4 | # ALL SUPPORT 5 | # 6 | 7 | darwin: darwin-arm 8 | nexe index.js -t darwin-x64 -o kubeopenapi-jsonschema-darwin -r "./node_modules/**/*" 9 | 10 | linux: linux-arm 11 | nexe index.js -t linux-x64 -o kubeopenapi-jsonschema -r "./node_modules/**/*" 12 | 13 | windows: windows-arm 14 | nexe index.js -t windows-x64 -o kubeopenapi-jsonschema -r "./node_modules/**/*" 15 | 16 | alpine: alpine-arm 17 | nexe index.js -t alpine-x64 -o kubeopenapi-jsonschema -r "./node_modules/**/*" 18 | 19 | # 20 | # ARM SUPPORT 21 | # 22 | darwin-arm: 23 | nexe index.js -t arm64 --build -o kubeopenapi-jsonschema-darwin -r "./node_modules/**/*" 24 | 25 | linux-arm: 26 | nexe index.js -t arm64 --build -o kubeopenapi-jsonschema -r "./node_modules/**/*" 27 | 28 | windows-arm: 29 | nexe index.js -t windows-arm64 --build -o kubeopenapi-jsonschema -r "./node_modules/**/*" 30 | 31 | alpine-arm: 32 | nexe index.js -t alpine-arm64 --build -o kubeopenapi-jsonschema -r "./node_modules/**/*" 33 | 34 | .PHONY: darwin darwin-arm alpine alpine-arm linux linux-arm -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KubeOpenAPI - JSON Schema 2 | 3 | This is a very basic node based CLI for converting OpenAPI schema to JSON Schema Draft 4 4 | 5 | 6 | ``` 7 | Usage: kubeopenapi-jsonschema [options] 8 | 9 | Options: 10 | -t, --type [type] set type of input, can be either yaml or json (default: "yaml") 11 | -l, --location location of the schema 12 | -f, --filter [query] give a query if a OpenAPISchema is nested 13 | --kubernetes enable kubernetes specific filters (default: false) 14 | -o [output-format] output format (default: "json") 15 | --o-filter [output-filter] output filter query 16 | --silent skip output (default: false) 17 | --resolve [resolve-filter] root of the OpenAPI spec to resolve the $ref. It is important to note that this jsonpath MUST evaluate to one object (default: "") 18 | -h, --help display help for command 19 | ``` 20 | 21 | ## Example 22 | 23 | Download the binaries from the github releases. Only linux-x64, darwin-x64 and windows-x64 binaries are released 24 | 25 | ```bash 26 | kubeopenapi-jsonschema --location ./k8s.json -f '$.definitions' -t json --o-filter '$[0][?(@["x-kubernetes-group-version-kind"][0].kind=="Deployment")].properties.spec' --resolve "$" 27 | ``` 28 | 29 | The above will consume kubernetes open API schema and will produce schema for Kubernetes `Deployment` 30 | 31 | 32 | ```bash 33 | kubeopenapi-jsonschema --location ./istio.yaml -t yaml --filter '$[?(@.kind=="CustomResourceDefinition")]..schema.openAPIV3Schema.properties.spec' --o-filter '$' 34 | ``` 35 | 36 | The above will consume istio CRD manifest and will produce schema for all of the CustomResourceDefinition objects 37 | 38 |
 
39 | 40 | ## Join the Community! 41 | 42 | 43 | Our projects are community-built and welcome collaboration. 👍 Be sure to see the Layer5 Community Welcome Guide for a tour of resources available to you and jump into our Slack! 44 | 45 |

46 | MeshMates 47 |

Find your MeshMate

48 | 49 |

MeshMates are experienced Layer5 community members, who will help you learn your way around, discover live projects and expand your community network. 50 | Become a Meshtee today!

51 | 52 | Find out more on the Layer5 community.
53 |



54 |

55 | 56 |
 
57 | 58 | 59 | 60 | 61 | 62 | 63 | Shows an illustrated light mode meshery logo in light color mode and a dark mode meshery logo dark color mode. 64 | 65 | 66 | 67 | Layer5 Cloud Native Community 68 | 69 |

70 | ✔️ Join any or all of the weekly meetings on community calendar.
71 | ✔️ Watch community meeting recordings.
72 | ✔️ Access the Community Drive by completing a community Member Form.
73 |

74 |

75 | Not sure where to start? Grab an open issue with the help-wanted label. 76 |

77 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | We are very grateful to the security researchers and users that report 3 | back Layer5 project security vulnerabilities. We investigate every report thoroughly. 4 | 5 | ## Reporting a vulnerability 6 | To make a report, send an email to the private 7 | [security-vulns-reports@layer5.io](mailto:security-vulns-reports@layer5.io) 8 | mailing list with the vulnerability details. For normal product bugs 9 | unrelated to latent security vulnerabilities, please head to 10 | the appropriate repository and submit a [new issue](../../issues/new/choose). 11 | 12 | ### When to report a security vulnerability? 13 | 14 | Send us a report whenever you: 15 | 16 | - Think Layer5 projects have a potential security vulnerability. 17 | - Are unsure whether or how a vulnerability affects Layer5 projects. 18 | - Think a vulnerability is present in another project that Layer5 projects 19 | depend on (Docker for example). 20 | 21 | ### When not to report a security vulnerability? 22 | 23 | Don't send a vulnerability report if: 24 | 25 | - You need help tuning Layer5 project components for security. 26 | - You need help applying security related updates. 27 | - Your issue is not security related. 28 | 29 | ## Evaluation 30 | 31 | The Layer5 team acknowledges and analyzes each vulnerability report within 10 working days. 32 | 33 | Any vulnerability information you share with the Layer5 team stays 34 | within the Layer5 project. We don't disseminate the information to other 35 | projects. We only share the information as needed to fix the issue. 36 | 37 | We keep the reporter updated as the status of the security issue is addressed. 38 | 39 | ## Fixing the issue 40 | 41 | Once a security vulnerability has been fully characterized, a fix is developed by the Layer5 team. 42 | The development and testing for the fix happens in a private GitHub repository in order to prevent 43 | premature disclosure of the vulnerability. 44 | 45 | ## Early disclosure 46 | 47 | The Layer5 team maintains a mailing list for private early disclosure of security vulnerabilities. 48 | The list is used to provide actionable information to close Layer5 partners. The list is not intended 49 | for individuals to find out about security issues. 50 | 51 | ## Public disclosure 52 | 53 | On the day chosen for public disclosure, a sequence of activities takes place as quickly as possible: 54 | 55 | - Changes are merged from the private GitHub repository holding the fix into the appropriate set of public 56 | branches. 57 | - Layer5 team ensures all necessary binaries are promptly built and published. 58 | - Once the binaries are available, an announcement is sent out on the following channels: 59 | - The [Layer5 blog](https://layer5.io/blog/) 60 | - The [Layer5 Twitter feed](https://twitter.com/layer5) 61 | - The #announcements channel on Slack 62 | 63 | As much as possible this announcement will be actionable, and include any mitigating steps customers can take prior to 64 | upgrading to a fixed version. 65 | -------------------------------------------------------------------------------- /helper/createQuery.js: -------------------------------------------------------------------------------- 1 | /** 2 | * CreateQuery generates a jsonpath based query 3 | * @param {string} query jsonpath query 4 | * @param {boolean} isKubernetes is the query to be generated for K8s CRD 5 | * @returns {string} generated query 6 | */ 7 | function CreateQuery(query = "", isKubernetes = true) { 8 | if (isKubernetes || !query) 9 | return `$[?(@.kind=="CustomResourceDefinition")]..validation.openAPIV3Schema`; 10 | 11 | return query; 12 | } 13 | 14 | module.exports = CreateQuery; 15 | -------------------------------------------------------------------------------- /helper/output.js: -------------------------------------------------------------------------------- 1 | const { dump } = require("js-yaml"); 2 | const jp = require("jsonpath"); 3 | 4 | /** 5 | * Output takes in the data that needs to be printed and 6 | * an output format 7 | * @param {Promise} data 8 | * @param {"json" | "yaml"} format output format 9 | */ 10 | function Output(data, format = "json", filter = "$", silent = false) { 11 | if (silent) return; 12 | 13 | data.then(data => { 14 | data = jp.query(data, filter); 15 | if (format === "yaml") return console.log(dump(data)); 16 | if (format === "json") return console.log(JSON.stringify(data, null, 2)); 17 | }) 18 | } 19 | 20 | module.exports = Output; 21 | -------------------------------------------------------------------------------- /helper/toJSONSchema.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const toJSONSchema = require("@openapi-contrib/openapi-schema-to-json-schema"); 3 | const yaml = require("js-yaml"); 4 | const { readFileSync, writeFileSync } = require("fs"); 5 | const { tmpdir } = require("os"); 6 | const path = require("path"); 7 | const jp = require("jsonpath"); 8 | const { Resolver } = require("@stoplight/json-ref-resolver"); 9 | 10 | /** 11 | * convertAllSchemasToJSONSchema takes in the OpenAPIV3 Schemas in an array 12 | * and return an array of an equivalent JSON Schema Draft 4 schemas 13 | * @param {any[]} schemas array of schemas in JSON format 14 | * @returns {any[]} JSON Schema draft 4 formatted schemas 15 | */ 16 | function convertAllSchemasToJSONSchema(schemas) { 17 | if (Array.isArray(schemas)) 18 | return schemas.map((schema) => toJSONSchema(schema)); 19 | 20 | return []; 21 | } 22 | 23 | /** 24 | * readSchema will read schema file from the given location, it expects 25 | * the schema to be in JSON format 26 | * 27 | * readSchema will also resolve the references if a resolveQuery is passed 28 | * @param {string} location 29 | * @param {string} resolveQuery jsonpath based query - must resolve to EXACTLY one match or else is ignored 30 | * @returns {Promise} 31 | */ 32 | async function readSchema(location, resolveQuery) { 33 | const data = readFileSync(location, "utf-8"); 34 | const parsed = JSON.parse(data); 35 | 36 | if (resolveQuery) { 37 | const inner = jp.query(parsed, resolveQuery); 38 | 39 | if (inner.length !== 1) return parsed; 40 | 41 | const resolver = new Resolver(); 42 | const resolved = await resolver.resolve(inner[0], {}); 43 | 44 | if (resolved.errors.length) console.error(resolved.errors); 45 | 46 | return resolved.result; 47 | } 48 | 49 | return parsed; 50 | } 51 | 52 | /** 53 | * filterSchemas takes in an array of schemas and will return an array of filtered schemas 54 | * @param {Array} schemas - OpenAPI schema in JSON format 55 | * @param {string} query jsonpath based query to filter out the data 56 | * @returns {Array} 57 | */ 58 | function filterSchemas(schemas, query) { 59 | return jp.query(schemas, query); 60 | } 61 | 62 | /** 63 | * setupFiles takes the location of the files and convert them into json 64 | * and return the new location 65 | * @param {string} location 66 | * @param {"yaml" | "json"} type 67 | * @returns {string} location of the schema files 68 | */ 69 | function setupFiles(location, type) { 70 | if (type === "json") return location; 71 | 72 | if (type === "yaml") { 73 | try { 74 | // Create a file name 75 | const filename = `ucnv-${Math.random().toString(36).substr(2, 5)}.json`; 76 | 77 | // Create destination path 78 | const dest = path.join(tmpdir(), filename); 79 | 80 | // Read file into memory and convert into json 81 | const doc = yaml.loadAll(readFileSync(location, "utf-8")); 82 | 83 | // Write the converted file to the disk 84 | writeFileSync(dest, JSON.stringify(doc)); 85 | 86 | return dest; 87 | } catch (error) { 88 | return ""; 89 | } 90 | } 91 | } 92 | 93 | /** 94 | * ToJSONSchema will convert he OpenAPIV3 based schema to JSONSchema Draft 4 schemas 95 | * @param {string} location location of the schemas in open api v3 format 96 | * @param {"yaml" | "json"} type encoding in which the openapi schema is present 97 | * @param {string} query jsonpath query to filter the read schemas 98 | * @param {string} resolve jsonpath query to reach to the root of the openAPI spec 99 | */ 100 | async function ToJSONSchema(location, type = "yaml", query = "", resolve = "") { 101 | if (type !== "yaml" && type !== "json") 102 | throw Error('invalid type received: can be either "yaml" or "json"'); 103 | 104 | const source = setupFiles(location, type); 105 | 106 | const schemas = await readSchema(source, resolve); 107 | 108 | const filtered = filterSchemas(schemas, query); 109 | 110 | return convertAllSchemasToJSONSchema(filtered); 111 | } 112 | 113 | module.exports = ToJSONSchema; 114 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { program } = require("commander"); 3 | const CreateQuery = require("./helper/createQuery"); 4 | const Output = require("./helper/output"); 5 | const ToJSONSchema = require("./helper/toJSONSchema"); 6 | 7 | program 8 | .option( 9 | "-t, --type [type]", 10 | "set type of input, can be either yaml or json", 11 | "yaml" 12 | ) 13 | .requiredOption("-l, --location ", "location of the schema") 14 | .option("-f, --filter [query]", "give a query if a OpenAPISchema is nested") 15 | .option("--kubernetes", "enable kubernetes specific filters", false) 16 | .option("-o [output-format]", "output format", "json") 17 | .option("--o-filter [output-filter]", "output filter query") 18 | .option("--silent", "skip output", false) 19 | .option("--resolve [resolve-filter]", "root of the OpenAPI spec to resolve the $ref", "") 20 | 21 | program.parse(process.argv); 22 | 23 | const options = program.opts(); 24 | 25 | Output( 26 | ToJSONSchema( 27 | options.location, 28 | options.type, 29 | CreateQuery(options.filter, options.kubernetes), 30 | options.resolve, 31 | ), 32 | options.o, 33 | options.oFilter, 34 | options.silent 35 | ); 36 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openapi-jsonschema", 3 | "version": "0.0.1", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@openapi-contrib/openapi-schema-to-json-schema": { 8 | "version": "3.1.1", 9 | "resolved": "https://registry.npmjs.org/@openapi-contrib/openapi-schema-to-json-schema/-/openapi-schema-to-json-schema-3.1.1.tgz", 10 | "integrity": "sha512-FMvdhv9Jr9tULjJAQaQzhCmNYYj2vQFVnl7CGlLAImZvJal71oedXMGszpPaZTLftAk5TCHqjnirig+P6LZxug==", 11 | "requires": { 12 | "fast-deep-equal": "^3.1.3" 13 | } 14 | }, 15 | "@stoplight/json": { 16 | "version": "3.17.0", 17 | "resolved": "https://registry.npmjs.org/@stoplight/json/-/json-3.17.0.tgz", 18 | "integrity": "sha512-WW0z2bb0D4t8FTl+zNTCu46J8lEOsrUhBPgwEYQ3Ri2Y0MiRE4U1/9ZV8Ki+pIJznZgY9i42bbFwOBxyZn5/6w==", 19 | "requires": { 20 | "@stoplight/ordered-object-literal": "^1.0.2", 21 | "@stoplight/types": "^12.3.0", 22 | "jsonc-parser": "~2.2.1", 23 | "lodash": "^4.17.21", 24 | "safe-stable-stringify": "^1.1" 25 | } 26 | }, 27 | "@stoplight/json-ref-resolver": { 28 | "version": "3.1.3", 29 | "resolved": "https://registry.npmjs.org/@stoplight/json-ref-resolver/-/json-ref-resolver-3.1.3.tgz", 30 | "integrity": "sha512-SgoKXwVnlpIZUyAFX4W79eeuTWvXmNlMfICZixL16GZXnkjcW+uZnfmAU0ZIjcnaTgaI4mjfxn8LAP2KR6Cr0A==", 31 | "requires": { 32 | "@stoplight/json": "^3.17.0", 33 | "@stoplight/path": "^1.3.2", 34 | "@stoplight/types": "^12.3.0", 35 | "@types/urijs": "^1.19.16", 36 | "dependency-graph": "~0.11.0", 37 | "fast-memoize": "^2.5.2", 38 | "immer": "^9.0.6", 39 | "lodash.get": "^4.4.2", 40 | "lodash.set": "^4.3.2", 41 | "tslib": "^2.3.1", 42 | "urijs": "^1.19.6" 43 | } 44 | }, 45 | "@stoplight/ordered-object-literal": { 46 | "version": "1.0.2", 47 | "resolved": "https://registry.npmjs.org/@stoplight/ordered-object-literal/-/ordered-object-literal-1.0.2.tgz", 48 | "integrity": "sha512-0ZMS/9sNU3kVo/6RF3eAv7MK9DY8WLjiVJB/tVyfF2lhr2R4kqh534jZ0PlrFB9CRXrdndzn1DbX6ihKZXft2w==" 49 | }, 50 | "@stoplight/path": { 51 | "version": "1.3.2", 52 | "resolved": "https://registry.npmjs.org/@stoplight/path/-/path-1.3.2.tgz", 53 | "integrity": "sha512-lyIc6JUlUA8Ve5ELywPC8I2Sdnh1zc1zmbYgVarhXIp9YeAB0ReeqmGEOWNtlHkbP2DAA1AL65Wfn2ncjK/jtQ==" 54 | }, 55 | "@stoplight/types": { 56 | "version": "12.3.0", 57 | "resolved": "https://registry.npmjs.org/@stoplight/types/-/types-12.3.0.tgz", 58 | "integrity": "sha512-hgzUR1z5BlYvIzUeFK5pjs5JXSvEutA9Pww31+dVicBlunsG1iXopDx/cvfBY7rHOrgtZDuvyeK4seqkwAZ6Cg==", 59 | "requires": { 60 | "@types/json-schema": "^7.0.4", 61 | "utility-types": "^3.10.0" 62 | } 63 | }, 64 | "@types/json-schema": { 65 | "version": "7.0.9", 66 | "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", 67 | "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==" 68 | }, 69 | "@types/urijs": { 70 | "version": "1.19.17", 71 | "resolved": "https://registry.npmjs.org/@types/urijs/-/urijs-1.19.17.tgz", 72 | "integrity": "sha512-ShIlp+8iNGo/yVVfYFoNRqUiaE9wMCzsSl85qTg2/C5l56BTJokU7QeMgVBQ9xhcyhWQP0zGXPBZPPvEG/sRmQ==" 73 | }, 74 | "argparse": { 75 | "version": "2.0.1", 76 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 77 | "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" 78 | }, 79 | "commander": { 80 | "version": "7.2.0", 81 | "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", 82 | "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==" 83 | }, 84 | "deep-is": { 85 | "version": "0.1.3", 86 | "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", 87 | "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" 88 | }, 89 | "dependency-graph": { 90 | "version": "0.11.0", 91 | "resolved": "https://registry.npmjs.org/dependency-graph/-/dependency-graph-0.11.0.tgz", 92 | "integrity": "sha512-JeMq7fEshyepOWDfcfHK06N3MhyPhz++vtqWhMT5O9A3K42rdsEDpfdVqjaqaAhsw6a+ZqeDvQVtD0hFHQWrzg==" 93 | }, 94 | "escodegen": { 95 | "version": "1.14.3", 96 | "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", 97 | "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", 98 | "requires": { 99 | "esprima": "^4.0.1", 100 | "estraverse": "^4.2.0", 101 | "esutils": "^2.0.2", 102 | "optionator": "^0.8.1", 103 | "source-map": "~0.6.1" 104 | }, 105 | "dependencies": { 106 | "esprima": { 107 | "version": "4.0.1", 108 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 109 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" 110 | } 111 | } 112 | }, 113 | "esprima": { 114 | "version": "1.2.2", 115 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", 116 | "integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=" 117 | }, 118 | "estraverse": { 119 | "version": "4.3.0", 120 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", 121 | "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" 122 | }, 123 | "esutils": { 124 | "version": "2.0.3", 125 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", 126 | "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" 127 | }, 128 | "fast-deep-equal": { 129 | "version": "3.1.3", 130 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", 131 | "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" 132 | }, 133 | "fast-levenshtein": { 134 | "version": "2.0.6", 135 | "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", 136 | "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" 137 | }, 138 | "fast-memoize": { 139 | "version": "2.5.2", 140 | "resolved": "https://registry.npmjs.org/fast-memoize/-/fast-memoize-2.5.2.tgz", 141 | "integrity": "sha512-Ue0LwpDYErFbmNnZSF0UH6eImUwDmogUO1jyE+JbN2gsQz/jICm1Ve7t9QT0rNSsfJt+Hs4/S3GnsDVjL4HVrw==" 142 | }, 143 | "immer": { 144 | "version": "9.0.6", 145 | "resolved": "https://registry.npmjs.org/immer/-/immer-9.0.6.tgz", 146 | "integrity": "sha512-G95ivKpy+EvVAnAab4fVa4YGYn24J1SpEktnJX7JJ45Bd7xqME/SCplFzYFmTbrkwZbQ4xJK1xMTUYBkN6pWsQ==" 147 | }, 148 | "js-yaml": { 149 | "version": "4.1.0", 150 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", 151 | "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", 152 | "requires": { 153 | "argparse": "^2.0.1" 154 | } 155 | }, 156 | "jsonc-parser": { 157 | "version": "2.2.1", 158 | "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.2.1.tgz", 159 | "integrity": "sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w==" 160 | }, 161 | "jsonpath": { 162 | "version": "1.1.1", 163 | "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz", 164 | "integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==", 165 | "requires": { 166 | "esprima": "1.2.2", 167 | "static-eval": "2.0.2", 168 | "underscore": "1.12.1" 169 | } 170 | }, 171 | "levn": { 172 | "version": "0.3.0", 173 | "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", 174 | "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", 175 | "requires": { 176 | "prelude-ls": "~1.1.2", 177 | "type-check": "~0.3.2" 178 | } 179 | }, 180 | "lodash": { 181 | "version": "4.17.21", 182 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", 183 | "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" 184 | }, 185 | "lodash.get": { 186 | "version": "4.4.2", 187 | "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", 188 | "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" 189 | }, 190 | "lodash.set": { 191 | "version": "4.3.2", 192 | "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", 193 | "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=" 194 | }, 195 | "optionator": { 196 | "version": "0.8.3", 197 | "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", 198 | "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", 199 | "requires": { 200 | "deep-is": "~0.1.3", 201 | "fast-levenshtein": "~2.0.6", 202 | "levn": "~0.3.0", 203 | "prelude-ls": "~1.1.2", 204 | "type-check": "~0.3.2", 205 | "word-wrap": "~1.2.3" 206 | } 207 | }, 208 | "prelude-ls": { 209 | "version": "1.1.2", 210 | "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", 211 | "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" 212 | }, 213 | "safe-stable-stringify": { 214 | "version": "1.1.1", 215 | "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-1.1.1.tgz", 216 | "integrity": "sha512-ERq4hUjKDbJfE4+XtZLFPCDi8Vb1JqaxAPTxWFLBx8XcAlf9Bda/ZJdVezs/NAfsMQScyIlUMx+Yeu7P7rx5jw==" 217 | }, 218 | "source-map": { 219 | "version": "0.6.1", 220 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 221 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 222 | "optional": true 223 | }, 224 | "static-eval": { 225 | "version": "2.0.2", 226 | "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", 227 | "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", 228 | "requires": { 229 | "escodegen": "^1.8.1" 230 | } 231 | }, 232 | "tslib": { 233 | "version": "2.3.1", 234 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", 235 | "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" 236 | }, 237 | "type-check": { 238 | "version": "0.3.2", 239 | "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", 240 | "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", 241 | "requires": { 242 | "prelude-ls": "~1.1.2" 243 | } 244 | }, 245 | "underscore": { 246 | "version": "1.12.1", 247 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", 248 | "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==" 249 | }, 250 | "urijs": { 251 | "version": "1.19.7", 252 | "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.7.tgz", 253 | "integrity": "sha512-Id+IKjdU0Hx+7Zx717jwLPsPeUqz7rAtuVBRLLs+qn+J2nf9NGITWVCxcijgYxBqe83C7sqsQPs6H1pyz3x9gA==" 254 | }, 255 | "utility-types": { 256 | "version": "3.10.0", 257 | "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", 258 | "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==" 259 | }, 260 | "word-wrap": { 261 | "version": "1.2.3", 262 | "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", 263 | "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" 264 | } 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openapi-jsonschema", 3 | "version": "0.0.1", 4 | "description": "Convert OpenAPI v3 spec to JSONSchema draft 4", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Utkarsh Srivastava", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@openapi-contrib/openapi-schema-to-json-schema": "^3.1.1", 13 | "@stoplight/json-ref-resolver": "^3.1.3", 14 | "commander": "^7.2.0", 15 | "js-yaml": "^4.1.0", 16 | "jsonpath": "^1.1.1" 17 | } 18 | } 19 | --------------------------------------------------------------------------------