├── .editorconfig ├── .eslintrc.json ├── .github ├── dependabot.yml └── workflows │ ├── ci.yaml │ └── codeql-analysis.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── index.js ├── openapi-filter.js ├── package-lock.json ├── package.json └── test ├── alias ├── input.yaml ├── options.yaml └── output.yaml ├── asyncapi ├── input.yaml ├── options.yaml └── output.yaml ├── checkTags1 ├── input.yaml ├── options.yaml └── output.yaml ├── checkTags2 ├── input.yaml ├── options.yaml └── output.yaml ├── circular ├── input.yaml ├── options.yaml └── output.yaml ├── codep ├── input.yaml ├── options.yaml └── output.yaml ├── configFile ├── input.yaml ├── options.json └── output.yaml ├── flagValues ├── input.yaml ├── options.yaml └── output.yaml ├── inverse ├── input.yaml ├── options.yaml └── output.yaml ├── issue105a ├── input.yaml └── output.yaml ├── issue26a ├── input.yaml ├── options.yaml └── output.yaml ├── issue26b ├── input.yaml ├── options.yaml └── output.yaml ├── issue28 ├── input.yaml ├── options.yaml └── output.yaml ├── issue29_nestedReferences ├── input.yaml ├── options.yaml └── output.yaml ├── issue85 ├── input.yaml ├── options.yaml └── output.yaml ├── strip ├── input.yaml ├── options.yaml └── output.yaml ├── test.js ├── valid ├── input.yaml ├── options.yaml └── output.yaml └── xkcd ├── input.yaml └── output.yaml /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | indent_style = space 6 | indent_size = 4 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "es6": true, 4 | "node": true, 5 | "mocha": true 6 | }, 7 | "parserOptions": { 8 | "ecmaVersion": 2017 9 | }, 10 | "extends": "eslint:recommended", 11 | "rules": { 12 | "accessor-pairs": "error", 13 | "array-bracket-spacing": [ 14 | "off", 15 | "never" 16 | ], 17 | "array-callback-return": "error", 18 | "arrow-body-style": "off", 19 | "arrow-parens": [ 20 | "off", 21 | "as-needed" 22 | ], 23 | "arrow-spacing": [ 24 | "off", 25 | { 26 | "after": true, 27 | "before": true 28 | } 29 | ], 30 | "block-scoped-var": "off", 31 | "block-spacing": "off", 32 | "brace-style": [ 33 | "off", 34 | "stroustrup" 35 | ], 36 | "callback-return": "off", 37 | "camelcase": "off", 38 | "class-methods-use-this": "error", 39 | "comma-dangle": "error", 40 | "comma-spacing": "off", 41 | "comma-style": [ 42 | "error", 43 | "last" 44 | ], 45 | "complexity": "off", 46 | "computed-property-spacing": [ 47 | "error", 48 | "never" 49 | ], 50 | "consistent-return": "off", 51 | "consistent-this": "error", 52 | "curly": "off", 53 | "default-case": "error", 54 | "dot-location": [ 55 | "off", 56 | "property" 57 | ], 58 | "dot-notation": [ 59 | "error", 60 | { 61 | "allowKeywords": true 62 | } 63 | ], 64 | "eol-last": "error", 65 | "eqeqeq": "off", 66 | "func-call-spacing": "error", 67 | "func-name-matching": "off", 68 | "func-names": "off", 69 | "func-style": [ 70 | "error", 71 | "declaration" 72 | ], 73 | "generator-star-spacing": "off", 74 | "global-require": "off", 75 | "guard-for-in": "off", 76 | "handle-callback-err": "off", 77 | "id-blacklist": "error", 78 | "id-length": "off", 79 | "id-match": "error", 80 | "indent": "off", 81 | "init-declarations": "off", 82 | "jsx-quotes": "error", 83 | "key-spacing": "off", 84 | "keyword-spacing": ["error", { "after": true }], 85 | "line-comment-position": "off", 86 | "linebreak-style": [ 87 | "error", 88 | "unix" 89 | ], 90 | "lines-around-comment": "off", 91 | "lines-around-directive": "off", 92 | "max-depth": "off", 93 | "max-len": "off", 94 | "max-lines": "off", 95 | "max-nested-callbacks": "error", 96 | "max-params": "off", 97 | "max-statements": "off", 98 | "max-statements-per-line": "off", 99 | "multiline-ternary": [ 100 | "off", 101 | "never" 102 | ], 103 | "new-parens": "error", 104 | "newline-after-var": "off", 105 | "newline-before-return": "off", 106 | "newline-per-chained-call": "off", 107 | "no-alert": "error", 108 | "no-array-constructor": "error", 109 | "no-bitwise": "off", 110 | "no-caller": "error", 111 | "no-catch-shadow": "off", 112 | "no-confusing-arrow": "error", 113 | "no-console": "off", 114 | "no-continue": "off", 115 | "no-div-regex": "error", 116 | "no-duplicate-imports": "error", 117 | "no-else-return": "off", 118 | "no-empty": [ 119 | "warn", 120 | { 121 | "allowEmptyCatch": true 122 | } 123 | ], 124 | "no-empty-function": "off", 125 | "no-eq-null": "error", 126 | "no-eval": "error", 127 | "no-extend-native": "off", 128 | "no-extra-bind": "error", 129 | "no-extra-label": "error", 130 | "no-extra-parens": "off", 131 | "no-floating-decimal": "error", 132 | "no-global-assign": "error", 133 | "no-implicit-globals": "error", 134 | "no-implied-eval": "error", 135 | "no-inline-comments": "off", 136 | "no-inner-declarations": [ 137 | "error", 138 | "functions" 139 | ], 140 | "no-invalid-this": "off", 141 | "no-iterator": "error", 142 | "no-label-var": "error", 143 | "no-labels": "error", 144 | "no-lone-blocks": "error", 145 | "no-lonely-if": "off", 146 | "no-loop-func": "off", 147 | "no-magic-numbers": "off", 148 | "no-mixed-operators": "error", 149 | "no-mixed-requires": "error", 150 | "no-multi-spaces": "off", 151 | "no-multi-str": "error", 152 | "no-multiple-empty-lines": "error", 153 | "no-negated-condition": "error", 154 | "no-nested-ternary": "off", 155 | "no-new": "error", 156 | "no-new-func": "error", 157 | "no-new-object": "error", 158 | "no-new-require": "error", 159 | "no-new-wrappers": "error", 160 | "no-octal-escape": "error", 161 | "no-param-reassign": "off", 162 | "no-path-concat": "error", 163 | "no-plusplus": "off", 164 | "no-process-env": "off", 165 | "no-process-exit": "off", 166 | "no-proto": "error", 167 | "no-prototype-builtins": "off", 168 | "no-restricted-globals": "error", 169 | "no-restricted-imports": "error", 170 | "no-restricted-modules": "error", 171 | "no-restricted-properties": "error", 172 | "no-restricted-syntax": "error", 173 | "no-return-assign": "off", 174 | "no-script-url": "error", 175 | "no-self-compare": "error", 176 | "no-sequences": "error", 177 | "no-shadow": "off", 178 | "no-shadow-restricted-names": "error", 179 | "no-spaced-func": "error", 180 | "no-sync": "off", 181 | "no-tabs": "off", 182 | "no-template-curly-in-string": "error", 183 | "no-ternary": "off", 184 | "no-throw-literal": "error", 185 | "no-trailing-spaces": "error", 186 | "no-undef-init": "error", 187 | "no-undefined": "warn", 188 | "no-underscore-dangle": "off", 189 | "no-unmodified-loop-condition": "error", 190 | "no-unneeded-ternary": [ 191 | "error", 192 | { 193 | "defaultAssignment": true 194 | } 195 | ], 196 | "no-unsafe-negation": "error", 197 | "no-unused-expressions": "error", 198 | "no-unused-vars": "off", 199 | "no-use-before-define": "off", 200 | "no-useless-call": "error", 201 | "no-useless-computed-key": "error", 202 | "no-useless-concat": "off", 203 | "no-useless-constructor": "error", 204 | "no-useless-escape": "off", 205 | "no-useless-rename": "error", 206 | "no-var": "off", 207 | "no-void": "error", 208 | "no-warning-comments": "off", 209 | "no-whitespace-before-property": "error", 210 | "no-with": "error", 211 | "object-curly-newline": "off", 212 | "object-curly-spacing": "off", 213 | "object-property-newline": [ 214 | "off", 215 | { 216 | "allowMultiplePropertiesPerLine": true 217 | } 218 | ], 219 | "object-shorthand": "off", 220 | "one-var": "off", 221 | "one-var-declaration-per-line": "error", 222 | "operator-assignment": "off", 223 | "operator-linebreak": "off", 224 | "padded-blocks": "off", 225 | "prefer-arrow-callback": "off", 226 | "prefer-const": "off", 227 | "prefer-numeric-literals": "error", 228 | "prefer-reflect": "off", 229 | "prefer-rest-params": "error", 230 | "prefer-spread": "error", 231 | "prefer-template": "off", 232 | "quote-props": "off", 233 | "quotes": "off", 234 | "radix": "error", 235 | "require-jsdoc": "off", 236 | "require-yield": "off", 237 | "rest-spread-spacing": "error", 238 | "semi": "off", 239 | "semi-spacing": "off", 240 | "sort-imports": "error", 241 | "sort-keys": "off", 242 | "sort-vars": "off", 243 | "space-before-blocks": "off", 244 | "space-before-function-paren": "off", 245 | "space-in-parens": [ 246 | "error", 247 | "never" 248 | ], 249 | "space-infix-ops": "off", 250 | "space-unary-ops": "error", 251 | "spaced-comment": "off", 252 | "strict": "error", 253 | "symbol-description": "error", 254 | "template-curly-spacing": "error", 255 | "unicode-bom": [ 256 | "error", 257 | "never" 258 | ], 259 | "valid-jsdoc": "off", 260 | "vars-on-top": "off", 261 | "wrap-iife": "error", 262 | "wrap-regex": "off", 263 | "yield-star-spacing": "error", 264 | "yoda": [ 265 | "error", 266 | "never" 267 | ] 268 | } 269 | } 270 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | ignore: 9 | - dependency-name: yargs 10 | versions: 11 | - "> 12.0.5" 12 | - dependency-name: eslint 13 | versions: 14 | - 7.18.0 15 | - 7.20.0 16 | - 7.22.0 17 | - dependency-name: mocha 18 | versions: 19 | - 8.3.1 20 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | # Author: @MikeRalphson 4 | # Issue : n/a 5 | # Desc : This workflow runs a simple lint and test for a node.js project 6 | 7 | # run this on push to any branch and creation of pull-requests 8 | on: [push, pull_request, workflow_dispatch] 9 | 10 | jobs: 11 | ci: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v1 # checkout repo content 15 | - uses: actions/setup-node@v1 # setup Node.js 16 | with: 17 | node-version: '18.x' 18 | - name: Audit package-lock.json 19 | run: npx package-lock-audit ./package-lock.json 20 | - name: Install deps 21 | run: npm i 22 | - name: Run lint 23 | run: npm run lint 24 | - name: Run tests 25 | run: npm run test 26 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | name: "CodeQL" 7 | 8 | on: 9 | push: 10 | branches: [master] 11 | pull_request: 12 | # The branches below must be a subset of the branches above 13 | branches: [master] 14 | schedule: 15 | - cron: '0 6 * * 0' 16 | 17 | jobs: 18 | analyze: 19 | name: Analyze 20 | runs-on: ubuntu-latest 21 | 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | # Override automatic language detection by changing the below list 26 | # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] 27 | language: ['javascript'] 28 | # Learn more... 29 | # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection 30 | 31 | steps: 32 | - name: Checkout repository 33 | uses: actions/checkout@v2 34 | with: 35 | # We must fetch at least the immediate parents so that if this is 36 | # a pull request then we can checkout the head. 37 | fetch-depth: 2 38 | 39 | # If this run was triggered by a pull request event, then checkout 40 | # the head of the pull request instead of the merge commit. 41 | - run: git checkout HEAD^2 42 | if: ${{ github.event_name == 'pull_request' }} 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # ide 61 | .idea 62 | .vscode 63 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v3.0.0 4 | 5 | * `--inverse` with `--valid` will now include all nested `$ref`s 6 | 7 | ## v2.0.0 8 | 9 | * `--tags` option has been renamed `--flags` to avoid confusion with the OpenAPI `tags` object 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, Mermade Software 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # openapi-filter 2 | 3 | ![ci](https://github.com/Mermade/openapi-filter/workflows/ci/badge.svg) 4 | 5 | Filter internal paths, operations, parameters, schemas etc from OpenAPI/Swagger/AsyncAPI definitions. 6 | 7 | Simply flag any object within the definition with an `x-internal` specification extension, and it will be removed from the output. 8 | 9 | For example: 10 | 11 | ```yaml 12 | openapi: 3.0.0 13 | info: 14 | title: API 15 | version: 1.0.0 16 | paths: 17 | /: 18 | get: 19 | x-internal: true 20 | ... 21 | ``` 22 | 23 | Works with OpenAPI/Swagger 2.0 and 3.0.x and AsyncAPI definitions. 24 | 25 | ``` 26 | openapi-filter.js [outfile] 27 | 28 | Positionals: 29 | infile the input file 30 | outfile the output file 31 | 32 | Options: 33 | 34 | --info include complete info object with --valid [boolean] 35 | --inverse, -i output filtered elements only [boolean] 36 | --flags, -f flags to filter by [array] [default: ["x-internal"]] 37 | --flagValues, -v flag String values to match [array] [default: []] 38 | --checkTags filter if flags given in --flags are in the tags array 39 | [boolean] 40 | --overrides, -o prefixes used to override named properties[arr] [default: []] 41 | --valid try to ensure inverse output is valid [boolean] 42 | --strip, -s strip the flags from the finished product [boolean] 43 | --servers include complete servers object with --valid [boolean] 44 | --lineWidth, -l max line width of yaml output [number] [default: 0] 45 | --maxAliasCount maximum YAML aliases allowed [number] [default: 100] 46 | --configFile The file & path for the filter options [path] 47 | --help Show help [boolean] 48 | --verbose Output more details of the filter process [count] 49 | ``` 50 | 51 | use `--` to separate flags or other array options from following options, i.e.: 52 | 53 | `openapi-filter --flags x-private x-hidden -- source.yaml target.yaml` 54 | 55 | or 56 | 57 | ```javascript 58 | let openapiFilter = require('openapi-filter'); 59 | let options = {}; // defaults are shown 60 | //options.inverse = false; 61 | //options.valid = false; 62 | //options.flags = ['x-internal']; 63 | let res = openapiFilter.filter(obj,options); 64 | ``` 65 | 66 | See the [wiki](https://github.com/Mermade/openapi-filter/wiki) for further examples. 67 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const recurse = require('reftools/lib/recurse.js').recurse; 4 | const clone = require('reftools/lib/clone.js').clone; 5 | const jptr = require('reftools/lib/jptr.js').jptr; 6 | 7 | function filter(obj,options) { 8 | 9 | const defaults = {}; 10 | defaults.flags = ['x-internal']; 11 | defaults.flagValues = []; 12 | defaults.checkTags = false; 13 | defaults.inverse = false; 14 | defaults.strip = false; 15 | defaults.overrides = []; 16 | options = Object.assign({},defaults,options); 17 | 18 | let src = clone(obj); 19 | let filtered = {}; 20 | let filteredpaths = []; 21 | recurse(src,{},function(obj,key,state){ 22 | for (let override of options.overrides) { 23 | if (key.startsWith(override)) { 24 | obj[key.substring(override.length)] = obj[key]; 25 | if (options.strip) { 26 | delete obj[key]; 27 | } 28 | } 29 | } 30 | 31 | for (let flag of options.flags) { 32 | if ((options.checkTags == false && (obj[key] && ((options.flagValues.length == 0 && obj[key][flag]) || options.flagValues.includes(obj[key][flag])))) || (options.checkTags && (obj[key] && obj[key].tags && Array.isArray(obj[key].tags) && obj[key].tags.includes(flag)))) { 33 | if (options.inverse) { 34 | if (options.strip) { 35 | delete obj[key][flag]; 36 | } 37 | if (Array.isArray(obj)) { 38 | // we need to seed the presence of an empty array 39 | // otherwise jptr won't know whether it's setting 40 | // an array entry or a property with a numeric key #26 41 | const components = state.path.split('/'); 42 | components.pop(); // throw away last item 43 | if (jptr(filtered,components.join('/')) === false) { 44 | jptr(filtered,components.join('/'),[]); 45 | } 46 | } 47 | jptr(filtered,state.path,clone(obj[key])); 48 | } 49 | filteredpaths.push(state.path); 50 | delete obj[key]; 51 | break; 52 | } 53 | } 54 | }); 55 | 56 | // remove undefined properties (important for YAML output) 57 | recurse((options.inverse ? filtered : src),{},function(obj,key,state){ 58 | if (Array.isArray(obj[key])) { 59 | obj[key] = obj[key].filter(function(e){ 60 | return typeof e !== 'undefined'; 61 | }); 62 | } 63 | }); 64 | 65 | recurse(src,{},function(obj,key,state){ 66 | if (Array.isArray(obj) && obj.length > 0) { 67 | for (let idx = 0; idx < obj.length; idx++) { 68 | if (obj[idx] && obj[idx].hasOwnProperty('$ref') && filteredpaths.includes(obj[idx].$ref)) { 69 | obj.splice(idx, 1); 70 | idx--; 71 | } 72 | } 73 | } 74 | }); 75 | 76 | // tidy up any paths where we have removed all the operations 77 | for (let p in src.paths) { 78 | if (Object.keys(src.paths[p]).length === 0) { 79 | delete src.paths[p]; 80 | } 81 | } 82 | 83 | if (options.inverse && options.valid) { 84 | // ensure any components being reffed are still included in output 85 | let checkForReferences = true; 86 | 87 | while (checkForReferences) { 88 | checkForReferences = false; 89 | let changesMade = false; 90 | 91 | recurse(filtered, {}, function (o, key, state) { 92 | if ((key === '$ref') && (typeof o[key] === 'string') && (o[key].startsWith('#'))) { 93 | if (!jptr(filtered, o.$ref)) { 94 | jptr(filtered, o.$ref, jptr(obj, o.$ref)); 95 | 96 | changesMade = true; 97 | } 98 | } 99 | 100 | checkForReferences = changesMade; 101 | }); 102 | } 103 | 104 | let info = {}; 105 | if (src.info && (!filtered.info || !filtered.info.version || !filtered.info.title)) { 106 | info = Object.assign({}, filtered.info, options.info ? src.info : { title: src.info.title, version: src.info.version }); 107 | } 108 | if (src.asyncapi && !filtered.asyncpi) { 109 | filtered = Object.assign({ asyncapi: src.asyncapi, info: info }, filtered); 110 | } 111 | if (src.swagger && !filtered.swagger) { 112 | filtered = Object.assign({ swagger: src.swagger, info: info }, filtered); 113 | } 114 | if (src.openapi && !filtered.openapi) { 115 | filtered = Object.assign({ openapi: src.openapi, info: info }, filtered); 116 | } 117 | if (!filtered.security && Array.isArray(src.security)) { 118 | const filteredsecurityschemes = []; 119 | // OAS2 120 | if (filtered.securityDefinitions) { 121 | filteredsecurityschemes.push(...Object.keys(filtered.securityDefinitions)); 122 | } 123 | // OAS3 124 | if (filtered.components && filtered.components.securitySchemes) { 125 | filteredsecurityschemes.push(...Object.keys(filtered.components.securitySchemes)); 126 | } 127 | filtered.security = src.security.filter(req => { 128 | const filteredreq = {}; 129 | Object.getOwnPropertyNames(req).forEach(function(n){ 130 | if (filteredsecurityschemes.includes(n)) { 131 | filteredreq[n] = clone(req[n]); 132 | } 133 | }); 134 | return Object.getOwnPropertyNames(filteredreq).length !== 0; 135 | }); 136 | } 137 | if (!filtered.paths && !filtered.asyncapi) filtered.paths = {}; 138 | 139 | if (options.servers && !filtered.servers && Array.isArray(src.servers)) { 140 | filtered.servers = src.servers; 141 | } 142 | } 143 | return (options.inverse ? filtered : src); 144 | } 145 | 146 | module.exports = { 147 | filter : filter 148 | }; 149 | -------------------------------------------------------------------------------- /openapi-filter.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict'; 4 | 5 | const fs = require('fs'); 6 | const yaml = require('yaml'); 7 | const openapiFilter = require('./index.js'); 8 | 9 | let argv = require('yargs') 10 | .usage('$0 [outfile]') 11 | .demand(1) 12 | .strict() 13 | .boolean('info') 14 | .describe('info','include complete info object with --valid') 15 | .boolean('inverse') 16 | .describe('inverse','output filtered elements only') 17 | .alias('inverse','i') 18 | .boolean('servers') 19 | .describe('servers','include complete servers object with --valid') 20 | .array('flags') 21 | .alias('flags','f') 22 | .describe('flags','flags to filter by') 23 | .default('flags',['x-internal']) 24 | .array('flagValues') 25 | .alias('flagValues', 'v') 26 | .describe('flagValues', 'flag string values to consider as a filter match (in addition to matching on boolean types)') 27 | .default('flagValues', []) 28 | .boolean('checkTags') 29 | .describe('checkTags', 'filter if flags given in --flags are in the tags array') 30 | .array('overrides') 31 | .alias('overrides','o') 32 | .default('overrides', []) 33 | .describe('overrides', 'prefixes used to override named properties') 34 | .boolean('valid') 35 | .describe('valid', 'try to ensure inverse output is valid') 36 | .boolean('strip') 37 | .alias('strip','s') 38 | .describe('strip','strip the flags from the finished product') 39 | .number('lineWidth') 40 | .alias('lineWidth','l') 41 | .describe('lineWidth','max line width of yaml output') 42 | .default('lineWidth',0) 43 | .number('maxAliasCount') 44 | .default('maxAliasCount',100) 45 | .describe('maxAliasCount','maximum YAML aliases allowed') 46 | .alias('configFile', 'c') 47 | .describe('configFile', 'The file & path for the filter options') 48 | .count('verbose') 49 | .describe('verbose', 'Output more details of the filter process.') 50 | .help() 51 | .version() 52 | .argv; 53 | 54 | // Helper function to display info message, depending on the verbose level 55 | function info(msg) { 56 | if (argv.verbose >= 1) { 57 | console.warn(msg); 58 | } 59 | } 60 | 61 | info('=== Document filtering started ===\n') 62 | 63 | // apply options from config file if present 64 | if (argv && argv.configFile) { 65 | info('Config File: ' + argv.configFile) 66 | try { 67 | let configFileOptions = {} 68 | if (argv.configFile.indexOf('.json')>=0) { 69 | configFileOptions = JSON.parse(fs.readFileSync(argv.configFile, 'utf8')); 70 | } else { 71 | configFileOptions = yaml.parse(fs.readFileSync(argv.configFile, 'utf8'), {schema:'core'}); 72 | } 73 | argv = Object.assign({}, argv, configFileOptions); 74 | } catch (err) { 75 | console.error(err) 76 | } 77 | } 78 | 79 | const infile = argv._[0]; 80 | const outfile = argv._[1]; 81 | info('Input file: ' + infile) 82 | 83 | let s = fs.readFileSync(infile,'utf8'); 84 | let obj = yaml.parse(s, {maxAliasCount: argv.maxAliasCount}); 85 | let res = openapiFilter.filter(obj,argv); 86 | if (infile.indexOf('.json')>=0) { 87 | s = JSON.stringify(res,null,2); 88 | } 89 | else { 90 | s = yaml.stringify(res, {lineWidth: argv.lineWidth}); 91 | } 92 | if (outfile) { 93 | fs.writeFileSync(outfile,s,'utf8'); 94 | 95 | info('Output file: ' + outfile) 96 | } 97 | else { 98 | console.log(s); 99 | } 100 | 101 | info('\n✅ Document was filtered successfully') 102 | 103 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openapi-filter", 3 | "version": "3.2.2", 4 | "description": "Filter internal paths, operations, parameters, schemas etc from OpenAPI/Swagger definitions", 5 | "main": "index.js", 6 | "bin": "openapi-filter.js", 7 | "scripts": { 8 | "lint": "npx eslint *.js test/*.js", 9 | "test": "npx mocha" 10 | }, 11 | "author": "Mike Ralphson", 12 | "license": "BSD-3-Clause", 13 | "dependencies": { 14 | "reftools": "^1.1.1", 15 | "yaml": "2.2", 16 | "yargs": "^17.7.1" 17 | }, 18 | "devDependencies": { 19 | "eslint": "^8.37.0", 20 | "mocha": "^10.2.0" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/mermade/openapi-filter.git" 25 | }, 26 | "keywords": [ 27 | "openapi", 28 | "openapi3", 29 | "swagger", 30 | "asyncapi", 31 | "filter", 32 | "internal" 33 | ], 34 | "bugs": { 35 | "url": "https://github.com/mermade/openapi-filter/issues" 36 | }, 37 | "homepage": "https://github.com/mermade/openapi-filter#readme" 38 | } 39 | -------------------------------------------------------------------------------- /test/alias/input.yaml: -------------------------------------------------------------------------------- 1 | ### Test to check for many aliases 2 | x-definitions: 3 | CorsResponseParameters: &CorsResponseParameters 4 | method.response.header.Access-Control-Allow-Methods: '''DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT''' 5 | 6 | CorsMock: &CorsMock 7 | responses: 8 | default: 9 | statusCode: '200' 10 | responseParameters: *CorsResponseParameters 11 | 12 | ErrorResponses: &ErrorResponses 13 | '400': 14 | $ref: '#/components/responses/badRequest' 15 | 16 | CorsResponse: &CorsResponse 17 | x-amazon-apigateway-integration: *CorsMock 18 | 19 | DefaultParameters: &DefaultParameters 20 | 21 | ### AWS API Gateway anchors 22 | DefaultRequestParameters: &DefaultRequestParameters 23 | integration.request.header.Accept: method.request.header.Accept 24 | 25 | ResponseMappings: &ResponseMappings 26 | '200': 27 | statusCode: 200 28 | responseParameters: *CorsResponseParameters 29 | 30 | 31 | ########################### 32 | # The API Spec comes here # 33 | ########################### 34 | 35 | openapi: 3.0.1 36 | info: 37 | version: v0 38 | title: Alias test 39 | 40 | paths: 41 | /resource1: 42 | options: *CorsResponse 43 | x-amazon-apigateway-any-method: &GetData 44 | parameters: *DefaultParameters 45 | responses: 46 | << : *ErrorResponses 47 | x-amazon-apigateway-integration: 48 | responses: *ResponseMappings 49 | requestParameters: *DefaultRequestParameters 50 | get: 51 | << : *GetData 52 | post: 53 | << : *GetData 54 | 55 | /resource2: 56 | options: *CorsResponse 57 | x-amazon-apigateway-any-method: &GetData 58 | parameters: *DefaultParameters 59 | responses: 60 | << : *ErrorResponses 61 | x-amazon-apigateway-integration: 62 | responses: *ResponseMappings 63 | requestParameters: *DefaultRequestParameters 64 | get: 65 | << : *GetData 66 | post: 67 | << : *GetData 68 | 69 | /resource3: 70 | options: *CorsResponse 71 | x-amazon-apigateway-any-method: &GetData 72 | parameters: *DefaultParameters 73 | responses: 74 | << : *ErrorResponses 75 | x-amazon-apigateway-integration: 76 | responses: *ResponseMappings 77 | requestParameters: *DefaultRequestParameters 78 | get: 79 | << : *GetData 80 | post: 81 | << : *GetData 82 | 83 | /resource4: 84 | options: *CorsResponse 85 | x-amazon-apigateway-any-method: &GetData 86 | parameters: *DefaultParameters 87 | responses: 88 | << : *ErrorResponses 89 | x-amazon-apigateway-integration: 90 | responses: *ResponseMappings 91 | requestParameters: *DefaultRequestParameters 92 | get: 93 | << : *GetData 94 | post: 95 | << : *GetData 96 | 97 | /resource5: 98 | options: *CorsResponse 99 | x-amazon-apigateway-any-method: &GetData 100 | parameters: *DefaultParameters 101 | responses: 102 | << : *ErrorResponses 103 | x-amazon-apigateway-integration: 104 | responses: *ResponseMappings 105 | requestParameters: *DefaultRequestParameters 106 | get: 107 | << : *GetData 108 | post: 109 | << : *GetData 110 | 111 | /resource6: 112 | options: *CorsResponse 113 | x-amazon-apigateway-any-method: &GetData 114 | parameters: *DefaultParameters 115 | responses: 116 | << : *ErrorResponses 117 | x-amazon-apigateway-integration: 118 | responses: *ResponseMappings 119 | requestParameters: *DefaultRequestParameters 120 | get: 121 | << : *GetData 122 | post: 123 | << : *GetData 124 | 125 | /resource7: 126 | options: *CorsResponse 127 | x-amazon-apigateway-any-method: &GetData 128 | parameters: *DefaultParameters 129 | responses: 130 | << : *ErrorResponses 131 | x-amazon-apigateway-integration: 132 | responses: *ResponseMappings 133 | requestParameters: *DefaultRequestParameters 134 | get: 135 | << : *GetData 136 | post: 137 | << : *GetData 138 | 139 | /resource8: 140 | options: *CorsResponse 141 | x-amazon-apigateway-any-method: &GetData 142 | parameters: *DefaultParameters 143 | responses: 144 | << : *ErrorResponses 145 | x-amazon-apigateway-integration: 146 | responses: *ResponseMappings 147 | requestParameters: *DefaultRequestParameters 148 | get: 149 | << : *GetData 150 | post: 151 | << : *GetData 152 | 153 | /resource9: 154 | options: *CorsResponse 155 | x-amazon-apigateway-any-method: &GetData 156 | parameters: *DefaultParameters 157 | responses: 158 | << : *ErrorResponses 159 | x-amazon-apigateway-integration: 160 | responses: *ResponseMappings 161 | requestParameters: *DefaultRequestParameters 162 | get: 163 | << : *GetData 164 | post: 165 | << : *GetData 166 | 167 | /resource10: 168 | options: *CorsResponse 169 | x-amazon-apigateway-any-method: &GetData 170 | parameters: *DefaultParameters 171 | responses: 172 | << : *ErrorResponses 173 | x-amazon-apigateway-integration: 174 | responses: *ResponseMappings 175 | requestParameters: *DefaultRequestParameters 176 | get: 177 | << : *GetData 178 | post: 179 | << : *GetData 180 | 181 | /resource11: 182 | options: *CorsResponse 183 | x-amazon-apigateway-any-method: &GetData 184 | parameters: *DefaultParameters 185 | responses: 186 | << : *ErrorResponses 187 | x-amazon-apigateway-integration: 188 | responses: *ResponseMappings 189 | requestParameters: *DefaultRequestParameters 190 | get: 191 | << : *GetData 192 | post: 193 | << : *GetData 194 | 195 | # Components 196 | 197 | components: 198 | responses: 199 | 200withcors: 200 | description: Successful response 201 | badRequest: 202 | description: Bad request 203 | -------------------------------------------------------------------------------- /test/alias/options.yaml: -------------------------------------------------------------------------------- 1 | maxAliasCount: 200 2 | -------------------------------------------------------------------------------- /test/alias/output.yaml: -------------------------------------------------------------------------------- 1 | x-definitions: 2 | CorsResponseParameters: 3 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 4 | CorsMock: 5 | responses: 6 | default: 7 | statusCode: "200" 8 | responseParameters: 9 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 10 | ErrorResponses: 11 | "400": 12 | $ref: "#/components/responses/badRequest" 13 | CorsResponse: 14 | x-amazon-apigateway-integration: 15 | responses: 16 | default: 17 | statusCode: "200" 18 | responseParameters: 19 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 20 | DefaultParameters: null 21 | DefaultRequestParameters: 22 | integration.request.header.Accept: method.request.header.Accept 23 | ResponseMappings: 24 | "200": 25 | statusCode: 200 26 | responseParameters: 27 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 28 | openapi: 3.0.1 29 | info: 30 | version: v0 31 | title: Alias test 32 | paths: 33 | /resource1: 34 | options: 35 | x-amazon-apigateway-integration: 36 | responses: 37 | default: 38 | statusCode: "200" 39 | responseParameters: 40 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 41 | x-amazon-apigateway-any-method: 42 | parameters: null 43 | responses: 44 | <<: 45 | "400": 46 | $ref: "#/components/responses/badRequest" 47 | x-amazon-apigateway-integration: 48 | responses: 49 | "200": 50 | statusCode: 200 51 | responseParameters: 52 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 53 | requestParameters: 54 | integration.request.header.Accept: method.request.header.Accept 55 | get: 56 | <<: 57 | parameters: null 58 | responses: 59 | <<: 60 | "400": 61 | $ref: "#/components/responses/badRequest" 62 | x-amazon-apigateway-integration: 63 | responses: 64 | "200": 65 | statusCode: 200 66 | responseParameters: 67 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 68 | requestParameters: 69 | integration.request.header.Accept: method.request.header.Accept 70 | post: 71 | <<: 72 | parameters: null 73 | responses: 74 | <<: 75 | "400": 76 | $ref: "#/components/responses/badRequest" 77 | x-amazon-apigateway-integration: 78 | responses: 79 | "200": 80 | statusCode: 200 81 | responseParameters: 82 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 83 | requestParameters: 84 | integration.request.header.Accept: method.request.header.Accept 85 | /resource2: 86 | options: 87 | x-amazon-apigateway-integration: 88 | responses: 89 | default: 90 | statusCode: "200" 91 | responseParameters: 92 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 93 | x-amazon-apigateway-any-method: 94 | parameters: null 95 | responses: 96 | <<: 97 | "400": 98 | $ref: "#/components/responses/badRequest" 99 | x-amazon-apigateway-integration: 100 | responses: 101 | "200": 102 | statusCode: 200 103 | responseParameters: 104 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 105 | requestParameters: 106 | integration.request.header.Accept: method.request.header.Accept 107 | get: 108 | <<: 109 | parameters: null 110 | responses: 111 | <<: 112 | "400": 113 | $ref: "#/components/responses/badRequest" 114 | x-amazon-apigateway-integration: 115 | responses: 116 | "200": 117 | statusCode: 200 118 | responseParameters: 119 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 120 | requestParameters: 121 | integration.request.header.Accept: method.request.header.Accept 122 | post: 123 | <<: 124 | parameters: null 125 | responses: 126 | <<: 127 | "400": 128 | $ref: "#/components/responses/badRequest" 129 | x-amazon-apigateway-integration: 130 | responses: 131 | "200": 132 | statusCode: 200 133 | responseParameters: 134 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 135 | requestParameters: 136 | integration.request.header.Accept: method.request.header.Accept 137 | /resource3: 138 | options: 139 | x-amazon-apigateway-integration: 140 | responses: 141 | default: 142 | statusCode: "200" 143 | responseParameters: 144 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 145 | x-amazon-apigateway-any-method: 146 | parameters: null 147 | responses: 148 | <<: 149 | "400": 150 | $ref: "#/components/responses/badRequest" 151 | x-amazon-apigateway-integration: 152 | responses: 153 | "200": 154 | statusCode: 200 155 | responseParameters: 156 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 157 | requestParameters: 158 | integration.request.header.Accept: method.request.header.Accept 159 | get: 160 | <<: 161 | parameters: null 162 | responses: 163 | <<: 164 | "400": 165 | $ref: "#/components/responses/badRequest" 166 | x-amazon-apigateway-integration: 167 | responses: 168 | "200": 169 | statusCode: 200 170 | responseParameters: 171 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 172 | requestParameters: 173 | integration.request.header.Accept: method.request.header.Accept 174 | post: 175 | <<: 176 | parameters: null 177 | responses: 178 | <<: 179 | "400": 180 | $ref: "#/components/responses/badRequest" 181 | x-amazon-apigateway-integration: 182 | responses: 183 | "200": 184 | statusCode: 200 185 | responseParameters: 186 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 187 | requestParameters: 188 | integration.request.header.Accept: method.request.header.Accept 189 | /resource4: 190 | options: 191 | x-amazon-apigateway-integration: 192 | responses: 193 | default: 194 | statusCode: "200" 195 | responseParameters: 196 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 197 | x-amazon-apigateway-any-method: 198 | parameters: null 199 | responses: 200 | <<: 201 | "400": 202 | $ref: "#/components/responses/badRequest" 203 | x-amazon-apigateway-integration: 204 | responses: 205 | "200": 206 | statusCode: 200 207 | responseParameters: 208 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 209 | requestParameters: 210 | integration.request.header.Accept: method.request.header.Accept 211 | get: 212 | <<: 213 | parameters: null 214 | responses: 215 | <<: 216 | "400": 217 | $ref: "#/components/responses/badRequest" 218 | x-amazon-apigateway-integration: 219 | responses: 220 | "200": 221 | statusCode: 200 222 | responseParameters: 223 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 224 | requestParameters: 225 | integration.request.header.Accept: method.request.header.Accept 226 | post: 227 | <<: 228 | parameters: null 229 | responses: 230 | <<: 231 | "400": 232 | $ref: "#/components/responses/badRequest" 233 | x-amazon-apigateway-integration: 234 | responses: 235 | "200": 236 | statusCode: 200 237 | responseParameters: 238 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 239 | requestParameters: 240 | integration.request.header.Accept: method.request.header.Accept 241 | /resource5: 242 | options: 243 | x-amazon-apigateway-integration: 244 | responses: 245 | default: 246 | statusCode: "200" 247 | responseParameters: 248 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 249 | x-amazon-apigateway-any-method: 250 | parameters: null 251 | responses: 252 | <<: 253 | "400": 254 | $ref: "#/components/responses/badRequest" 255 | x-amazon-apigateway-integration: 256 | responses: 257 | "200": 258 | statusCode: 200 259 | responseParameters: 260 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 261 | requestParameters: 262 | integration.request.header.Accept: method.request.header.Accept 263 | get: 264 | <<: 265 | parameters: null 266 | responses: 267 | <<: 268 | "400": 269 | $ref: "#/components/responses/badRequest" 270 | x-amazon-apigateway-integration: 271 | responses: 272 | "200": 273 | statusCode: 200 274 | responseParameters: 275 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 276 | requestParameters: 277 | integration.request.header.Accept: method.request.header.Accept 278 | post: 279 | <<: 280 | parameters: null 281 | responses: 282 | <<: 283 | "400": 284 | $ref: "#/components/responses/badRequest" 285 | x-amazon-apigateway-integration: 286 | responses: 287 | "200": 288 | statusCode: 200 289 | responseParameters: 290 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 291 | requestParameters: 292 | integration.request.header.Accept: method.request.header.Accept 293 | /resource6: 294 | options: 295 | x-amazon-apigateway-integration: 296 | responses: 297 | default: 298 | statusCode: "200" 299 | responseParameters: 300 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 301 | x-amazon-apigateway-any-method: 302 | parameters: null 303 | responses: 304 | <<: 305 | "400": 306 | $ref: "#/components/responses/badRequest" 307 | x-amazon-apigateway-integration: 308 | responses: 309 | "200": 310 | statusCode: 200 311 | responseParameters: 312 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 313 | requestParameters: 314 | integration.request.header.Accept: method.request.header.Accept 315 | get: 316 | <<: 317 | parameters: null 318 | responses: 319 | <<: 320 | "400": 321 | $ref: "#/components/responses/badRequest" 322 | x-amazon-apigateway-integration: 323 | responses: 324 | "200": 325 | statusCode: 200 326 | responseParameters: 327 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 328 | requestParameters: 329 | integration.request.header.Accept: method.request.header.Accept 330 | post: 331 | <<: 332 | parameters: null 333 | responses: 334 | <<: 335 | "400": 336 | $ref: "#/components/responses/badRequest" 337 | x-amazon-apigateway-integration: 338 | responses: 339 | "200": 340 | statusCode: 200 341 | responseParameters: 342 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 343 | requestParameters: 344 | integration.request.header.Accept: method.request.header.Accept 345 | /resource7: 346 | options: 347 | x-amazon-apigateway-integration: 348 | responses: 349 | default: 350 | statusCode: "200" 351 | responseParameters: 352 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 353 | x-amazon-apigateway-any-method: 354 | parameters: null 355 | responses: 356 | <<: 357 | "400": 358 | $ref: "#/components/responses/badRequest" 359 | x-amazon-apigateway-integration: 360 | responses: 361 | "200": 362 | statusCode: 200 363 | responseParameters: 364 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 365 | requestParameters: 366 | integration.request.header.Accept: method.request.header.Accept 367 | get: 368 | <<: 369 | parameters: null 370 | responses: 371 | <<: 372 | "400": 373 | $ref: "#/components/responses/badRequest" 374 | x-amazon-apigateway-integration: 375 | responses: 376 | "200": 377 | statusCode: 200 378 | responseParameters: 379 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 380 | requestParameters: 381 | integration.request.header.Accept: method.request.header.Accept 382 | post: 383 | <<: 384 | parameters: null 385 | responses: 386 | <<: 387 | "400": 388 | $ref: "#/components/responses/badRequest" 389 | x-amazon-apigateway-integration: 390 | responses: 391 | "200": 392 | statusCode: 200 393 | responseParameters: 394 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 395 | requestParameters: 396 | integration.request.header.Accept: method.request.header.Accept 397 | /resource8: 398 | options: 399 | x-amazon-apigateway-integration: 400 | responses: 401 | default: 402 | statusCode: "200" 403 | responseParameters: 404 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 405 | x-amazon-apigateway-any-method: 406 | parameters: null 407 | responses: 408 | <<: 409 | "400": 410 | $ref: "#/components/responses/badRequest" 411 | x-amazon-apigateway-integration: 412 | responses: 413 | "200": 414 | statusCode: 200 415 | responseParameters: 416 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 417 | requestParameters: 418 | integration.request.header.Accept: method.request.header.Accept 419 | get: 420 | <<: 421 | parameters: null 422 | responses: 423 | <<: 424 | "400": 425 | $ref: "#/components/responses/badRequest" 426 | x-amazon-apigateway-integration: 427 | responses: 428 | "200": 429 | statusCode: 200 430 | responseParameters: 431 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 432 | requestParameters: 433 | integration.request.header.Accept: method.request.header.Accept 434 | post: 435 | <<: 436 | parameters: null 437 | responses: 438 | <<: 439 | "400": 440 | $ref: "#/components/responses/badRequest" 441 | x-amazon-apigateway-integration: 442 | responses: 443 | "200": 444 | statusCode: 200 445 | responseParameters: 446 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 447 | requestParameters: 448 | integration.request.header.Accept: method.request.header.Accept 449 | /resource9: 450 | options: 451 | x-amazon-apigateway-integration: 452 | responses: 453 | default: 454 | statusCode: "200" 455 | responseParameters: 456 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 457 | x-amazon-apigateway-any-method: 458 | parameters: null 459 | responses: 460 | <<: 461 | "400": 462 | $ref: "#/components/responses/badRequest" 463 | x-amazon-apigateway-integration: 464 | responses: 465 | "200": 466 | statusCode: 200 467 | responseParameters: 468 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 469 | requestParameters: 470 | integration.request.header.Accept: method.request.header.Accept 471 | get: 472 | <<: 473 | parameters: null 474 | responses: 475 | <<: 476 | "400": 477 | $ref: "#/components/responses/badRequest" 478 | x-amazon-apigateway-integration: 479 | responses: 480 | "200": 481 | statusCode: 200 482 | responseParameters: 483 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 484 | requestParameters: 485 | integration.request.header.Accept: method.request.header.Accept 486 | post: 487 | <<: 488 | parameters: null 489 | responses: 490 | <<: 491 | "400": 492 | $ref: "#/components/responses/badRequest" 493 | x-amazon-apigateway-integration: 494 | responses: 495 | "200": 496 | statusCode: 200 497 | responseParameters: 498 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 499 | requestParameters: 500 | integration.request.header.Accept: method.request.header.Accept 501 | /resource10: 502 | options: 503 | x-amazon-apigateway-integration: 504 | responses: 505 | default: 506 | statusCode: "200" 507 | responseParameters: 508 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 509 | x-amazon-apigateway-any-method: 510 | parameters: null 511 | responses: 512 | <<: 513 | "400": 514 | $ref: "#/components/responses/badRequest" 515 | x-amazon-apigateway-integration: 516 | responses: 517 | "200": 518 | statusCode: 200 519 | responseParameters: 520 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 521 | requestParameters: 522 | integration.request.header.Accept: method.request.header.Accept 523 | get: 524 | <<: 525 | parameters: null 526 | responses: 527 | <<: 528 | "400": 529 | $ref: "#/components/responses/badRequest" 530 | x-amazon-apigateway-integration: 531 | responses: 532 | "200": 533 | statusCode: 200 534 | responseParameters: 535 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 536 | requestParameters: 537 | integration.request.header.Accept: method.request.header.Accept 538 | post: 539 | <<: 540 | parameters: null 541 | responses: 542 | <<: 543 | "400": 544 | $ref: "#/components/responses/badRequest" 545 | x-amazon-apigateway-integration: 546 | responses: 547 | "200": 548 | statusCode: 200 549 | responseParameters: 550 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 551 | requestParameters: 552 | integration.request.header.Accept: method.request.header.Accept 553 | /resource11: 554 | options: 555 | x-amazon-apigateway-integration: 556 | responses: 557 | default: 558 | statusCode: "200" 559 | responseParameters: 560 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 561 | x-amazon-apigateway-any-method: 562 | parameters: null 563 | responses: 564 | <<: 565 | "400": 566 | $ref: "#/components/responses/badRequest" 567 | x-amazon-apigateway-integration: 568 | responses: 569 | "200": 570 | statusCode: 200 571 | responseParameters: 572 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 573 | requestParameters: 574 | integration.request.header.Accept: method.request.header.Accept 575 | get: 576 | <<: 577 | parameters: null 578 | responses: 579 | <<: 580 | "400": 581 | $ref: "#/components/responses/badRequest" 582 | x-amazon-apigateway-integration: 583 | responses: 584 | "200": 585 | statusCode: 200 586 | responseParameters: 587 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 588 | requestParameters: 589 | integration.request.header.Accept: method.request.header.Accept 590 | post: 591 | <<: 592 | parameters: null 593 | responses: 594 | <<: 595 | "400": 596 | $ref: "#/components/responses/badRequest" 597 | x-amazon-apigateway-integration: 598 | responses: 599 | "200": 600 | statusCode: 200 601 | responseParameters: 602 | method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" 603 | requestParameters: 604 | integration.request.header.Accept: method.request.header.Accept 605 | components: 606 | responses: 607 | 200withcors: 608 | description: Successful response 609 | badRequest: 610 | description: Bad request 611 | -------------------------------------------------------------------------------- /test/asyncapi/input.yaml: -------------------------------------------------------------------------------- 1 | asyncapi: '2.0.0' 2 | info: 3 | title: Streetlights API 4 | version: '1.0.0' 5 | description: | 6 | The Smartylighting Streetlights API allows you to remotely manage the city lights. 7 | 8 | ### Check out its awesome features: 9 | 10 | * Turn a specific streetlight on/off 🌃 11 | * Dim a specific streetlight 😎 12 | * Receive real-time information about environmental lighting conditions 📈 13 | license: 14 | name: Apache 2.0 15 | url: https://www.apache.org/licenses/LICENSE-2.0 16 | 17 | servers: 18 | production: 19 | url: test.mosquitto.org:{port} 20 | protocol: mqtt 21 | description: Test broker 22 | variables: 23 | port: 24 | description: Secure connection (TLS) is available through port 8883. 25 | default: '1883' 26 | enum: 27 | - '1883' 28 | - '8883' 29 | security: 30 | - apiKey: [] 31 | - supportedOauthFlows: 32 | - streetlights:on 33 | - streetlights:off 34 | - streetlights:dim 35 | - openIdConnectWellKnown: [] 36 | 37 | defaultContentType: application/json 38 | 39 | channels: 40 | smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured: 41 | description: The topic on which measured values may be produced and consumed. 42 | parameters: 43 | streetlightId: 44 | $ref: '#/components/parameters/streetlightId' 45 | publish: 46 | summary: Inform about environmental lighting conditions of a particular streetlight. 47 | operationId: receiveLightMeasurement 48 | traits: 49 | - $ref: '#/components/operationTraits/kafka' 50 | message: 51 | $ref: '#/components/messages/lightMeasured' 52 | 53 | smartylighting/streetlights/1/0/action/{streetlightId}/turn/on: 54 | parameters: 55 | streetlightId: 56 | $ref: '#/components/parameters/streetlightId' 57 | subscribe: 58 | operationId: turnOn 59 | traits: 60 | - $ref: '#/components/operationTraits/kafka' 61 | message: 62 | $ref: '#/components/messages/turnOnOff' 63 | 64 | smartylighting/streetlights/1/0/action/{streetlightId}/turn/off: 65 | parameters: 66 | streetlightId: 67 | $ref: '#/components/parameters/streetlightId' 68 | subscribe: 69 | operationId: turnOff 70 | traits: 71 | - $ref: '#/components/operationTraits/kafka' 72 | message: 73 | $ref: '#/components/messages/turnOnOff' 74 | 75 | smartylighting/streetlights/1/0/action/{streetlightId}/dim: 76 | x-internal: true 77 | parameters: 78 | streetlightId: 79 | $ref: '#/components/parameters/streetlightId' 80 | subscribe: 81 | operationId: dimLight 82 | traits: 83 | - $ref: '#/components/operationTraits/kafka' 84 | message: 85 | $ref: '#/components/messages/dimLight' 86 | 87 | components: 88 | messages: 89 | lightMeasured: 90 | name: lightMeasured 91 | title: Light measured 92 | summary: Inform about environmental lighting conditions of a particular streetlight. 93 | contentType: application/json 94 | traits: 95 | - $ref: '#/components/messageTraits/commonHeaders' 96 | payload: 97 | $ref: "#/components/schemas/lightMeasuredPayload" 98 | turnOnOff: 99 | name: turnOnOff 100 | title: Turn on/off 101 | summary: Command a particular streetlight to turn the lights on or off. 102 | traits: 103 | - $ref: '#/components/messageTraits/commonHeaders' 104 | payload: 105 | $ref: "#/components/schemas/turnOnOffPayload" 106 | dimLight: 107 | name: dimLight 108 | title: Dim light 109 | summary: Command a particular streetlight to dim the lights. 110 | traits: 111 | - $ref: '#/components/messageTraits/commonHeaders' 112 | payload: 113 | $ref: "#/components/schemas/dimLightPayload" 114 | 115 | schemas: 116 | lightMeasuredPayload: 117 | type: object 118 | properties: 119 | lumens: 120 | type: integer 121 | minimum: 0 122 | description: Light intensity measured in lumens. 123 | sentAt: 124 | $ref: "#/components/schemas/sentAt" 125 | turnOnOffPayload: 126 | type: object 127 | properties: 128 | command: 129 | type: string 130 | enum: 131 | - on 132 | - off 133 | description: Whether to turn on or off the light. 134 | sentAt: 135 | $ref: "#/components/schemas/sentAt" 136 | dimLightPayload: 137 | type: object 138 | properties: 139 | percentage: 140 | type: integer 141 | description: Percentage to which the light should be dimmed to. 142 | minimum: 0 143 | maximum: 100 144 | sentAt: 145 | $ref: "#/components/schemas/sentAt" 146 | sentAt: 147 | type: string 148 | format: date-time 149 | description: Date and time when the message was sent. 150 | 151 | securitySchemes: 152 | apiKey: 153 | type: apiKey 154 | in: user 155 | description: Provide your API key as the user and leave the password empty. 156 | supportedOauthFlows: 157 | type: oauth2 158 | description: Flows to support OAuth 2.0 159 | flows: 160 | implicit: 161 | authorizationUrl: 'https://authserver.example/auth' 162 | scopes: 163 | 'streetlights:on': Ability to switch lights on 164 | 'streetlights:off': Ability to switch lights off 165 | 'streetlights:dim': Ability to dim the lights 166 | password: 167 | tokenUrl: 'https://authserver.example/token' 168 | scopes: 169 | 'streetlights:on': Ability to switch lights on 170 | 'streetlights:off': Ability to switch lights off 171 | 'streetlights:dim': Ability to dim the lights 172 | clientCredentials: 173 | tokenUrl: 'https://authserver.example/token' 174 | scopes: 175 | 'streetlights:on': Ability to switch lights on 176 | 'streetlights:off': Ability to switch lights off 177 | 'streetlights:dim': Ability to dim the lights 178 | authorizationCode: 179 | authorizationUrl: 'https://authserver.example/auth' 180 | tokenUrl: 'https://authserver.example/token' 181 | refreshUrl: 'https://authserver.example/refresh' 182 | scopes: 183 | 'streetlights:on': Ability to switch lights on 184 | 'streetlights:off': Ability to switch lights off 185 | 'streetlights:dim': Ability to dim the lights 186 | openIdConnectWellKnown: 187 | type: openIdConnect 188 | openIdConnectUrl: 'https://authserver.example/.well-known' 189 | 190 | parameters: 191 | streetlightId: 192 | description: The ID of the streetlight. 193 | schema: 194 | type: string 195 | 196 | messageTraits: 197 | commonHeaders: 198 | headers: 199 | type: object 200 | properties: 201 | my-app-header: 202 | type: integer 203 | minimum: 0 204 | maximum: 100 205 | 206 | operationTraits: 207 | kafka: 208 | bindings: 209 | kafka: 210 | clientId: my-app-id 211 | -------------------------------------------------------------------------------- /test/asyncapi/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | valid: true 3 | -------------------------------------------------------------------------------- /test/asyncapi/output.yaml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0 2 | info: 3 | title: Streetlights API 4 | version: 1.0.0 5 | channels: 6 | "smartylighting/streetlights/1/0/action/{streetlightId}/dim": 7 | x-internal: true 8 | parameters: 9 | streetlightId: 10 | $ref: "#/components/parameters/streetlightId" 11 | subscribe: 12 | operationId: dimLight 13 | traits: 14 | - $ref: "#/components/operationTraits/kafka" 15 | message: 16 | $ref: "#/components/messages/dimLight" 17 | components: 18 | parameters: 19 | streetlightId: 20 | description: The ID of the streetlight. 21 | schema: 22 | type: string 23 | operationTraits: 24 | kafka: 25 | bindings: 26 | kafka: 27 | clientId: my-app-id 28 | messages: 29 | dimLight: 30 | name: dimLight 31 | title: Dim light 32 | summary: Command a particular streetlight to dim the lights. 33 | traits: 34 | - $ref: "#/components/messageTraits/commonHeaders" 35 | payload: 36 | $ref: "#/components/schemas/dimLightPayload" 37 | messageTraits: 38 | commonHeaders: 39 | headers: 40 | type: object 41 | properties: 42 | my-app-header: 43 | type: integer 44 | minimum: 0 45 | maximum: 100 46 | schemas: 47 | dimLightPayload: 48 | type: object 49 | properties: 50 | percentage: 51 | type: integer 52 | description: Percentage to which the light should be dimmed to. 53 | minimum: 0 54 | maximum: 100 55 | sentAt: 56 | $ref: "#/components/schemas/sentAt" 57 | sentAt: 58 | type: string 59 | format: date-time 60 | description: Date and time when the message was sent. 61 | -------------------------------------------------------------------------------- /test/checkTags1/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | servers: 3 | - url: http://petstore.swagger.io/v2 4 | x-origin: 5 | - url: http://petstore.swagger.io/v2/swagger.json 6 | format: swagger 7 | version: "2.0" 8 | converter: 9 | url: https://github.com/mermade/swagger2openapi 10 | version: 2.6.3 11 | info: 12 | description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters." 13 | version: 1.0.0 14 | title: Swagger Petstore 15 | termsOfService: http://swagger.io/terms/ 16 | contact: 17 | email: apiteam@swagger.io 18 | license: 19 | name: Apache 2.0 20 | url: http://www.apache.org/licenses/LICENSE-2.0.html 21 | tags: 22 | - name: pet 23 | description: Everything about your Pets 24 | externalDocs: 25 | description: Find out more 26 | url: http://swagger.io 27 | - name: store 28 | description: Access to Petstore orders 29 | - name: user 30 | description: Operations about user 31 | externalDocs: 32 | description: Find out more about our store 33 | url: http://swagger.io 34 | paths: 35 | /pet: 36 | post: 37 | tags: 38 | - pet 39 | summary: Add a new pet to the store 40 | description: "" 41 | operationId: addPet 42 | responses: 43 | "405": 44 | description: Invalid input 45 | security: 46 | - petstore_auth: 47 | - write:pets 48 | - read:pets 49 | requestBody: 50 | $ref: "#/components/requestBodies/Pet" 51 | put: 52 | tags: 53 | - pet 54 | summary: Update an existing pet 55 | description: "" 56 | operationId: updatePet 57 | responses: 58 | "400": 59 | description: Invalid ID supplied 60 | "404": 61 | description: Pet not found 62 | "405": 63 | description: Validation exception 64 | security: 65 | - petstore_auth: 66 | - write:pets 67 | - read:pets 68 | requestBody: 69 | $ref: "#/components/requestBodies/Pet" 70 | /pet/findByStatus: 71 | get: 72 | tags: 73 | - pet 74 | summary: Finds Pets by status 75 | description: Multiple status values can be provided with comma separated strings 76 | operationId: findPetsByStatus 77 | parameters: 78 | - name: status 79 | in: query 80 | description: Status values that need to be considered for filter 81 | required: true 82 | explode: true 83 | schema: 84 | type: array 85 | items: 86 | type: string 87 | enum: 88 | - available 89 | - pending 90 | - sold 91 | default: available 92 | responses: 93 | "200": 94 | description: successful operation 95 | content: 96 | application/xml: 97 | schema: 98 | type: array 99 | items: 100 | $ref: "#/components/schemas/Pet" 101 | application/json: 102 | schema: 103 | type: array 104 | items: 105 | $ref: "#/components/schemas/Pet" 106 | "400": 107 | description: Invalid status value 108 | security: 109 | - petstore_auth: 110 | - write:pets 111 | - read:pets 112 | /pet/findByTags: 113 | get: 114 | tags: 115 | - pet 116 | summary: Finds Pets by tags 117 | description: Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 118 | operationId: findPetsByTags 119 | parameters: 120 | - name: tags 121 | in: query 122 | description: Tags to filter by 123 | required: true 124 | explode: true 125 | schema: 126 | type: array 127 | items: 128 | type: string 129 | responses: 130 | "200": 131 | description: successful operation 132 | content: 133 | application/xml: 134 | schema: 135 | type: array 136 | items: 137 | $ref: "#/components/schemas/Pet" 138 | application/json: 139 | schema: 140 | type: array 141 | items: 142 | $ref: "#/components/schemas/Pet" 143 | "400": 144 | description: Invalid tag value 145 | security: 146 | - petstore_auth: 147 | - write:pets 148 | - read:pets 149 | deprecated: true 150 | "/pet/{petId}": 151 | get: 152 | tags: 153 | - pet 154 | summary: Find pet by ID 155 | description: Returns a single pet 156 | operationId: getPetById 157 | parameters: 158 | - name: petId 159 | in: path 160 | description: ID of pet to return 161 | required: true 162 | schema: 163 | type: integer 164 | format: int64 165 | responses: 166 | "200": 167 | description: successful operation 168 | content: 169 | application/xml: 170 | schema: 171 | $ref: "#/components/schemas/Pet" 172 | application/json: 173 | schema: 174 | $ref: "#/components/schemas/Pet" 175 | "400": 176 | description: Invalid ID supplied 177 | "404": 178 | description: Pet not found 179 | security: 180 | - api_key: [] 181 | post: 182 | tags: 183 | - pet 184 | summary: Updates a pet in the store with form data 185 | description: "" 186 | operationId: updatePetWithForm 187 | parameters: 188 | - name: petId 189 | in: path 190 | description: ID of pet that needs to be updated 191 | required: true 192 | schema: 193 | type: integer 194 | format: int64 195 | responses: 196 | "405": 197 | description: Invalid input 198 | security: 199 | - petstore_auth: 200 | - write:pets 201 | - read:pets 202 | requestBody: 203 | content: 204 | application/x-www-form-urlencoded: 205 | schema: 206 | type: object 207 | properties: 208 | name: 209 | description: Updated name of the pet 210 | type: string 211 | status: 212 | description: Updated status of the pet 213 | type: string 214 | delete: 215 | tags: 216 | - pet 217 | summary: Deletes a pet 218 | description: "" 219 | operationId: deletePet 220 | parameters: 221 | - name: api_key 222 | in: header 223 | required: false 224 | schema: 225 | type: string 226 | - name: petId 227 | in: path 228 | description: Pet id to delete 229 | required: true 230 | schema: 231 | type: integer 232 | format: int64 233 | responses: 234 | "400": 235 | description: Invalid ID supplied 236 | "404": 237 | description: Pet not found 238 | security: 239 | - petstore_auth: 240 | - write:pets 241 | - read:pets 242 | "/pet/{petId}/uploadImage": 243 | post: 244 | tags: 245 | - pet 246 | summary: uploads an image 247 | description: "" 248 | operationId: uploadFile 249 | parameters: 250 | - name: petId 251 | in: path 252 | description: ID of pet to update 253 | required: true 254 | schema: 255 | type: integer 256 | format: int64 257 | responses: 258 | "200": 259 | description: successful operation 260 | content: 261 | application/json: 262 | schema: 263 | $ref: "#/components/schemas/ApiResponse" 264 | security: 265 | - petstore_auth: 266 | - write:pets 267 | - read:pets 268 | requestBody: 269 | content: 270 | application/octet-stream: 271 | schema: 272 | type: string 273 | format: binary 274 | /store/inventory: 275 | get: 276 | tags: 277 | - store 278 | summary: Returns pet inventories by status 279 | description: Returns a map of status codes to quantities 280 | operationId: getInventory 281 | responses: 282 | "200": 283 | description: successful operation 284 | content: 285 | application/json: 286 | schema: 287 | type: object 288 | additionalProperties: 289 | type: integer 290 | format: int32 291 | security: 292 | - api_key: [] 293 | /store/order: 294 | post: 295 | tags: 296 | - store 297 | summary: Place an order for a pet 298 | description: "" 299 | operationId: placeOrder 300 | responses: 301 | "200": 302 | description: successful operation 303 | content: 304 | application/xml: 305 | schema: 306 | $ref: "#/components/schemas/Order" 307 | application/json: 308 | schema: 309 | $ref: "#/components/schemas/Order" 310 | "400": 311 | description: Invalid Order 312 | requestBody: 313 | content: 314 | application/json: 315 | schema: 316 | $ref: "#/components/schemas/Order" 317 | description: order placed for purchasing the pet 318 | required: true 319 | "/store/order/{orderId}": 320 | get: 321 | tags: 322 | - store 323 | summary: Find purchase order by ID 324 | description: For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions 325 | operationId: getOrderById 326 | parameters: 327 | - name: orderId 328 | in: path 329 | description: ID of pet that needs to be fetched 330 | required: true 331 | schema: 332 | type: integer 333 | format: int64 334 | minimum: 1 335 | maximum: 10 336 | responses: 337 | "200": 338 | description: successful operation 339 | content: 340 | application/xml: 341 | schema: 342 | $ref: "#/components/schemas/Order" 343 | application/json: 344 | schema: 345 | $ref: "#/components/schemas/Order" 346 | "400": 347 | description: Invalid ID supplied 348 | "404": 349 | description: Order not found 350 | delete: 351 | tags: 352 | - store 353 | summary: Delete purchase order by ID 354 | description: For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors 355 | operationId: deleteOrder 356 | parameters: 357 | - name: orderId 358 | in: path 359 | description: ID of the order that needs to be deleted 360 | required: true 361 | schema: 362 | type: integer 363 | format: int64 364 | minimum: 1 365 | responses: 366 | "400": 367 | description: Invalid ID supplied 368 | "404": 369 | description: Order not found 370 | /user: 371 | post: 372 | tags: 373 | - user 374 | summary: Create user 375 | description: This can only be done by the logged in user. 376 | operationId: createUser 377 | responses: 378 | default: 379 | description: successful operation 380 | requestBody: 381 | content: 382 | application/json: 383 | schema: 384 | $ref: "#/components/schemas/User" 385 | description: Created user object 386 | required: true 387 | /user/createWithArray: 388 | post: 389 | tags: 390 | - user 391 | summary: Creates list of users with given input array 392 | description: "" 393 | operationId: createUsersWithArrayInput 394 | responses: 395 | default: 396 | description: successful operation 397 | requestBody: 398 | $ref: "#/components/requestBodies/UserArray" 399 | /user/createWithList: 400 | post: 401 | tags: 402 | - user 403 | summary: Creates list of users with given input array 404 | description: "" 405 | operationId: createUsersWithListInput 406 | responses: 407 | default: 408 | description: successful operation 409 | requestBody: 410 | $ref: "#/components/requestBodies/UserArray" 411 | /user/login: 412 | get: 413 | tags: 414 | - user 415 | summary: Logs user into the system 416 | description: "" 417 | operationId: loginUser 418 | parameters: 419 | - name: username 420 | in: query 421 | description: The user name for login 422 | required: true 423 | schema: 424 | type: string 425 | - name: password 426 | in: query 427 | description: The password for login in clear text 428 | required: true 429 | schema: 430 | type: string 431 | format: password 432 | responses: 433 | "200": 434 | description: successful operation 435 | headers: 436 | X-Rate-Limit: 437 | description: calls per hour allowed by the user 438 | schema: 439 | type: integer 440 | format: int32 441 | X-Expires-After: 442 | description: date in UTC when token expires 443 | schema: 444 | type: string 445 | format: date-time 446 | content: 447 | application/xml: 448 | schema: 449 | type: string 450 | application/json: 451 | schema: 452 | type: string 453 | "400": 454 | description: Invalid username/password supplied 455 | /user/logout: 456 | get: 457 | tags: 458 | - user 459 | summary: Logs out current logged in user session 460 | description: "" 461 | operationId: logoutUser 462 | responses: 463 | default: 464 | description: successful operation 465 | "/user/{username}": 466 | get: 467 | tags: 468 | - user 469 | summary: Get user by user name 470 | description: "" 471 | operationId: getUserByName 472 | parameters: 473 | - name: username 474 | in: path 475 | description: "The name that needs to be fetched. Use user1 for testing. " 476 | required: true 477 | schema: 478 | type: string 479 | responses: 480 | "200": 481 | description: successful operation 482 | content: 483 | application/xml: 484 | schema: 485 | $ref: "#/components/schemas/User" 486 | application/json: 487 | schema: 488 | $ref: "#/components/schemas/User" 489 | "400": 490 | description: Invalid username supplied 491 | "404": 492 | description: User not found 493 | put: 494 | tags: 495 | - user 496 | summary: Updated user 497 | description: This can only be done by the logged in user. 498 | operationId: updateUser 499 | parameters: 500 | - name: username 501 | in: path 502 | description: name that need to be updated 503 | required: true 504 | schema: 505 | type: string 506 | responses: 507 | "400": 508 | description: Invalid user supplied 509 | "404": 510 | description: User not found 511 | requestBody: 512 | content: 513 | application/json: 514 | schema: 515 | $ref: "#/components/schemas/User" 516 | description: Updated user object 517 | required: true 518 | delete: 519 | tags: 520 | - user 521 | summary: Delete user 522 | description: This can only be done by the logged in user. 523 | operationId: deleteUser 524 | parameters: 525 | - name: username 526 | in: path 527 | description: The name that needs to be deleted 528 | required: true 529 | schema: 530 | type: string 531 | responses: 532 | "400": 533 | description: Invalid username supplied 534 | "404": 535 | description: User not found 536 | externalDocs: 537 | description: Find out more about Swagger 538 | url: http://swagger.io 539 | components: 540 | schemas: 541 | Order: 542 | type: object 543 | properties: 544 | id: 545 | type: integer 546 | format: int64 547 | petId: 548 | type: integer 549 | format: int64 550 | quantity: 551 | type: integer 552 | format: int32 553 | shipDate: 554 | type: string 555 | format: date-time 556 | status: 557 | type: string 558 | description: Order Status 559 | enum: 560 | - placed 561 | - approved 562 | - delivered 563 | complete: 564 | type: boolean 565 | default: false 566 | xml: 567 | name: Order 568 | Category: 569 | type: object 570 | properties: 571 | id: 572 | type: integer 573 | format: int64 574 | name: 575 | type: string 576 | xml: 577 | name: Category 578 | User: 579 | type: object 580 | properties: 581 | id: 582 | type: integer 583 | format: int64 584 | username: 585 | type: string 586 | firstName: 587 | type: string 588 | lastName: 589 | type: string 590 | email: 591 | type: string 592 | password: 593 | type: string 594 | phone: 595 | type: string 596 | userStatus: 597 | type: integer 598 | format: int32 599 | description: User Status 600 | xml: 601 | name: User 602 | Tag: 603 | type: object 604 | properties: 605 | id: 606 | type: integer 607 | format: int64 608 | name: 609 | type: string 610 | xml: 611 | name: Tag 612 | Pet: 613 | type: object 614 | required: 615 | - name 616 | - photoUrls 617 | properties: 618 | id: 619 | type: integer 620 | format: int64 621 | category: 622 | $ref: "#/components/schemas/Category" 623 | name: 624 | type: string 625 | example: doggie 626 | photoUrls: 627 | type: array 628 | xml: 629 | name: photoUrl 630 | wrapped: true 631 | items: 632 | type: string 633 | tags: 634 | type: array 635 | xml: 636 | name: tag 637 | wrapped: true 638 | items: 639 | $ref: "#/components/schemas/Tag" 640 | status: 641 | type: string 642 | description: pet status in the store 643 | enum: 644 | - available 645 | - pending 646 | - sold 647 | xml: 648 | name: Pet 649 | ApiResponse: 650 | type: object 651 | properties: 652 | code: 653 | type: integer 654 | format: int32 655 | type: 656 | type: string 657 | message: 658 | type: string 659 | requestBodies: 660 | Pet: 661 | content: 662 | application/json: 663 | schema: 664 | $ref: "#/components/schemas/Pet" 665 | application/xml: 666 | schema: 667 | $ref: "#/components/schemas/Pet" 668 | description: Pet object that needs to be added to the store 669 | required: true 670 | UserArray: 671 | content: 672 | application/json: 673 | schema: 674 | type: array 675 | items: 676 | $ref: "#/components/schemas/User" 677 | description: List of user object 678 | required: true 679 | securitySchemes: 680 | petstore_auth: 681 | type: oauth2 682 | flows: 683 | implicit: 684 | authorizationUrl: http://petstore.swagger.io/oauth/dialog 685 | scopes: 686 | write:pets: modify pets in your account 687 | read:pets: read your pets 688 | api_key: 689 | type: apiKey 690 | name: api_key 691 | in: header 692 | -------------------------------------------------------------------------------- /test/checkTags1/options.yaml: -------------------------------------------------------------------------------- 1 | flags: [ 'user' ] 2 | checkTags: true 3 | -------------------------------------------------------------------------------- /test/checkTags1/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | servers: 3 | - url: http://petstore.swagger.io/v2 4 | x-origin: 5 | - url: http://petstore.swagger.io/v2/swagger.json 6 | format: swagger 7 | version: "2.0" 8 | converter: 9 | url: https://github.com/mermade/swagger2openapi 10 | version: 2.6.3 11 | info: 12 | description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters." 13 | version: 1.0.0 14 | title: Swagger Petstore 15 | termsOfService: http://swagger.io/terms/ 16 | contact: 17 | email: apiteam@swagger.io 18 | license: 19 | name: Apache 2.0 20 | url: http://www.apache.org/licenses/LICENSE-2.0.html 21 | tags: 22 | - name: pet 23 | description: Everything about your Pets 24 | externalDocs: 25 | description: Find out more 26 | url: http://swagger.io 27 | - name: store 28 | description: Access to Petstore orders 29 | - name: user 30 | description: Operations about user 31 | externalDocs: 32 | description: Find out more about our store 33 | url: http://swagger.io 34 | paths: 35 | /pet: 36 | post: 37 | tags: 38 | - pet 39 | summary: Add a new pet to the store 40 | description: "" 41 | operationId: addPet 42 | responses: 43 | "405": 44 | description: Invalid input 45 | security: 46 | - petstore_auth: 47 | - write:pets 48 | - read:pets 49 | requestBody: 50 | $ref: "#/components/requestBodies/Pet" 51 | put: 52 | tags: 53 | - pet 54 | summary: Update an existing pet 55 | description: "" 56 | operationId: updatePet 57 | responses: 58 | "400": 59 | description: Invalid ID supplied 60 | "404": 61 | description: Pet not found 62 | "405": 63 | description: Validation exception 64 | security: 65 | - petstore_auth: 66 | - write:pets 67 | - read:pets 68 | requestBody: 69 | $ref: "#/components/requestBodies/Pet" 70 | /pet/findByStatus: 71 | get: 72 | tags: 73 | - pet 74 | summary: Finds Pets by status 75 | description: Multiple status values can be provided with comma separated strings 76 | operationId: findPetsByStatus 77 | parameters: 78 | - name: status 79 | in: query 80 | description: Status values that need to be considered for filter 81 | required: true 82 | explode: true 83 | schema: 84 | type: array 85 | items: 86 | type: string 87 | enum: 88 | - available 89 | - pending 90 | - sold 91 | default: available 92 | responses: 93 | "200": 94 | description: successful operation 95 | content: 96 | application/xml: 97 | schema: 98 | type: array 99 | items: 100 | $ref: "#/components/schemas/Pet" 101 | application/json: 102 | schema: 103 | type: array 104 | items: 105 | $ref: "#/components/schemas/Pet" 106 | "400": 107 | description: Invalid status value 108 | security: 109 | - petstore_auth: 110 | - write:pets 111 | - read:pets 112 | /pet/findByTags: 113 | get: 114 | tags: 115 | - pet 116 | summary: Finds Pets by tags 117 | description: Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 118 | operationId: findPetsByTags 119 | parameters: 120 | - name: tags 121 | in: query 122 | description: Tags to filter by 123 | required: true 124 | explode: true 125 | schema: 126 | type: array 127 | items: 128 | type: string 129 | responses: 130 | "200": 131 | description: successful operation 132 | content: 133 | application/xml: 134 | schema: 135 | type: array 136 | items: 137 | $ref: "#/components/schemas/Pet" 138 | application/json: 139 | schema: 140 | type: array 141 | items: 142 | $ref: "#/components/schemas/Pet" 143 | "400": 144 | description: Invalid tag value 145 | security: 146 | - petstore_auth: 147 | - write:pets 148 | - read:pets 149 | deprecated: true 150 | "/pet/{petId}": 151 | get: 152 | tags: 153 | - pet 154 | summary: Find pet by ID 155 | description: Returns a single pet 156 | operationId: getPetById 157 | parameters: 158 | - name: petId 159 | in: path 160 | description: ID of pet to return 161 | required: true 162 | schema: 163 | type: integer 164 | format: int64 165 | responses: 166 | "200": 167 | description: successful operation 168 | content: 169 | application/xml: 170 | schema: 171 | $ref: "#/components/schemas/Pet" 172 | application/json: 173 | schema: 174 | $ref: "#/components/schemas/Pet" 175 | "400": 176 | description: Invalid ID supplied 177 | "404": 178 | description: Pet not found 179 | security: 180 | - api_key: [] 181 | post: 182 | tags: 183 | - pet 184 | summary: Updates a pet in the store with form data 185 | description: "" 186 | operationId: updatePetWithForm 187 | parameters: 188 | - name: petId 189 | in: path 190 | description: ID of pet that needs to be updated 191 | required: true 192 | schema: 193 | type: integer 194 | format: int64 195 | responses: 196 | "405": 197 | description: Invalid input 198 | security: 199 | - petstore_auth: 200 | - write:pets 201 | - read:pets 202 | requestBody: 203 | content: 204 | application/x-www-form-urlencoded: 205 | schema: 206 | type: object 207 | properties: 208 | name: 209 | description: Updated name of the pet 210 | type: string 211 | status: 212 | description: Updated status of the pet 213 | type: string 214 | delete: 215 | tags: 216 | - pet 217 | summary: Deletes a pet 218 | description: "" 219 | operationId: deletePet 220 | parameters: 221 | - name: api_key 222 | in: header 223 | required: false 224 | schema: 225 | type: string 226 | - name: petId 227 | in: path 228 | description: Pet id to delete 229 | required: true 230 | schema: 231 | type: integer 232 | format: int64 233 | responses: 234 | "400": 235 | description: Invalid ID supplied 236 | "404": 237 | description: Pet not found 238 | security: 239 | - petstore_auth: 240 | - write:pets 241 | - read:pets 242 | "/pet/{petId}/uploadImage": 243 | post: 244 | tags: 245 | - pet 246 | summary: uploads an image 247 | description: "" 248 | operationId: uploadFile 249 | parameters: 250 | - name: petId 251 | in: path 252 | description: ID of pet to update 253 | required: true 254 | schema: 255 | type: integer 256 | format: int64 257 | responses: 258 | "200": 259 | description: successful operation 260 | content: 261 | application/json: 262 | schema: 263 | $ref: "#/components/schemas/ApiResponse" 264 | security: 265 | - petstore_auth: 266 | - write:pets 267 | - read:pets 268 | requestBody: 269 | content: 270 | application/octet-stream: 271 | schema: 272 | type: string 273 | format: binary 274 | /store/inventory: 275 | get: 276 | tags: 277 | - store 278 | summary: Returns pet inventories by status 279 | description: Returns a map of status codes to quantities 280 | operationId: getInventory 281 | responses: 282 | "200": 283 | description: successful operation 284 | content: 285 | application/json: 286 | schema: 287 | type: object 288 | additionalProperties: 289 | type: integer 290 | format: int32 291 | security: 292 | - api_key: [] 293 | /store/order: 294 | post: 295 | tags: 296 | - store 297 | summary: Place an order for a pet 298 | description: "" 299 | operationId: placeOrder 300 | responses: 301 | "200": 302 | description: successful operation 303 | content: 304 | application/xml: 305 | schema: 306 | $ref: "#/components/schemas/Order" 307 | application/json: 308 | schema: 309 | $ref: "#/components/schemas/Order" 310 | "400": 311 | description: Invalid Order 312 | requestBody: 313 | content: 314 | application/json: 315 | schema: 316 | $ref: "#/components/schemas/Order" 317 | description: order placed for purchasing the pet 318 | required: true 319 | "/store/order/{orderId}": 320 | get: 321 | tags: 322 | - store 323 | summary: Find purchase order by ID 324 | description: For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions 325 | operationId: getOrderById 326 | parameters: 327 | - name: orderId 328 | in: path 329 | description: ID of pet that needs to be fetched 330 | required: true 331 | schema: 332 | type: integer 333 | format: int64 334 | minimum: 1 335 | maximum: 10 336 | responses: 337 | "200": 338 | description: successful operation 339 | content: 340 | application/xml: 341 | schema: 342 | $ref: "#/components/schemas/Order" 343 | application/json: 344 | schema: 345 | $ref: "#/components/schemas/Order" 346 | "400": 347 | description: Invalid ID supplied 348 | "404": 349 | description: Order not found 350 | delete: 351 | tags: 352 | - store 353 | summary: Delete purchase order by ID 354 | description: For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors 355 | operationId: deleteOrder 356 | parameters: 357 | - name: orderId 358 | in: path 359 | description: ID of the order that needs to be deleted 360 | required: true 361 | schema: 362 | type: integer 363 | format: int64 364 | minimum: 1 365 | responses: 366 | "400": 367 | description: Invalid ID supplied 368 | "404": 369 | description: Order not found 370 | externalDocs: 371 | description: Find out more about Swagger 372 | url: http://swagger.io 373 | components: 374 | schemas: 375 | Order: 376 | type: object 377 | properties: 378 | id: 379 | type: integer 380 | format: int64 381 | petId: 382 | type: integer 383 | format: int64 384 | quantity: 385 | type: integer 386 | format: int32 387 | shipDate: 388 | type: string 389 | format: date-time 390 | status: 391 | type: string 392 | description: Order Status 393 | enum: 394 | - placed 395 | - approved 396 | - delivered 397 | complete: 398 | type: boolean 399 | default: false 400 | xml: 401 | name: Order 402 | Category: 403 | type: object 404 | properties: 405 | id: 406 | type: integer 407 | format: int64 408 | name: 409 | type: string 410 | xml: 411 | name: Category 412 | User: 413 | type: object 414 | properties: 415 | id: 416 | type: integer 417 | format: int64 418 | username: 419 | type: string 420 | firstName: 421 | type: string 422 | lastName: 423 | type: string 424 | email: 425 | type: string 426 | password: 427 | type: string 428 | phone: 429 | type: string 430 | userStatus: 431 | type: integer 432 | format: int32 433 | description: User Status 434 | xml: 435 | name: User 436 | Tag: 437 | type: object 438 | properties: 439 | id: 440 | type: integer 441 | format: int64 442 | name: 443 | type: string 444 | xml: 445 | name: Tag 446 | Pet: 447 | type: object 448 | required: 449 | - name 450 | - photoUrls 451 | properties: 452 | id: 453 | type: integer 454 | format: int64 455 | category: 456 | $ref: "#/components/schemas/Category" 457 | name: 458 | type: string 459 | example: doggie 460 | photoUrls: 461 | type: array 462 | xml: 463 | name: photoUrl 464 | wrapped: true 465 | items: 466 | type: string 467 | tags: 468 | type: array 469 | xml: 470 | name: tag 471 | wrapped: true 472 | items: 473 | $ref: "#/components/schemas/Tag" 474 | status: 475 | type: string 476 | description: pet status in the store 477 | enum: 478 | - available 479 | - pending 480 | - sold 481 | xml: 482 | name: Pet 483 | ApiResponse: 484 | type: object 485 | properties: 486 | code: 487 | type: integer 488 | format: int32 489 | type: 490 | type: string 491 | message: 492 | type: string 493 | requestBodies: 494 | Pet: 495 | content: 496 | application/json: 497 | schema: 498 | $ref: "#/components/schemas/Pet" 499 | application/xml: 500 | schema: 501 | $ref: "#/components/schemas/Pet" 502 | description: Pet object that needs to be added to the store 503 | required: true 504 | UserArray: 505 | content: 506 | application/json: 507 | schema: 508 | type: array 509 | items: 510 | $ref: "#/components/schemas/User" 511 | description: List of user object 512 | required: true 513 | securitySchemes: 514 | petstore_auth: 515 | type: oauth2 516 | flows: 517 | implicit: 518 | authorizationUrl: http://petstore.swagger.io/oauth/dialog 519 | scopes: 520 | write:pets: modify pets in your account 521 | read:pets: read your pets 522 | api_key: 523 | type: apiKey 524 | name: api_key 525 | in: header 526 | -------------------------------------------------------------------------------- /test/checkTags2/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | servers: 3 | - url: http://petstore.swagger.io/v2 4 | x-origin: 5 | - url: http://petstore.swagger.io/v2/swagger.json 6 | format: swagger 7 | version: "2.0" 8 | converter: 9 | url: https://github.com/mermade/swagger2openapi 10 | version: 2.6.3 11 | info: 12 | description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters." 13 | version: 1.0.0 14 | title: Swagger Petstore 15 | termsOfService: http://swagger.io/terms/ 16 | contact: 17 | email: apiteam@swagger.io 18 | license: 19 | name: Apache 2.0 20 | url: http://www.apache.org/licenses/LICENSE-2.0.html 21 | tags: 22 | - name: pet 23 | description: Everything about your Pets 24 | externalDocs: 25 | description: Find out more 26 | url: http://swagger.io 27 | - name: store 28 | description: Access to Petstore orders 29 | - name: user 30 | description: Operations about user 31 | externalDocs: 32 | description: Find out more about our store 33 | url: http://swagger.io 34 | paths: 35 | /pet: 36 | post: 37 | tags: 38 | - pet 39 | summary: Add a new pet to the store 40 | description: "" 41 | operationId: addPet 42 | responses: 43 | "405": 44 | description: Invalid input 45 | security: 46 | - petstore_auth: 47 | - write:pets 48 | - read:pets 49 | requestBody: 50 | $ref: "#/components/requestBodies/Pet" 51 | put: 52 | tags: 53 | - pet 54 | summary: Update an existing pet 55 | description: "" 56 | operationId: updatePet 57 | responses: 58 | "400": 59 | description: Invalid ID supplied 60 | "404": 61 | description: Pet not found 62 | "405": 63 | description: Validation exception 64 | security: 65 | - petstore_auth: 66 | - write:pets 67 | - read:pets 68 | requestBody: 69 | $ref: "#/components/requestBodies/Pet" 70 | /pet/findByStatus: 71 | get: 72 | tags: 73 | - pet 74 | summary: Finds Pets by status 75 | description: Multiple status values can be provided with comma separated strings 76 | operationId: findPetsByStatus 77 | parameters: 78 | - name: status 79 | in: query 80 | description: Status values that need to be considered for filter 81 | required: true 82 | explode: true 83 | schema: 84 | type: array 85 | items: 86 | type: string 87 | enum: 88 | - available 89 | - pending 90 | - sold 91 | default: available 92 | responses: 93 | "200": 94 | description: successful operation 95 | content: 96 | application/xml: 97 | schema: 98 | type: array 99 | items: 100 | $ref: "#/components/schemas/Pet" 101 | application/json: 102 | schema: 103 | type: array 104 | items: 105 | $ref: "#/components/schemas/Pet" 106 | "400": 107 | description: Invalid status value 108 | security: 109 | - petstore_auth: 110 | - write:pets 111 | - read:pets 112 | /pet/findByTags: 113 | get: 114 | tags: 115 | - pet 116 | summary: Finds Pets by tags 117 | description: Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 118 | operationId: findPetsByTags 119 | parameters: 120 | - name: tags 121 | in: query 122 | description: Tags to filter by 123 | required: true 124 | explode: true 125 | schema: 126 | type: array 127 | items: 128 | type: string 129 | responses: 130 | "200": 131 | description: successful operation 132 | content: 133 | application/xml: 134 | schema: 135 | type: array 136 | items: 137 | $ref: "#/components/schemas/Pet" 138 | application/json: 139 | schema: 140 | type: array 141 | items: 142 | $ref: "#/components/schemas/Pet" 143 | "400": 144 | description: Invalid tag value 145 | security: 146 | - petstore_auth: 147 | - write:pets 148 | - read:pets 149 | deprecated: true 150 | "/pet/{petId}": 151 | get: 152 | tags: 153 | - pet 154 | summary: Find pet by ID 155 | description: Returns a single pet 156 | operationId: getPetById 157 | parameters: 158 | - name: petId 159 | in: path 160 | description: ID of pet to return 161 | required: true 162 | schema: 163 | type: integer 164 | format: int64 165 | responses: 166 | "200": 167 | description: successful operation 168 | content: 169 | application/xml: 170 | schema: 171 | $ref: "#/components/schemas/Pet" 172 | application/json: 173 | schema: 174 | $ref: "#/components/schemas/Pet" 175 | "400": 176 | description: Invalid ID supplied 177 | "404": 178 | description: Pet not found 179 | security: 180 | - api_key: [] 181 | post: 182 | tags: 183 | - pet 184 | summary: Updates a pet in the store with form data 185 | description: "" 186 | operationId: updatePetWithForm 187 | parameters: 188 | - name: petId 189 | in: path 190 | description: ID of pet that needs to be updated 191 | required: true 192 | schema: 193 | type: integer 194 | format: int64 195 | responses: 196 | "405": 197 | description: Invalid input 198 | security: 199 | - petstore_auth: 200 | - write:pets 201 | - read:pets 202 | requestBody: 203 | content: 204 | application/x-www-form-urlencoded: 205 | schema: 206 | type: object 207 | properties: 208 | name: 209 | description: Updated name of the pet 210 | type: string 211 | status: 212 | description: Updated status of the pet 213 | type: string 214 | delete: 215 | tags: 216 | - pet 217 | summary: Deletes a pet 218 | description: "" 219 | operationId: deletePet 220 | parameters: 221 | - name: api_key 222 | in: header 223 | required: false 224 | schema: 225 | type: string 226 | - name: petId 227 | in: path 228 | description: Pet id to delete 229 | required: true 230 | schema: 231 | type: integer 232 | format: int64 233 | responses: 234 | "400": 235 | description: Invalid ID supplied 236 | "404": 237 | description: Pet not found 238 | security: 239 | - petstore_auth: 240 | - write:pets 241 | - read:pets 242 | "/pet/{petId}/uploadImage": 243 | post: 244 | tags: 245 | - pet 246 | summary: uploads an image 247 | description: "" 248 | operationId: uploadFile 249 | parameters: 250 | - name: petId 251 | in: path 252 | description: ID of pet to update 253 | required: true 254 | schema: 255 | type: integer 256 | format: int64 257 | responses: 258 | "200": 259 | description: successful operation 260 | content: 261 | application/json: 262 | schema: 263 | $ref: "#/components/schemas/ApiResponse" 264 | security: 265 | - petstore_auth: 266 | - write:pets 267 | - read:pets 268 | requestBody: 269 | content: 270 | application/octet-stream: 271 | schema: 272 | type: string 273 | format: binary 274 | /store/inventory: 275 | get: 276 | tags: 277 | - store 278 | summary: Returns pet inventories by status 279 | description: Returns a map of status codes to quantities 280 | operationId: getInventory 281 | responses: 282 | "200": 283 | description: successful operation 284 | content: 285 | application/json: 286 | schema: 287 | type: object 288 | additionalProperties: 289 | type: integer 290 | format: int32 291 | security: 292 | - api_key: [] 293 | /store/order: 294 | post: 295 | tags: 296 | - store 297 | summary: Place an order for a pet 298 | description: "" 299 | operationId: placeOrder 300 | responses: 301 | "200": 302 | description: successful operation 303 | content: 304 | application/xml: 305 | schema: 306 | $ref: "#/components/schemas/Order" 307 | application/json: 308 | schema: 309 | $ref: "#/components/schemas/Order" 310 | "400": 311 | description: Invalid Order 312 | requestBody: 313 | content: 314 | application/json: 315 | schema: 316 | $ref: "#/components/schemas/Order" 317 | description: order placed for purchasing the pet 318 | required: true 319 | "/store/order/{orderId}": 320 | get: 321 | tags: 322 | - store 323 | summary: Find purchase order by ID 324 | description: For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions 325 | operationId: getOrderById 326 | parameters: 327 | - name: orderId 328 | in: path 329 | description: ID of pet that needs to be fetched 330 | required: true 331 | schema: 332 | type: integer 333 | format: int64 334 | minimum: 1 335 | maximum: 10 336 | responses: 337 | "200": 338 | description: successful operation 339 | content: 340 | application/xml: 341 | schema: 342 | $ref: "#/components/schemas/Order" 343 | application/json: 344 | schema: 345 | $ref: "#/components/schemas/Order" 346 | "400": 347 | description: Invalid ID supplied 348 | "404": 349 | description: Order not found 350 | delete: 351 | tags: 352 | - store 353 | summary: Delete purchase order by ID 354 | description: For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors 355 | operationId: deleteOrder 356 | parameters: 357 | - name: orderId 358 | in: path 359 | description: ID of the order that needs to be deleted 360 | required: true 361 | schema: 362 | type: integer 363 | format: int64 364 | minimum: 1 365 | responses: 366 | "400": 367 | description: Invalid ID supplied 368 | "404": 369 | description: Order not found 370 | /user: 371 | post: 372 | tags: 373 | - user 374 | summary: Create user 375 | description: This can only be done by the logged in user. 376 | operationId: createUser 377 | responses: 378 | default: 379 | description: successful operation 380 | requestBody: 381 | content: 382 | application/json: 383 | schema: 384 | $ref: "#/components/schemas/User" 385 | description: Created user object 386 | required: true 387 | /user/createWithArray: 388 | post: 389 | tags: 390 | - user 391 | summary: Creates list of users with given input array 392 | description: "" 393 | operationId: createUsersWithArrayInput 394 | responses: 395 | default: 396 | description: successful operation 397 | requestBody: 398 | $ref: "#/components/requestBodies/UserArray" 399 | /user/createWithList: 400 | post: 401 | tags: 402 | - user 403 | summary: Creates list of users with given input array 404 | description: "" 405 | operationId: createUsersWithListInput 406 | responses: 407 | default: 408 | description: successful operation 409 | requestBody: 410 | $ref: "#/components/requestBodies/UserArray" 411 | /user/login: 412 | get: 413 | tags: 414 | - user 415 | summary: Logs user into the system 416 | description: "" 417 | operationId: loginUser 418 | parameters: 419 | - name: username 420 | in: query 421 | description: The user name for login 422 | required: true 423 | schema: 424 | type: string 425 | - name: password 426 | in: query 427 | description: The password for login in clear text 428 | required: true 429 | schema: 430 | type: string 431 | format: password 432 | responses: 433 | "200": 434 | description: successful operation 435 | headers: 436 | X-Rate-Limit: 437 | description: calls per hour allowed by the user 438 | schema: 439 | type: integer 440 | format: int32 441 | X-Expires-After: 442 | description: date in UTC when token expires 443 | schema: 444 | type: string 445 | format: date-time 446 | content: 447 | application/xml: 448 | schema: 449 | type: string 450 | application/json: 451 | schema: 452 | type: string 453 | "400": 454 | description: Invalid username/password supplied 455 | /user/logout: 456 | get: 457 | tags: 458 | - user 459 | summary: Logs out current logged in user session 460 | description: "" 461 | operationId: logoutUser 462 | responses: 463 | default: 464 | description: successful operation 465 | "/user/{username}": 466 | get: 467 | tags: 468 | - user 469 | summary: Get user by user name 470 | description: "" 471 | operationId: getUserByName 472 | parameters: 473 | - name: username 474 | in: path 475 | description: "The name that needs to be fetched. Use user1 for testing. " 476 | required: true 477 | schema: 478 | type: string 479 | responses: 480 | "200": 481 | description: successful operation 482 | content: 483 | application/xml: 484 | schema: 485 | $ref: "#/components/schemas/User" 486 | application/json: 487 | schema: 488 | $ref: "#/components/schemas/User" 489 | "400": 490 | description: Invalid username supplied 491 | "404": 492 | description: User not found 493 | put: 494 | tags: 495 | - user 496 | summary: Updated user 497 | description: This can only be done by the logged in user. 498 | operationId: updateUser 499 | parameters: 500 | - name: username 501 | in: path 502 | description: name that need to be updated 503 | required: true 504 | schema: 505 | type: string 506 | responses: 507 | "400": 508 | description: Invalid user supplied 509 | "404": 510 | description: User not found 511 | requestBody: 512 | content: 513 | application/json: 514 | schema: 515 | $ref: "#/components/schemas/User" 516 | description: Updated user object 517 | required: true 518 | delete: 519 | tags: 520 | - user 521 | summary: Delete user 522 | description: This can only be done by the logged in user. 523 | operationId: deleteUser 524 | parameters: 525 | - name: username 526 | in: path 527 | description: The name that needs to be deleted 528 | required: true 529 | schema: 530 | type: string 531 | responses: 532 | "400": 533 | description: Invalid username supplied 534 | "404": 535 | description: User not found 536 | externalDocs: 537 | description: Find out more about Swagger 538 | url: http://swagger.io 539 | components: 540 | schemas: 541 | Order: 542 | type: object 543 | properties: 544 | id: 545 | type: integer 546 | format: int64 547 | petId: 548 | type: integer 549 | format: int64 550 | quantity: 551 | type: integer 552 | format: int32 553 | shipDate: 554 | type: string 555 | format: date-time 556 | status: 557 | type: string 558 | description: Order Status 559 | enum: 560 | - placed 561 | - approved 562 | - delivered 563 | complete: 564 | type: boolean 565 | default: false 566 | xml: 567 | name: Order 568 | Category: 569 | type: object 570 | properties: 571 | id: 572 | type: integer 573 | format: int64 574 | name: 575 | type: string 576 | xml: 577 | name: Category 578 | User: 579 | type: object 580 | properties: 581 | id: 582 | type: integer 583 | format: int64 584 | username: 585 | type: string 586 | firstName: 587 | type: string 588 | lastName: 589 | type: string 590 | email: 591 | type: string 592 | password: 593 | type: string 594 | phone: 595 | type: string 596 | userStatus: 597 | type: integer 598 | format: int32 599 | description: User Status 600 | xml: 601 | name: User 602 | Tag: 603 | type: object 604 | properties: 605 | id: 606 | type: integer 607 | format: int64 608 | name: 609 | type: string 610 | xml: 611 | name: Tag 612 | Pet: 613 | type: object 614 | required: 615 | - name 616 | - photoUrls 617 | properties: 618 | id: 619 | type: integer 620 | format: int64 621 | category: 622 | $ref: "#/components/schemas/Category" 623 | name: 624 | type: string 625 | example: doggie 626 | photoUrls: 627 | type: array 628 | xml: 629 | name: photoUrl 630 | wrapped: true 631 | items: 632 | type: string 633 | tags: 634 | type: array 635 | xml: 636 | name: tag 637 | wrapped: true 638 | items: 639 | $ref: "#/components/schemas/Tag" 640 | status: 641 | type: string 642 | description: pet status in the store 643 | enum: 644 | - available 645 | - pending 646 | - sold 647 | xml: 648 | name: Pet 649 | ApiResponse: 650 | type: object 651 | properties: 652 | code: 653 | type: integer 654 | format: int32 655 | type: 656 | type: string 657 | message: 658 | type: string 659 | requestBodies: 660 | Pet: 661 | content: 662 | application/json: 663 | schema: 664 | $ref: "#/components/schemas/Pet" 665 | application/xml: 666 | schema: 667 | $ref: "#/components/schemas/Pet" 668 | description: Pet object that needs to be added to the store 669 | required: true 670 | UserArray: 671 | content: 672 | application/json: 673 | schema: 674 | type: array 675 | items: 676 | $ref: "#/components/schemas/User" 677 | description: List of user object 678 | required: true 679 | securitySchemes: 680 | petstore_auth: 681 | type: oauth2 682 | flows: 683 | implicit: 684 | authorizationUrl: http://petstore.swagger.io/oauth/dialog 685 | scopes: 686 | write:pets: modify pets in your account 687 | read:pets: read your pets 688 | api_key: 689 | type: apiKey 690 | name: api_key 691 | in: header 692 | -------------------------------------------------------------------------------- /test/checkTags2/options.yaml: -------------------------------------------------------------------------------- 1 | flags: [ 'user' ] 2 | checkTags: true 3 | inverse: true 4 | valid: true 5 | -------------------------------------------------------------------------------- /test/checkTags2/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Swagger Petstore 4 | version: 1.0.0 5 | paths: 6 | /user: 7 | post: 8 | tags: 9 | - user 10 | summary: Create user 11 | description: This can only be done by the logged in user. 12 | operationId: createUser 13 | responses: 14 | default: 15 | description: successful operation 16 | requestBody: 17 | content: 18 | application/json: 19 | schema: 20 | $ref: "#/components/schemas/User" 21 | description: Created user object 22 | required: true 23 | /user/createWithArray: 24 | post: 25 | tags: 26 | - user 27 | summary: Creates list of users with given input array 28 | description: "" 29 | operationId: createUsersWithArrayInput 30 | responses: 31 | default: 32 | description: successful operation 33 | requestBody: 34 | $ref: "#/components/requestBodies/UserArray" 35 | /user/createWithList: 36 | post: 37 | tags: 38 | - user 39 | summary: Creates list of users with given input array 40 | description: "" 41 | operationId: createUsersWithListInput 42 | responses: 43 | default: 44 | description: successful operation 45 | requestBody: 46 | $ref: "#/components/requestBodies/UserArray" 47 | /user/login: 48 | get: 49 | tags: 50 | - user 51 | summary: Logs user into the system 52 | description: "" 53 | operationId: loginUser 54 | parameters: 55 | - name: username 56 | in: query 57 | description: The user name for login 58 | required: true 59 | schema: 60 | type: string 61 | - name: password 62 | in: query 63 | description: The password for login in clear text 64 | required: true 65 | schema: 66 | type: string 67 | format: password 68 | responses: 69 | "200": 70 | description: successful operation 71 | headers: 72 | X-Rate-Limit: 73 | description: calls per hour allowed by the user 74 | schema: 75 | type: integer 76 | format: int32 77 | X-Expires-After: 78 | description: date in UTC when token expires 79 | schema: 80 | type: string 81 | format: date-time 82 | content: 83 | application/xml: 84 | schema: 85 | type: string 86 | application/json: 87 | schema: 88 | type: string 89 | "400": 90 | description: Invalid username/password supplied 91 | /user/logout: 92 | get: 93 | tags: 94 | - user 95 | summary: Logs out current logged in user session 96 | description: "" 97 | operationId: logoutUser 98 | responses: 99 | default: 100 | description: successful operation 101 | "/user/{username}": 102 | get: 103 | tags: 104 | - user 105 | summary: Get user by user name 106 | description: "" 107 | operationId: getUserByName 108 | parameters: 109 | - name: username 110 | in: path 111 | description: "The name that needs to be fetched. Use user1 for testing. " 112 | required: true 113 | schema: 114 | type: string 115 | responses: 116 | "200": 117 | description: successful operation 118 | content: 119 | application/xml: 120 | schema: 121 | $ref: "#/components/schemas/User" 122 | application/json: 123 | schema: 124 | $ref: "#/components/schemas/User" 125 | "400": 126 | description: Invalid username supplied 127 | "404": 128 | description: User not found 129 | put: 130 | tags: 131 | - user 132 | summary: Updated user 133 | description: This can only be done by the logged in user. 134 | operationId: updateUser 135 | parameters: 136 | - name: username 137 | in: path 138 | description: name that need to be updated 139 | required: true 140 | schema: 141 | type: string 142 | responses: 143 | "400": 144 | description: Invalid user supplied 145 | "404": 146 | description: User not found 147 | requestBody: 148 | content: 149 | application/json: 150 | schema: 151 | $ref: "#/components/schemas/User" 152 | description: Updated user object 153 | required: true 154 | delete: 155 | tags: 156 | - user 157 | summary: Delete user 158 | description: This can only be done by the logged in user. 159 | operationId: deleteUser 160 | parameters: 161 | - name: username 162 | in: path 163 | description: The name that needs to be deleted 164 | required: true 165 | schema: 166 | type: string 167 | responses: 168 | "400": 169 | description: Invalid username supplied 170 | "404": 171 | description: User not found 172 | components: 173 | schemas: 174 | User: 175 | type: object 176 | properties: 177 | id: 178 | type: integer 179 | format: int64 180 | username: 181 | type: string 182 | firstName: 183 | type: string 184 | lastName: 185 | type: string 186 | email: 187 | type: string 188 | password: 189 | type: string 190 | phone: 191 | type: string 192 | userStatus: 193 | type: integer 194 | format: int32 195 | description: User Status 196 | xml: 197 | name: User 198 | requestBodies: 199 | UserArray: 200 | content: 201 | application/json: 202 | schema: 203 | type: array 204 | items: 205 | $ref: "#/components/schemas/User" 206 | description: List of user object 207 | required: true 208 | -------------------------------------------------------------------------------- /test/circular/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-internal: true 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | get: 30 | description: | 31 | Fetch current comic and metadata. 32 | parameters: 33 | - $ref: '#/definitions/comic' 34 | - $ref: '#/definitions/hovertext' 35 | responses: 36 | '200': 37 | description: OK 38 | schema: 39 | $ref: '#/definitions/comic' 40 | '/{comicId}/info.0.json': 41 | x-internal: true 42 | get: 43 | description: | 44 | Fetch comics and metadata by comic id. 45 | parameters: 46 | - in: path 47 | name: comicId 48 | required: true 49 | type: number 50 | - $ref: '#/definitions/complex' 51 | - $ref: '#/definitions/hovertext' 52 | responses: 53 | '200': 54 | description: OK 55 | schema: 56 | $ref: '#/definitions/comic' 57 | definitions: 58 | comic: 59 | properties: 60 | alt: 61 | type: string 62 | day: 63 | type: string 64 | img: 65 | type: string 66 | link: 67 | type: string 68 | month: 69 | type: string 70 | news: 71 | type: string 72 | num: 73 | type: number 74 | safe_title: 75 | type: string 76 | title: 77 | type: string 78 | transcript: 79 | type: string 80 | year: 81 | type: string 82 | previous: 83 | $ref: '#/definitions/comic' 84 | type: object 85 | hovertext: 86 | x-internal: true 87 | properties: 88 | description: 89 | type: string 90 | complex: 91 | properties: 92 | a69: 93 | type: object 94 | oneOf: 95 | - $ref: '#/definitions/b1' 96 | - $ref: '#/definitions/b2' 97 | b1: 98 | properties: 99 | ab: 100 | type: string 101 | b2: 102 | properties: 103 | ac: 104 | type: object 105 | oneOf: 106 | - $ref: '#/definitions/c1' 107 | c1: 108 | properties: 109 | ab: 110 | type: string 111 | -------------------------------------------------------------------------------- /test/circular/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | valid: true 3 | -------------------------------------------------------------------------------- /test/circular/output.yaml: -------------------------------------------------------------------------------- 1 | swagger: "2.0" 2 | info: 3 | x-logo: 4 | url: http://imgs.xkcd.com/static/terrible_small_logo.png 5 | x-internal: true 6 | paths: 7 | "/{comicId}/info.0.json": 8 | x-internal: true 9 | get: 10 | description: > 11 | Fetch comics and metadata by comic id. 12 | parameters: 13 | - in: path 14 | name: comicId 15 | required: true 16 | type: number 17 | - $ref: '#/definitions/complex' 18 | - $ref: "#/definitions/hovertext" 19 | responses: 20 | "200": 21 | description: OK 22 | schema: 23 | $ref: "#/definitions/comic" 24 | definitions: 25 | hovertext: 26 | x-internal: true 27 | properties: 28 | description: 29 | type: string 30 | comic: 31 | properties: 32 | alt: 33 | type: string 34 | day: 35 | type: string 36 | img: 37 | type: string 38 | link: 39 | type: string 40 | month: 41 | type: string 42 | news: 43 | type: string 44 | num: 45 | type: number 46 | safe_title: 47 | type: string 48 | title: 49 | type: string 50 | transcript: 51 | type: string 52 | year: 53 | type: string 54 | previous: 55 | $ref: '#/definitions/comic' 56 | type: object 57 | complex: 58 | properties: 59 | a69: 60 | type: object 61 | oneOf: 62 | - $ref: '#/definitions/b1' 63 | - $ref: '#/definitions/b2' 64 | b1: 65 | properties: 66 | ab: 67 | type: string 68 | b2: 69 | properties: 70 | ac: 71 | type: object 72 | oneOf: 73 | - $ref: '#/definitions/c1' 74 | c1: 75 | properties: 76 | ab: 77 | type: string 78 | -------------------------------------------------------------------------------- /test/codep/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-internal: true 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | get: 30 | description: | 31 | Fetch current comic and metadata. 32 | parameters: 33 | - $ref: '#/definitions/comic' 34 | - $ref: '#/definitions/hovertext' 35 | responses: 36 | '200': 37 | description: OK 38 | schema: 39 | $ref: '#/definitions/comic' 40 | '/{comicId}/info.0.json': 41 | x-internal: true 42 | get: 43 | description: | 44 | Fetch comics and metadata by comic id. 45 | parameters: 46 | - in: path 47 | name: comicId 48 | required: true 49 | type: number 50 | - $ref: '#/definitions/complex' 51 | - $ref: '#/definitions/hovertext' 52 | responses: 53 | '200': 54 | description: OK 55 | schema: 56 | $ref: '#/definitions/comic' 57 | definitions: 58 | comic: 59 | properties: 60 | alt: 61 | type: string 62 | day: 63 | type: string 64 | img: 65 | type: string 66 | link: 67 | type: string 68 | month: 69 | type: string 70 | news: 71 | type: string 72 | num: 73 | type: number 74 | safe_title: 75 | type: string 76 | title: 77 | type: string 78 | transcript: 79 | type: string 80 | year: 81 | type: string 82 | previous: 83 | $ref: '#/definitions/other' 84 | type: object 85 | other: 86 | type: object 87 | properties: 88 | comic: 89 | $ref: '#/definitions/comic' 90 | hovertext: 91 | x-internal: true 92 | properties: 93 | description: 94 | type: string 95 | complex: 96 | properties: 97 | a69: 98 | type: object 99 | oneOf: 100 | - $ref: '#/definitions/b1' 101 | - $ref: '#/definitions/b2' 102 | b1: 103 | properties: 104 | ab: 105 | type: string 106 | b2: 107 | properties: 108 | ac: 109 | type: object 110 | oneOf: 111 | - $ref: '#/definitions/c1' 112 | c1: 113 | properties: 114 | ab: 115 | type: string 116 | -------------------------------------------------------------------------------- /test/codep/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | valid: true 3 | -------------------------------------------------------------------------------- /test/codep/output.yaml: -------------------------------------------------------------------------------- 1 | swagger: "2.0" 2 | info: 3 | x-logo: 4 | url: http://imgs.xkcd.com/static/terrible_small_logo.png 5 | x-internal: true 6 | paths: 7 | "/{comicId}/info.0.json": 8 | x-internal: true 9 | get: 10 | description: > 11 | Fetch comics and metadata by comic id. 12 | parameters: 13 | - in: path 14 | name: comicId 15 | required: true 16 | type: number 17 | - $ref: '#/definitions/complex' 18 | - $ref: "#/definitions/hovertext" 19 | responses: 20 | "200": 21 | description: OK 22 | schema: 23 | $ref: "#/definitions/comic" 24 | definitions: 25 | hovertext: 26 | x-internal: true 27 | properties: 28 | description: 29 | type: string 30 | comic: 31 | properties: 32 | alt: 33 | type: string 34 | day: 35 | type: string 36 | img: 37 | type: string 38 | link: 39 | type: string 40 | month: 41 | type: string 42 | news: 43 | type: string 44 | num: 45 | type: number 46 | safe_title: 47 | type: string 48 | title: 49 | type: string 50 | transcript: 51 | type: string 52 | year: 53 | type: string 54 | previous: 55 | $ref: '#/definitions/other' 56 | type: object 57 | other: 58 | type: object 59 | properties: 60 | comic: 61 | $ref: '#/definitions/comic' 62 | complex: 63 | properties: 64 | a69: 65 | type: object 66 | oneOf: 67 | - $ref: '#/definitions/b1' 68 | - $ref: '#/definitions/b2' 69 | b1: 70 | properties: 71 | ab: 72 | type: string 73 | b2: 74 | properties: 75 | ac: 76 | type: object 77 | oneOf: 78 | - $ref: '#/definitions/c1' 79 | c1: 80 | properties: 81 | ab: 82 | type: string 83 | -------------------------------------------------------------------------------- /test/configFile/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-visibility: private 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | x-visibility: public 30 | get: 31 | description: | 32 | Fetch current comic and metadata. 33 | parameters: 34 | - $ref: '#/definitions/comic' 35 | - $ref: '#/definitions/hovertext' 36 | responses: 37 | '200': 38 | description: OK 39 | schema: 40 | $ref: '#/definitions/comic' 41 | '/{comicId}/info.0.json': 42 | x-visibility: internal 43 | get: 44 | description: | 45 | Fetch comics and metadata by comic id. 46 | parameters: 47 | - in: path 48 | name: comicId 49 | required: true 50 | type: number 51 | - $ref: '#/definitions/hovertext' 52 | responses: 53 | '200': 54 | description: OK 55 | schema: 56 | $ref: '#/definitions/comic' 57 | definitions: 58 | comic: 59 | properties: 60 | alt: 61 | type: string 62 | day: 63 | type: string 64 | img: 65 | type: string 66 | link: 67 | type: string 68 | month: 69 | type: string 70 | news: 71 | type: string 72 | num: 73 | type: number 74 | safe_title: 75 | type: string 76 | title: 77 | type: string 78 | transcript: 79 | type: string 80 | year: 81 | type: string 82 | type: object 83 | hovertext: 84 | x-visibility: private 85 | properties: 86 | description: 87 | type: string 88 | -------------------------------------------------------------------------------- /test/configFile/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1.0, 3 | "flags": [ 4 | "x-visibility" 5 | ], 6 | "flagValues": [ 7 | "private", 8 | "internal" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /test/configFile/output.yaml: -------------------------------------------------------------------------------- 1 | swagger: "2.0" 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: Webcomic of romance, sarcasm, math, and language. 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-origin: 13 | - format: swagger 14 | url: https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml 15 | version: "2.0" 16 | x-providerName: xkcd.com 17 | x-tags: 18 | - humor 19 | - comics 20 | x-unofficialSpec: true 21 | externalDocs: 22 | url: https://xkcd.com/json.html 23 | securityDefinitions: {} 24 | paths: 25 | /info.0.json: 26 | x-visibility: public 27 | get: 28 | description: > 29 | Fetch current comic and metadata. 30 | parameters: 31 | - $ref: "#/definitions/comic" 32 | responses: 33 | "200": 34 | description: OK 35 | schema: 36 | $ref: "#/definitions/comic" 37 | definitions: 38 | comic: 39 | properties: 40 | alt: 41 | type: string 42 | day: 43 | type: string 44 | img: 45 | type: string 46 | link: 47 | type: string 48 | month: 49 | type: string 50 | news: 51 | type: string 52 | num: 53 | type: number 54 | safe_title: 55 | type: string 56 | title: 57 | type: string 58 | transcript: 59 | type: string 60 | year: 61 | type: string 62 | type: object 63 | -------------------------------------------------------------------------------- /test/flagValues/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-visibility: private 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | x-visibility: public 30 | get: 31 | description: | 32 | Fetch current comic and metadata. 33 | parameters: 34 | - $ref: '#/definitions/comic' 35 | - $ref: '#/definitions/hovertext' 36 | responses: 37 | '200': 38 | description: OK 39 | schema: 40 | $ref: '#/definitions/comic' 41 | '/{comicId}/info.0.json': 42 | x-visibility: internal 43 | get: 44 | description: | 45 | Fetch comics and metadata by comic id. 46 | parameters: 47 | - in: path 48 | name: comicId 49 | required: true 50 | type: number 51 | - $ref: '#/definitions/hovertext' 52 | responses: 53 | '200': 54 | description: OK 55 | schema: 56 | $ref: '#/definitions/comic' 57 | definitions: 58 | comic: 59 | properties: 60 | alt: 61 | type: string 62 | day: 63 | type: string 64 | img: 65 | type: string 66 | link: 67 | type: string 68 | month: 69 | type: string 70 | news: 71 | type: string 72 | num: 73 | type: number 74 | safe_title: 75 | type: string 76 | title: 77 | type: string 78 | transcript: 79 | type: string 80 | year: 81 | type: string 82 | type: object 83 | hovertext: 84 | x-visibility: private 85 | properties: 86 | description: 87 | type: string 88 | -------------------------------------------------------------------------------- /test/flagValues/options.yaml: -------------------------------------------------------------------------------- 1 | flags: 2 | - x-visibility 3 | flagValues: 4 | - private 5 | - internal 6 | -------------------------------------------------------------------------------- /test/flagValues/output.yaml: -------------------------------------------------------------------------------- 1 | swagger: "2.0" 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: Webcomic of romance, sarcasm, math, and language. 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-origin: 13 | - format: swagger 14 | url: https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml 15 | version: "2.0" 16 | x-providerName: xkcd.com 17 | x-tags: 18 | - humor 19 | - comics 20 | x-unofficialSpec: true 21 | externalDocs: 22 | url: https://xkcd.com/json.html 23 | securityDefinitions: {} 24 | paths: 25 | /info.0.json: 26 | x-visibility: public 27 | get: 28 | description: | 29 | Fetch current comic and metadata. 30 | parameters: 31 | - $ref: "#/definitions/comic" 32 | responses: 33 | "200": 34 | description: OK 35 | schema: 36 | $ref: "#/definitions/comic" 37 | definitions: 38 | comic: 39 | properties: 40 | alt: 41 | type: string 42 | day: 43 | type: string 44 | img: 45 | type: string 46 | link: 47 | type: string 48 | month: 49 | type: string 50 | news: 51 | type: string 52 | num: 53 | type: number 54 | safe_title: 55 | type: string 56 | title: 57 | type: string 58 | transcript: 59 | type: string 60 | year: 61 | type: string 62 | type: object 63 | -------------------------------------------------------------------------------- /test/inverse/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-internal: true 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | get: 30 | description: | 31 | Fetch current comic and metadata. 32 | parameters: 33 | - $ref: '#/definitions/comic' 34 | - $ref: '#/definitions/hovertext' 35 | responses: 36 | '200': 37 | description: OK 38 | schema: 39 | $ref: '#/definitions/comic' 40 | '/{comicId}/info.0.json': 41 | x-internal: true 42 | get: 43 | description: | 44 | Fetch comics and metadata by comic id. 45 | parameters: 46 | - in: path 47 | name: comicId 48 | required: true 49 | type: number 50 | - $ref: '#/definitions/hovertext' 51 | responses: 52 | '200': 53 | description: OK 54 | schema: 55 | $ref: '#/definitions/comic' 56 | definitions: 57 | comic: 58 | properties: 59 | alt: 60 | type: string 61 | day: 62 | type: string 63 | img: 64 | type: string 65 | link: 66 | type: string 67 | month: 68 | type: string 69 | news: 70 | type: string 71 | num: 72 | type: number 73 | safe_title: 74 | type: string 75 | title: 76 | type: string 77 | transcript: 78 | type: string 79 | year: 80 | type: string 81 | type: object 82 | hovertext: 83 | x-internal: true 84 | properties: 85 | description: 86 | type: string 87 | -------------------------------------------------------------------------------- /test/inverse/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | -------------------------------------------------------------------------------- /test/inverse/output.yaml: -------------------------------------------------------------------------------- 1 | info: 2 | x-logo: 3 | url: http://imgs.xkcd.com/static/terrible_small_logo.png 4 | x-internal: true 5 | paths: 6 | "/{comicId}/info.0.json": 7 | x-internal: true 8 | get: 9 | description: | 10 | Fetch comics and metadata by comic id. 11 | parameters: 12 | - in: path 13 | name: comicId 14 | required: true 15 | type: number 16 | - $ref: "#/definitions/hovertext" 17 | responses: 18 | "200": 19 | description: OK 20 | schema: 21 | $ref: "#/definitions/comic" 22 | definitions: 23 | hovertext: 24 | x-internal: true 25 | properties: 26 | description: 27 | type: string 28 | -------------------------------------------------------------------------------- /test/issue105a/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.1.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | components: 6 | responses: 7 | ok: 8 | description: OK 9 | content: 10 | 'application/json': 11 | schema: 12 | type: object 13 | properties: 14 | public: 15 | type: string 16 | private: 17 | type: string 18 | x-internal: true 19 | required: 20 | - public 21 | -------------------------------------------------------------------------------- /test/issue105a/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.1.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | components: 6 | responses: 7 | ok: 8 | description: OK 9 | content: 10 | 'application/json': 11 | schema: 12 | type: object 13 | properties: 14 | public: 15 | type: string 16 | required: 17 | - public 18 | -------------------------------------------------------------------------------- /test/issue26a/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | tags: 6 | - name: Tag 1 7 | - "x-public": true 8 | name: Tag 2 9 | paths: {} 10 | -------------------------------------------------------------------------------- /test/issue26a/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | valid: true 3 | flags: [ "x-public" ] 4 | -------------------------------------------------------------------------------- /test/issue26a/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | tags: 6 | - "x-public": true 7 | name: Tag 2 8 | paths: {} 9 | -------------------------------------------------------------------------------- /test/issue26b/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | tags: 6 | - name: Tag 1 7 | "x-public": true 8 | - name: Tag 2 9 | paths: {} 10 | -------------------------------------------------------------------------------- /test/issue26b/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | valid: true 3 | flags: [ "x-public" ] 4 | -------------------------------------------------------------------------------- /test/issue26b/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | tags: 6 | - "x-public": true 7 | name: Tag 1 8 | paths: {} 9 | -------------------------------------------------------------------------------- /test/issue28/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | tags: 6 | - name: Tag 1 7 | - "x-public": true 8 | name: Tag 2 9 | - "x-public": true 10 | name: Tag 3 11 | - "x-public": true 12 | name: Tag 4 13 | paths: {} 14 | -------------------------------------------------------------------------------- /test/issue28/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | flags: 3 | - 'x-public' 4 | -------------------------------------------------------------------------------- /test/issue28/output.yaml: -------------------------------------------------------------------------------- 1 | tags: 2 | - x-public: true 3 | name: Tag 2 4 | - x-public: true 5 | name: Tag 3 6 | - x-public: true 7 | name: Tag 4 8 | -------------------------------------------------------------------------------- /test/issue29_nestedReferences/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-internal: true 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | get: 30 | description: | 31 | Fetch current comic and metadata. 32 | parameters: 33 | - $ref: '#/definitions/comic' 34 | - $ref: '#/definitions/hovertext' 35 | responses: 36 | '200': 37 | description: OK 38 | schema: 39 | $ref: '#/definitions/comic' 40 | '/{comicId}/info.0.json': 41 | x-internal: true 42 | get: 43 | description: | 44 | Fetch comics and metadata by comic id. 45 | parameters: 46 | - in: path 47 | name: comicId 48 | required: true 49 | type: number 50 | - $ref: '#/definitions/complex' 51 | - $ref: '#/definitions/hovertext' 52 | responses: 53 | '200': 54 | description: OK 55 | schema: 56 | $ref: '#/definitions/comic' 57 | definitions: 58 | comic: 59 | properties: 60 | alt: 61 | type: string 62 | day: 63 | type: string 64 | img: 65 | type: string 66 | link: 67 | type: string 68 | month: 69 | type: string 70 | news: 71 | type: string 72 | num: 73 | type: number 74 | safe_title: 75 | type: string 76 | title: 77 | type: string 78 | transcript: 79 | type: string 80 | year: 81 | type: string 82 | type: object 83 | hovertext: 84 | x-internal: true 85 | properties: 86 | description: 87 | type: string 88 | complex: 89 | properties: 90 | a69: 91 | type: object 92 | oneOf: 93 | - $ref: '#/definitions/b1' 94 | - $ref: '#/definitions/b2' 95 | b1: 96 | properties: 97 | ab: 98 | type: string 99 | b2: 100 | properties: 101 | ac: 102 | type: object 103 | oneOf: 104 | - $ref: '#/definitions/c1' 105 | c1: 106 | properties: 107 | ab: 108 | type: string -------------------------------------------------------------------------------- /test/issue29_nestedReferences/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | valid: true -------------------------------------------------------------------------------- /test/issue29_nestedReferences/output.yaml: -------------------------------------------------------------------------------- 1 | swagger: "2.0" 2 | info: 3 | x-logo: 4 | url: http://imgs.xkcd.com/static/terrible_small_logo.png 5 | x-internal: true 6 | paths: 7 | "/{comicId}/info.0.json": 8 | x-internal: true 9 | get: 10 | description: > 11 | Fetch comics and metadata by comic id. 12 | parameters: 13 | - in: path 14 | name: comicId 15 | required: true 16 | type: number 17 | - $ref: '#/definitions/complex' 18 | - $ref: "#/definitions/hovertext" 19 | responses: 20 | "200": 21 | description: OK 22 | schema: 23 | $ref: "#/definitions/comic" 24 | definitions: 25 | hovertext: 26 | x-internal: true 27 | properties: 28 | description: 29 | type: string 30 | comic: 31 | properties: 32 | alt: 33 | type: string 34 | day: 35 | type: string 36 | img: 37 | type: string 38 | link: 39 | type: string 40 | month: 41 | type: string 42 | news: 43 | type: string 44 | num: 45 | type: number 46 | safe_title: 47 | type: string 48 | title: 49 | type: string 50 | transcript: 51 | type: string 52 | year: 53 | type: string 54 | type: object 55 | complex: 56 | properties: 57 | a69: 58 | type: object 59 | oneOf: 60 | - $ref: '#/definitions/b1' 61 | - $ref: '#/definitions/b2' 62 | b1: 63 | properties: 64 | ab: 65 | type: string 66 | b2: 67 | properties: 68 | ac: 69 | type: object 70 | oneOf: 71 | - $ref: '#/definitions/c1' 72 | c1: 73 | properties: 74 | ab: 75 | type: string -------------------------------------------------------------------------------- /test/issue85/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | paths: 6 | /test: 7 | post: 8 | parameters: 9 | - $ref: '#/components/parameters/InternalHeader' 10 | - $ref: '#/components/parameters/SecondInternalHeader' 11 | - $ref: '#/components/parameters/ExternalHeader' 12 | - $ref: '#/components/parameters/ThirdInternalHeader' 13 | 14 | components: 15 | parameters: 16 | InternalHeader: 17 | x-internal: true 18 | in: header 19 | name: X-Internal-Header 20 | schema: 21 | type: string 22 | SecondInternalHeader: 23 | x-internal: true 24 | in: header 25 | name: X-Second-Internal-Header 26 | schema: 27 | type: string 28 | ThirdInternalHeader: 29 | x-internal: true 30 | in: header 31 | name: X-Third-Internal-Header 32 | schema: 33 | type: string 34 | ExternalHeader: 35 | in: header 36 | name: X-External-Header 37 | schema: 38 | type: string 39 | -------------------------------------------------------------------------------- /test/issue85/options.yaml: -------------------------------------------------------------------------------- 1 | maxAliasCount: 200 2 | -------------------------------------------------------------------------------- /test/issue85/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: API 4 | version: 1.0.0 5 | paths: 6 | /test: 7 | post: 8 | parameters: 9 | - $ref: '#/components/parameters/ExternalHeader' 10 | 11 | components: 12 | parameters: 13 | ExternalHeader: 14 | in: header 15 | name: X-External-Header 16 | schema: 17 | type: string 18 | -------------------------------------------------------------------------------- /test/strip/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-internal: true 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | get: 30 | description: | 31 | Fetch current comic and metadata. 32 | parameters: 33 | - $ref: '#/definitions/comic' 34 | - $ref: '#/definitions/hovertext' 35 | responses: 36 | '200': 37 | description: OK 38 | schema: 39 | $ref: '#/definitions/comic' 40 | '/{comicId}/info.0.json': 41 | x-internal: true 42 | get: 43 | description: | 44 | Fetch comics and metadata by comic id. 45 | parameters: 46 | - in: path 47 | name: comicId 48 | required: true 49 | type: number 50 | - $ref: '#/definitions/hovertext' 51 | responses: 52 | '200': 53 | description: OK 54 | schema: 55 | $ref: '#/definitions/comic' 56 | definitions: 57 | comic: 58 | properties: 59 | alt: 60 | type: string 61 | day: 62 | type: string 63 | img: 64 | type: string 65 | link: 66 | type: string 67 | month: 68 | type: string 69 | news: 70 | type: string 71 | num: 72 | type: number 73 | safe_title: 74 | type: string 75 | title: 76 | type: string 77 | transcript: 78 | type: string 79 | year: 80 | type: string 81 | type: object 82 | hovertext: 83 | x-internal: true 84 | properties: 85 | description: 86 | type: string 87 | -------------------------------------------------------------------------------- /test/strip/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | strip: true 3 | -------------------------------------------------------------------------------- /test/strip/output.yaml: -------------------------------------------------------------------------------- 1 | info: 2 | x-logo: 3 | url: http://imgs.xkcd.com/static/terrible_small_logo.png 4 | paths: 5 | "/{comicId}/info.0.json": 6 | get: 7 | description: | 8 | Fetch comics and metadata by comic id. 9 | parameters: 10 | - in: path 11 | name: comicId 12 | required: true 13 | type: number 14 | - $ref: "#/definitions/hovertext" 15 | responses: 16 | "200": 17 | description: OK 18 | schema: 19 | $ref: "#/definitions/comic" 20 | definitions: 21 | hovertext: 22 | properties: 23 | description: 24 | type: string 25 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const assert = require('assert'); 6 | const yaml = require('yaml'); 7 | 8 | const filter = require('../index.js'); 9 | 10 | const doPrivate = (!process.env.SKIP_PRIVATE); 11 | 12 | const tests = fs.readdirSync(__dirname).filter(file => { 13 | return fs.statSync(path.join(__dirname, file)).isDirectory() && (!file.startsWith('_') || doPrivate); 14 | }); 15 | 16 | describe('Filter tests', () => { 17 | tests.forEach((test) => { 18 | describe(test, () => { 19 | it('should match expected output', (done) => { 20 | let options = {}; 21 | let configFile = null 22 | try { 23 | // Load options.yaml 24 | configFile = path.join(__dirname, test, 'options.yaml'); 25 | options = yaml.parse(fs.readFileSync(configFile, 'utf8'), {schema: 'core'}); 26 | } catch (ex) { 27 | try { 28 | // Fallback to options.json 29 | configFile = path.join(__dirname, test, 'options.json'); 30 | options = JSON.parse(fs.readFileSync(configFile, 'utf8')); 31 | } catch (ex) { 32 | // No options found. options = {} will be used 33 | } 34 | } 35 | 36 | const input = yaml.parse(fs.readFileSync(path.join(__dirname, test, 'input.yaml'),'utf8'), {schema:'core', maxAliasCount: options.maxAliasCount }); 37 | let readOutput = false; 38 | let output = {}; 39 | try { 40 | output = yaml.parse(fs.readFileSync(path.join(__dirname, test, 'output.yaml'),'utf8'), {schema:'core', maxAliasCount: options.maxAliasCount }); 41 | readOutput = true; 42 | } 43 | catch (ex) {} 44 | 45 | const result = filter.filter(input, options); 46 | if (!readOutput) { 47 | output = result; 48 | fs.writeFileSync(path.join(__dirname, test, 'output.yaml'), yaml.stringify(result), 'utf8'); 49 | } 50 | 51 | assert.deepStrictEqual(result, output); 52 | return done(); 53 | }); 54 | }); 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /test/valid/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-internal: true 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | get: 30 | description: | 31 | Fetch current comic and metadata. 32 | parameters: 33 | - $ref: '#/definitions/comic' 34 | - $ref: '#/definitions/hovertext' 35 | responses: 36 | '200': 37 | description: OK 38 | schema: 39 | $ref: '#/definitions/comic' 40 | '/{comicId}/info.0.json': 41 | x-internal: true 42 | get: 43 | description: | 44 | Fetch comics and metadata by comic id. 45 | parameters: 46 | - in: path 47 | name: comicId 48 | required: true 49 | type: number 50 | - $ref: '#/definitions/hovertext' 51 | responses: 52 | '200': 53 | description: OK 54 | schema: 55 | $ref: '#/definitions/comic' 56 | definitions: 57 | comic: 58 | properties: 59 | alt: 60 | type: string 61 | day: 62 | type: string 63 | img: 64 | type: string 65 | link: 66 | type: string 67 | month: 68 | type: string 69 | news: 70 | type: string 71 | num: 72 | type: number 73 | safe_title: 74 | type: string 75 | title: 76 | type: string 77 | transcript: 78 | type: string 79 | year: 80 | type: string 81 | type: object 82 | hovertext: 83 | x-internal: true 84 | properties: 85 | description: 86 | type: string 87 | -------------------------------------------------------------------------------- /test/valid/options.yaml: -------------------------------------------------------------------------------- 1 | inverse: true 2 | valid: true 3 | -------------------------------------------------------------------------------- /test/valid/output.yaml: -------------------------------------------------------------------------------- 1 | swagger: "2.0" 2 | info: 3 | x-logo: 4 | url: http://imgs.xkcd.com/static/terrible_small_logo.png 5 | x-internal: true 6 | paths: 7 | "/{comicId}/info.0.json": 8 | x-internal: true 9 | get: 10 | description: > 11 | Fetch comics and metadata by comic id. 12 | parameters: 13 | - in: path 14 | name: comicId 15 | required: true 16 | type: number 17 | - $ref: "#/definitions/hovertext" 18 | responses: 19 | "200": 20 | description: OK 21 | schema: 22 | $ref: "#/definitions/comic" 23 | definitions: 24 | hovertext: 25 | x-internal: true 26 | properties: 27 | description: 28 | type: string 29 | comic: 30 | properties: 31 | alt: 32 | type: string 33 | day: 34 | type: string 35 | img: 36 | type: string 37 | link: 38 | type: string 39 | month: 40 | type: string 41 | news: 42 | type: string 43 | num: 44 | type: number 45 | safe_title: 46 | type: string 47 | title: 48 | type: string 49 | transcript: 50 | type: string 51 | year: 52 | type: string 53 | type: object 54 | -------------------------------------------------------------------------------- /test/xkcd/input.yaml: -------------------------------------------------------------------------------- 1 | swagger: '2.0' 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: 'Webcomic of romance, sarcasm, math, and language.' 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-logo: 13 | url: 'http://imgs.xkcd.com/static/terrible_small_logo.png' 14 | x-internal: true 15 | x-origin: 16 | - format: swagger 17 | url: 'https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml' 18 | version: '2.0' 19 | x-providerName: xkcd.com 20 | x-tags: 21 | - humor 22 | - comics 23 | x-unofficialSpec: true 24 | externalDocs: 25 | url: 'https://xkcd.com/json.html' 26 | securityDefinitions: {} 27 | paths: 28 | /info.0.json: 29 | get: 30 | description: | 31 | Fetch current comic and metadata. 32 | parameters: 33 | - $ref: '#/definitions/comic' 34 | - $ref: '#/definitions/hovertext' 35 | responses: 36 | '200': 37 | description: OK 38 | schema: 39 | $ref: '#/definitions/comic' 40 | '/{comicId}/info.0.json': 41 | x-internal: true 42 | get: 43 | description: | 44 | Fetch comics and metadata by comic id. 45 | parameters: 46 | - in: path 47 | name: comicId 48 | required: true 49 | type: number 50 | - $ref: '#/definitions/hovertext' 51 | responses: 52 | '200': 53 | description: OK 54 | schema: 55 | $ref: '#/definitions/comic' 56 | definitions: 57 | comic: 58 | properties: 59 | alt: 60 | type: string 61 | day: 62 | type: string 63 | img: 64 | type: string 65 | link: 66 | type: string 67 | month: 68 | type: string 69 | news: 70 | type: string 71 | num: 72 | type: number 73 | safe_title: 74 | type: string 75 | title: 76 | type: string 77 | transcript: 78 | type: string 79 | year: 80 | type: string 81 | type: object 82 | hovertext: 83 | x-internal: true 84 | properties: 85 | description: 86 | type: string 87 | -------------------------------------------------------------------------------- /test/xkcd/output.yaml: -------------------------------------------------------------------------------- 1 | swagger: "2.0" 2 | schemes: 3 | - http 4 | host: xkcd.com 5 | basePath: / 6 | info: 7 | description: Webcomic of romance, sarcasm, math, and language. 8 | title: XKCD 9 | version: 1.0.0 10 | x-apisguru-categories: 11 | - media 12 | x-origin: 13 | - format: swagger 14 | url: https://raw.githubusercontent.com/APIs-guru/unofficial_openapi_specs/master/xkcd.com/1.0.0/swagger.yaml 15 | version: "2.0" 16 | x-providerName: xkcd.com 17 | x-tags: 18 | - humor 19 | - comics 20 | x-unofficialSpec: true 21 | externalDocs: 22 | url: https://xkcd.com/json.html 23 | securityDefinitions: {} 24 | paths: 25 | /info.0.json: 26 | get: 27 | description: | 28 | Fetch current comic and metadata. 29 | parameters: 30 | - $ref: "#/definitions/comic" 31 | responses: 32 | "200": 33 | description: OK 34 | schema: 35 | $ref: "#/definitions/comic" 36 | definitions: 37 | comic: 38 | properties: 39 | alt: 40 | type: string 41 | day: 42 | type: string 43 | img: 44 | type: string 45 | link: 46 | type: string 47 | month: 48 | type: string 49 | news: 50 | type: string 51 | num: 52 | type: number 53 | safe_title: 54 | type: string 55 | title: 56 | type: string 57 | transcript: 58 | type: string 59 | year: 60 | type: string 61 | type: object 62 | --------------------------------------------------------------------------------