├── .editorconfig ├── .eslintrc ├── .github └── workflows │ ├── build.yml │ ├── npm-publish.yml │ └── npm-test.yml ├── .gitignore ├── .prettierrc ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── assets ├── openapi-format-icon.png ├── openapi-format-icon.svg ├── openapi-format-logo-centered.svg ├── openapi-format-logo.png ├── openapi-format-logo.psd ├── openapi-format-logo.svg ├── openapi-format-playground-diff.png ├── openapi-format-playground-filter.png └── openapi-format-playground.png ├── bin ├── __snapshots__ │ └── cli.test.js.snap ├── cli.js └── cli.test.js ├── defaultFilter.json ├── defaultSort.json ├── defaultSortComponents.json ├── jest.config.js ├── openapi-format.js ├── package-lock.json ├── package.json ├── readme.md ├── test ├── __utils__ │ ├── mockOpenApi.json │ ├── mockTrain.yaml │ ├── test-utils.js │ └── train.yaml ├── _cli-configfile │ ├── configFile.json │ ├── output.json │ └── snap.json ├── _split │ ├── snap.yaml │ ├── snap_station.yaml │ └── snap_station_id.yaml ├── casing.test.js ├── converting.test.js ├── filtering.test.js ├── json-convert-3.1 │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-custom-yaml │ ├── customSort.json │ ├── input.json │ ├── options.yaml │ └── output.yaml ├── json-custom │ ├── customSort.json │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-default-bug-big-numbers │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-default-yaml │ ├── input.json │ ├── options.yaml │ └── output.yaml ├── json-default │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-delete-method │ ├── customFilter.json │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-example-request │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-example-schemas │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-filter-empty-paths │ ├── customFilter.yaml │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-filter-inverse-operationids-126 │ ├── customFilter.yaml │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-filter-inverse-operationids │ ├── customFilter.yaml │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-filter-markdown-comments │ ├── customFilter.yaml │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-filter-unused │ ├── customFilter.yaml │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-no-sort │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-rename │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-sort-components │ ├── customSortComponents.json │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-sort-request-params │ ├── customSortComponents.yaml │ ├── input.json │ ├── options.yaml │ └── output.json ├── json-yaml-null │ ├── customFilter.yaml │ ├── input.json │ ├── options.yaml │ └── output.yaml ├── overlay-combi │ ├── input.yaml │ ├── options.yaml │ ├── output.yaml │ └── overlay.yaml ├── overlay-params │ ├── input.yaml │ ├── options.yaml │ ├── output.yaml │ └── overlay.yaml ├── overlay-preserve-required │ ├── input.yaml │ ├── options.yaml │ ├── output.yaml │ └── overlay.yaml ├── overlay.test.js ├── parseTpl.test.js ├── sorting.test.js ├── split.test.js ├── test.js ├── util-file.test.js ├── yaml-casing-component-keys │ ├── customCasing.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-casing-component-parameters-keys │ ├── customCasing.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-casing-operationId │ ├── customCasing.yaml │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-casing-parameters │ ├── customCasing.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-casing-properties │ ├── customCasing.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-casing-required │ ├── customCasing.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-casing │ ├── customCasing.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-convert-3.1 │ ├── input.yaml │ ├── options.yaml │ ├── output.yaml │ └── output_OpenApi31.yaml ├── yaml-custom-3.1 │ ├── customSort.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-custom-json │ ├── customSort.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.json ├── yaml-custom │ ├── customSort.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-default-bug-big-numbers │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-default-bug-examples-properties │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-default-bug-nested-properties │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-default-bug-numbers-x-tag │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-default-json │ ├── input.yaml │ ├── options.yaml │ └── output.json ├── yaml-default │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-default-3.1 │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-flags-flagsValues │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-flags │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-flagsvalue-array-taggroups │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-flagsvalue-array-tags │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-flagsvalue-array │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-flagsvalue-value-array │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-flagsvalue-value-taggroups │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-flagsvalue-value │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-methods │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-operationids │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-operations-method-wildcard │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-operations-path-wildcard │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-operations │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom-tags │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-custom │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-default │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-all-methods │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-flags-flagsValues-minimal │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-flags-flagsValues │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-flags-minimal │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-flags │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-flagsvalue-value-array │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-methods │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-operationids-free-form │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-operationids │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-request-content │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-response-content │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-inverse-tags │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-markdown-comments │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-refs │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-replace-text │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-request-content │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-response-content │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-security-empty │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-unused-components-path │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-unused-components-period │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-filter-unused-components │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-generate-operationId-overwrite-casing │ ├── customCasing.yaml │ ├── customGenerate.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-generate-operationId-overwrite │ ├── customGenerate.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-generate-operationId │ ├── customGenerate.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-linewidth │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-no-sort-keep-comments │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-no-sort │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-preserve-empty-no-filter │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-preserve-empty-objects-default │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-preserve-empty-objects-false │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-preserve-empty-objects-schema-only │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-preserve-empty-objects-true │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-preserve-example-props │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-ref-quotes │ ├── bundled.yaml │ ├── domain-types.openapi.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-remove-empty-filter │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-rename │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-sort-components │ ├── customSortComponents.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-sort-keep-comments │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-sort-paths-alphabet │ ├── customSort.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-sort-paths-tags │ ├── customSort.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-sort-skip-components │ ├── customSortComponents.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── yaml-stoplight-studio-style │ ├── input.yaml │ ├── options.yaml │ ├── output.yaml │ └── petstore.yaml ├── yaml-strip-flags │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml └── yaml-unused-extra │ ├── customFilter.yaml │ ├── input.yaml │ ├── options.yaml │ └── output.yaml ├── types └── openapi-format.d.ts └── utils ├── casing.js ├── convert.js ├── file.js ├── filtering.js ├── logging.js ├── overlay.js ├── parseTpl.js ├── sorting.js ├── split.js └── types.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # Default 2 | [*] 3 | charset = utf-8 4 | end_of_line = lf 5 | insert_final_newline = false 6 | trim_trailing_whitespace = true 7 | 8 | # JavaScript 9 | [*.js] 10 | indent_style = space 11 | indent_size = 2 12 | 13 | # JSON 14 | [*.json] 15 | indent_style = space 16 | indent_size = 2 17 | ij_json_wrap_long_lines = false 18 | 19 | # Markdown 20 | [*.md] 21 | insert_final_newline = false 22 | trim_trailing_whitespace = false 23 | indent_style = space 24 | indent_size = 4 25 | 26 | # XML 27 | [*.xml] 28 | indent_size = 2 -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": false, 4 | "node": true, 5 | "es6": true 6 | }, 7 | "ignorePatterns": [ 8 | "node_modules", 9 | "vendor", 10 | "libs" 11 | ], 12 | "rules": { 13 | "semi": "error", 14 | "space-before-function-paren": [ 15 | "error", 16 | "never" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Publish image 2 | on: 3 | release: 4 | types: [released] 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Login to GitHub Container Registry 11 | uses: docker/login-action@v2 12 | with: 13 | registry: ghcr.io 14 | username: ${{ github.actor }} 15 | password: ${{ secrets.GITHUB_TOKEN }} 16 | 17 | - name: Build and push ghcr.io 18 | id: build-and-push 19 | uses: docker/build-push-action@v3.1.0 20 | with: 21 | push: true 22 | tags: ghcr.io/${{ github.repository }}:latest 23 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-node@v1 16 | with: 17 | node-version: 20 18 | - run: npm ci 19 | - run: npm test 20 | 21 | # publish-npm: 22 | # needs: build 23 | # runs-on: ubuntu-latest 24 | # steps: 25 | # - uses: actions/checkout@v2 26 | # - uses: actions/setup-node@v1 27 | # with: 28 | # node-version: 12 29 | # registry-url: https://registry.npmjs.org/ 30 | # - run: npm ci 31 | # - run: npm publish 32 | # env: 33 | # NODE_AUTH_TOKEN: ${{secrets.npm_token}} 34 | 35 | # publish-gpr: 36 | # needs: build 37 | # runs-on: ubuntu-latest 38 | # steps: 39 | # - uses: actions/checkout@v2 40 | # - uses: actions/setup-node@v1 41 | # with: 42 | # node-version: 12 43 | # registry-url: https://npm.pkg.github.com/ 44 | # - run: npm ci 45 | # - run: npm publish 46 | # env: 47 | # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 48 | -------------------------------------------------------------------------------- /.github/workflows/npm-test.yml: -------------------------------------------------------------------------------- 1 | name: Node Tests CI 2 | on: 3 | push: 4 | branches: 5 | - '*' # Trigger on all branches 6 | pull_request: 7 | branches: 8 | - '*' # Trigger on all branches 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | matrix: 15 | node-version: [ '18', '20' ] 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v4 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | cache: npm 24 | 25 | - name: Install Dependencies 26 | run: npm ci 27 | 28 | - name: Run Unit Tests 29 | run: npm run test 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /coverage 3 | 4 | .idea 5 | .tmp 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "printWidth": 120, 4 | "tabWidth": 2, 5 | "semi": true, 6 | "bracketSpacing": false, 7 | "arrowParens": "avoid", 8 | "trailingComma": "none", 9 | "endOfLine": "lf" 10 | } 11 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine 2 | RUN npm install -g openapi-format 3 | 4 | LABEL org.opencontainers.image.source https://github.com/thim81/openapi-format 5 | 6 | ENTRYPOINT ["openapi-format"] 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 thim81 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /assets/openapi-format-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thim81/openapi-format/8fd943379021a3c1a6293fb027aee942bbbc890b/assets/openapi-format-icon.png -------------------------------------------------------------------------------- /assets/openapi-format-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thim81/openapi-format/8fd943379021a3c1a6293fb027aee942bbbc890b/assets/openapi-format-logo.png -------------------------------------------------------------------------------- /assets/openapi-format-logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thim81/openapi-format/8fd943379021a3c1a6293fb027aee942bbbc890b/assets/openapi-format-logo.psd -------------------------------------------------------------------------------- /assets/openapi-format-playground-diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thim81/openapi-format/8fd943379021a3c1a6293fb027aee942bbbc890b/assets/openapi-format-playground-diff.png -------------------------------------------------------------------------------- /assets/openapi-format-playground-filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thim81/openapi-format/8fd943379021a3c1a6293fb027aee942bbbc890b/assets/openapi-format-playground-filter.png -------------------------------------------------------------------------------- /assets/openapi-format-playground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thim81/openapi-format/8fd943379021a3c1a6293fb027aee942bbbc890b/assets/openapi-format-playground.png -------------------------------------------------------------------------------- /defaultFilter.json: -------------------------------------------------------------------------------- 1 | { 2 | "methods": [], 3 | "inverseMethods": [], 4 | "tags": [], 5 | "inverseTags": [], 6 | "operationIds": [], 7 | "inverseOperationIds": [], 8 | "operations": [], 9 | "flags": [], 10 | "inverseFlags": [], 11 | "flagValues": [], 12 | "inverseFlagValues": [], 13 | "unusedComponents": [], 14 | "stripFlags": [], 15 | "responseContent": [], 16 | "inverseResponseContent": [], 17 | "requestContent": [], 18 | "inverseRequestContent": [] 19 | } 20 | -------------------------------------------------------------------------------- /defaultSort.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": ["openapi", "info", "servers", "paths", "components", "tags", "x-tagGroups", "externalDocs"], 3 | "get": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 4 | "post": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 5 | "put": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 6 | "patch": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 7 | "delete": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 8 | "parameters": ["name", "in", "description", "required", "schema"], 9 | "requestBody": ["description", "required", "content"], 10 | "responses": ["description", "headers", "content", "links"], 11 | "content": [], 12 | "components": ["parameters", "schemas"], 13 | "schema": ["description", "type", "items", "properties", "format", "example", "default"], 14 | "schemas": ["description", "type", "items", "properties", "format", "example", "default"], 15 | "properties": ["description", "type", "items", "format", "example", "default", "enum"] 16 | } 17 | -------------------------------------------------------------------------------- /defaultSortComponents.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node' 3 | }; 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openapi-format", 3 | "version": "1.26.0", 4 | "description": "Format an OpenAPI document by ordering, formatting and filtering fields.", 5 | "keywords": [ 6 | "openapi", 7 | "openapi3", 8 | "format", 9 | "sort", 10 | "order", 11 | "filter", 12 | "convert", 13 | "rename", 14 | "case", 15 | "generate", 16 | "overlay", 17 | "cli" 18 | ], 19 | "homepage": "https://github.com/thim81/openapi-format#readme", 20 | "bugs": "https://github.com/thim81/openapi-format/issues", 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/thim81/openapi-format.git" 24 | }, 25 | "license": "MIT", 26 | "author": "Tim Haselaars", 27 | "main": "openapi-format.js", 28 | "types": "types/openapi-format.d.ts", 29 | "bin": { 30 | "openapi-format": "bin/cli.js" 31 | }, 32 | "scripts": { 33 | "test": "jest --colors --verbose --reporters=default --collectCoverage --no-cache --maxWorkers=2", 34 | "lint": "npx prettier --write '**/*.js'", 35 | "release": "npx np --branch main" 36 | }, 37 | "dependencies": { 38 | "@stoplight/yaml": "^4.3.0", 39 | "api-ref-bundler": "^0.4.3", 40 | "case-anything": "2.1.10", 41 | "commander": "^7.2.0", 42 | "jsonpath-plus": "^10.3.0", 43 | "neotraverse": "^0.6.18" 44 | }, 45 | "devDependencies": { 46 | "jest": "^29.7.0", 47 | "openapi-types": "^12.1.3" 48 | }, 49 | "engines": { 50 | "node": ">=18" 51 | }, 52 | "files": [ 53 | "README.md", 54 | "CHANGELOG.md", 55 | "LICENSE", 56 | "openapi-format.js", 57 | "utils/casing.js", 58 | "utils/convert.js", 59 | "utils/file.js", 60 | "utils/filtering.js", 61 | "utils/logging.js", 62 | "utils/overlay.js", 63 | "utils/parseTpl.js", 64 | "utils/sorting.js", 65 | "utils/split.js", 66 | "utils/types.js", 67 | "defaultFilter.json", 68 | "defaultSort.json", 69 | "defaultSortComponents.json", 70 | "types/openapi-format.d.ts", 71 | "package-lock.json" 72 | ], 73 | "directories": { 74 | "test": "test" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /test/__utils__/mockOpenApi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "Sample API", 5 | "version": "1.0.0" 6 | }, 7 | "paths": { 8 | "/pets": { 9 | "get": { 10 | "tags": [ 11 | "pets" 12 | ], 13 | "operationId": "getPets", 14 | "responses": { 15 | "200": { 16 | "description": "A list of pets.", 17 | "content": { 18 | "application/json": {} 19 | } 20 | } 21 | } 22 | }, 23 | "put": { 24 | "tags": [ 25 | "x-customTag" 26 | ], 27 | "operationId": "updatePet", 28 | "requestBody": { 29 | "description": "Pet object that needs to be updated", 30 | "content": { 31 | "application/json": { 32 | "schema": { 33 | "type": "object", 34 | "properties": { 35 | "id": { 36 | "type": "integer", 37 | "example": 1 38 | }, 39 | "name": { 40 | "type": "string", 41 | "example": "Rex" 42 | }, 43 | "tag": { 44 | "type": "string", 45 | "example": "dog" 46 | } 47 | }, 48 | "required": [ 49 | "id", 50 | "name" 51 | ] 52 | } 53 | }, 54 | "application/xml": { 55 | "schema": { 56 | "type": "object", 57 | "properties": { 58 | "id": { 59 | "type": "integer", 60 | "example": 1 61 | }, 62 | "name": { 63 | "type": "string", 64 | "example": "Rex" 65 | }, 66 | "tag": { 67 | "type": "string", 68 | "example": "dog" 69 | } 70 | }, 71 | "required": [ 72 | "id", 73 | "name" 74 | ] 75 | } 76 | } 77 | } 78 | }, 79 | "responses": { 80 | "200": { 81 | "description": "Pet updated.", 82 | "content": { 83 | "application/json": {}, 84 | "application/xml": {} 85 | } 86 | } 87 | }, 88 | "x-version": "1.0" 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /test/__utils__/mockTrain.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Train API 4 | version: 1.0.0 5 | 6 | paths: 7 | /trains/{id}: 8 | get: 9 | operationId: trainDetails 10 | summary: Retrieve details about a specific train 11 | tags: 12 | - Train 13 | - Transport 14 | parameters: 15 | - name: id 16 | in: path 17 | required: true 18 | description: The ID of the train 19 | schema: 20 | type: string 21 | responses: 22 | '200': 23 | description: A successful response with train details 24 | -------------------------------------------------------------------------------- /test/__utils__/test-utils.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const sy = require('@stoplight/yaml'); 3 | const {exec} = require('child_process'); 4 | const path = require('path'); 5 | const {parseFile, stringify} = require('../../utils/file'); 6 | 7 | async function loadTest(folder, inputType = 'yaml', outType = 'yaml') { 8 | let input, 9 | outputBefore, 10 | outputAfter = {}; 11 | const testPath = `./test/${folder}`; 12 | const inputFile = `input.${inputType}`; 13 | const inputPath = `./test/${folder}/${inputFile}`; 14 | const outputFile = `output.${outType}`; 15 | const outputPath = `./test/${folder}/${outputFile}`; 16 | 17 | try { 18 | input = await parseFile(inputPath); 19 | } catch (err) { 20 | // File not found = {} will be used 21 | } 22 | 23 | try { 24 | outputBefore = await parseFile(outputPath); 25 | } catch (err) { 26 | // File not found = {} will be used 27 | } 28 | 29 | let result = await cli([`${inputFile}`, `--configFile options.yaml`], testPath); 30 | 31 | try { 32 | outputAfter = await parseFile(outputPath); 33 | } catch (err) { 34 | // 35 | } 36 | 37 | return { 38 | result: result, 39 | input: input, 40 | outputBefore: await stringify(outputBefore), 41 | outputAfter: await stringify(outputAfter) 42 | }; 43 | } 44 | 45 | function cli(args, cwd) { 46 | return new Promise(resolve => { 47 | exec(`node ${path.resolve('./bin/cli')} ${args.join(' ')}`, {cwd}, (error, stderr, stdout) => { 48 | resolve({ 49 | code: error && error.code ? error.code : 0, 50 | error, 51 | stdout, 52 | stderr 53 | }); 54 | }); 55 | }); 56 | } 57 | 58 | module.exports = { 59 | loadTest: loadTest, 60 | cli: cli 61 | }; 62 | -------------------------------------------------------------------------------- /test/__utils__/train.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Train Travel API 4 | version: 1.0.0 5 | description: A compact version of the Train Travel API 6 | 7 | paths: 8 | /stations/{station_id}: 9 | get: 10 | summary: Get station information 11 | operationId: getStation 12 | parameters: 13 | - $ref: '#/components/parameters/StationId' 14 | responses: 15 | '200': 16 | description: Successful operation 17 | content: 18 | application/json: 19 | schema: 20 | $ref: '#/components/schemas/Station' 21 | '404': 22 | description: Station not found 23 | components: 24 | schemas: 25 | Station: 26 | type: object 27 | properties: 28 | id: 29 | type: string 30 | description: Unique identifier for the station 31 | name: 32 | type: string 33 | description: Name of the station 34 | location: 35 | type: object 36 | properties: 37 | latitude: 38 | type: number 39 | format: float 40 | longitude: 41 | type: number 42 | format: float 43 | description: Location of the station 44 | parameters: 45 | StationId: 46 | name: station_id 47 | in: path 48 | required: true 49 | schema: 50 | type: string 51 | description: The ID of the station 52 | -------------------------------------------------------------------------------- /test/_cli-configfile/configFile.json: -------------------------------------------------------------------------------- 1 | { 2 | "output": "test/_cli-configfile/output.json", 3 | "sortSet": { 4 | "info": ["title", "version"], 5 | "paths": { 6 | "order": [ "post", "put", "delete","get"] 7 | } 8 | }, 9 | "casingSet": { 10 | "operationId": "camelCase", 11 | "parameters": "snake_case", 12 | "properties": "PascalCase" 13 | }, 14 | "filterSet": { 15 | "removeUnusedComponents": true, 16 | "requestContent": ["application/xml"], 17 | "excludeTags": ["internal"] 18 | }, 19 | "generateSet": { 20 | "operationIdTemplate": "__Handler", 21 | "overwriteExisting": true 22 | }, 23 | "no-sort": false, 24 | "lineWidth": 80, 25 | "rename": "Updated API" 26 | } -------------------------------------------------------------------------------- /test/_cli-configfile/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "Updated API", 5 | "version": "1.0.0" 6 | }, 7 | "paths": { 8 | "/pets": { 9 | "get": { 10 | "operationId": "getPetsHandler", 11 | "responses": { 12 | "200": { 13 | "description": "A list of pets." 14 | } 15 | }, 16 | "tags": [ 17 | "pets" 18 | ] 19 | }, 20 | "put": { 21 | "operationId": "putPetsHandler", 22 | "requestBody": { 23 | "description": "Pet object that needs to be updated", 24 | "content": { 25 | "application/json": { 26 | "schema": { 27 | "type": "object", 28 | "properties": { 29 | "Id": { 30 | "type": "integer", 31 | "example": 1 32 | }, 33 | "Name": { 34 | "type": "string", 35 | "example": "Rex" 36 | }, 37 | "Tag": { 38 | "type": "string", 39 | "example": "dog" 40 | } 41 | }, 42 | "required": [ 43 | "id", 44 | "name" 45 | ] 46 | } 47 | } 48 | } 49 | }, 50 | "responses": { 51 | "200": { 52 | "description": "Pet updated." 53 | } 54 | }, 55 | "tags": [ 56 | "x-customTag" 57 | ], 58 | "x-version": "1.0" 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /test/_cli-configfile/snap.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "title": "Updated API", 5 | "version": "1.0.0" 6 | }, 7 | "paths": { 8 | "/pets": { 9 | "get": { 10 | "operationId": "getPetsHandler", 11 | "responses": { 12 | "200": { 13 | "description": "A list of pets." 14 | } 15 | }, 16 | "tags": [ 17 | "pets" 18 | ] 19 | }, 20 | "put": { 21 | "operationId": "putPetsHandler", 22 | "requestBody": { 23 | "description": "Pet object that needs to be updated", 24 | "content": { 25 | "application/json": { 26 | "schema": { 27 | "type": "object", 28 | "properties": { 29 | "Id": { 30 | "type": "integer", 31 | "example": 1 32 | }, 33 | "Name": { 34 | "type": "string", 35 | "example": "Rex" 36 | }, 37 | "Tag": { 38 | "type": "string", 39 | "example": "dog" 40 | } 41 | }, 42 | "required": [ 43 | "id", 44 | "name" 45 | ] 46 | } 47 | } 48 | } 49 | }, 50 | "responses": { 51 | "200": { 52 | "description": "Pet updated." 53 | } 54 | }, 55 | "tags": [ 56 | "x-customTag" 57 | ], 58 | "x-version": "1.0" 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /test/_split/snap.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Train Travel API 4 | version: 1.0.0 5 | description: A compact version of the Train Travel API 6 | paths: 7 | '/stations/{station_id}': 8 | $ref: 'paths/stations_{station_id}.yaml' 9 | components: 10 | schemas: 11 | Station: 12 | $ref: "components/schemas/Station.yaml" 13 | parameters: 14 | StationId: 15 | $ref: "components/parameters/StationId.yaml" 16 | -------------------------------------------------------------------------------- /test/_split/snap_station.yaml: -------------------------------------------------------------------------------- 1 | get: 2 | summary: Get station information 3 | operationId: getStation 4 | parameters: 5 | - $ref: "../components/parameters/StationId.yaml" 6 | responses: 7 | '200': 8 | description: Successful operation 9 | content: 10 | application/json: 11 | schema: 12 | $ref: "../components/schemas/Station.yaml" 13 | '404': 14 | description: Station not found 15 | -------------------------------------------------------------------------------- /test/_split/snap_station_id.yaml: -------------------------------------------------------------------------------- 1 | name: station_id 2 | in: path 3 | required: true 4 | schema: 5 | type: string 6 | description: The ID of the station 7 | -------------------------------------------------------------------------------- /test/json-convert-3.1/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | no-sort: true 4 | convertToVersion: 3.1 5 | -------------------------------------------------------------------------------- /test/json-custom-yaml/customSort.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": ["openapi", "info", "servers", "paths", "components", "tags", "x-tagGroups", "externalDocs"], 3 | "get": ["parameters", "requestBody", "responses", "operationId", "summary", "description"], 4 | "post": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 5 | "put": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 6 | "patch": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 7 | "delete": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 8 | "parameters": ["required", "schema", "name", "in", "description"], 9 | "requestBody": ["description", "headers", "content", "links"], 10 | "responses": ["description", "headers", "content", "links"], 11 | "content": [], 12 | "components": ["parameters", "schemas"], 13 | "Schema": ["description", "type", "items", "properties", "format", "example", "default"], 14 | "schemas": ["description", "type", "items", "properties", "format", "example", "default"], 15 | "properties": ["description", "type", "items", "format", "example", "default", "enum"] 16 | } 17 | -------------------------------------------------------------------------------- /test/json-custom-yaml/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | sortFile: customSort.json 4 | -------------------------------------------------------------------------------- /test/json-custom/customSort.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": ["openapi", "info", "servers", "paths", "components", "tags", "x-tagGroups", "externalDocs"], 3 | "get": ["parameters", "requestBody", "responses", "operationId", "summary", "description"], 4 | "post": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 5 | "put": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 6 | "patch": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 7 | "delete": ["operationId", "summary", "description", "parameters", "requestBody", "responses"], 8 | "parameters": ["required", "schema", "name", "in", "description"], 9 | "requestBody": ["description", "headers", "content", "links"], 10 | "responses": ["description", "headers", "content", "links"], 11 | "content": [], 12 | "components": ["parameters", "schemas"], 13 | "Schema": ["description", "type", "items", "properties", "format", "example", "default"], 14 | "schemas": ["description", "type", "items", "properties", "format", "example", "default"], 15 | "properties": ["description", "type", "items", "format", "example", "default", "enum"] 16 | } 17 | -------------------------------------------------------------------------------- /test/json-custom/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | sortFile: customSort.json 4 | -------------------------------------------------------------------------------- /test/json-default-bug-big-numbers/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "title": "Test", 5 | "version": "1.0.0" 6 | }, 7 | "paths": { 8 | "/pet": { 9 | "get": { 10 | "operationId": "getPet", 11 | "responses": { 12 | "200": { 13 | "description": "Successful operation", 14 | "content": { 15 | "application/json": { 16 | "schema": { 17 | "$ref": "#/components/schemas/Pet" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | } 24 | } 25 | }, 26 | "components": { 27 | "schemas": { 28 | "Pet": { 29 | "title": "500.1", 30 | "type": "object", 31 | "properties": { 32 | "NumberLimitsSchema": { 33 | "type": "number", 34 | "maximum": 9999999999999.99999, 35 | "minimum": 0, 36 | "multipleOf": 0.0000000001 37 | }, 38 | "properties": { 39 | "type": "string", 40 | "example": "123e4567-e89b-12d3-a456-426614174000" 41 | }, 42 | "id": { 43 | "type": "integer", 44 | "format": "int64", 45 | "example": 10 46 | }, 47 | "title": { 48 | "type": "string", 49 | "example": "500.1" 50 | }, 51 | "name": { 52 | "type": "string", 53 | "example": "123e4567" 54 | } 55 | }, 56 | "required": [ 57 | "name" 58 | ] 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /test/json-default-bug-big-numbers/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | no-sort: true 4 | -------------------------------------------------------------------------------- /test/json-default-bug-big-numbers/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "title": "Test", 5 | "version": "1.0.0" 6 | }, 7 | "paths": { 8 | "/pet": { 9 | "get": { 10 | "operationId": "getPet", 11 | "responses": { 12 | "200": { 13 | "description": "Successful operation", 14 | "content": { 15 | "application/json": { 16 | "schema": { 17 | "$ref": "#/components/schemas/Pet" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | } 24 | } 25 | }, 26 | "components": { 27 | "schemas": { 28 | "Pet": { 29 | "title": "500.1", 30 | "type": "object", 31 | "properties": { 32 | "NumberLimitsSchema": { 33 | "type": "number", 34 | "maximum": 9999999999999.99999, 35 | "minimum": 0, 36 | "multipleOf": 0.0000000001 37 | }, 38 | "properties": { 39 | "type": "string", 40 | "example": "123e4567-e89b-12d3-a456-426614174000" 41 | }, 42 | "id": { 43 | "type": "integer", 44 | "format": "int64", 45 | "example": 10 46 | }, 47 | "title": { 48 | "type": "string", 49 | "example": "500.1" 50 | }, 51 | "name": { 52 | "type": "string", 53 | "example": "123e4567" 54 | } 55 | }, 56 | "required": [ 57 | "name" 58 | ] 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /test/json-default-yaml/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | -------------------------------------------------------------------------------- /test/json-default/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | -------------------------------------------------------------------------------- /test/json-delete-method/customFilter.json: -------------------------------------------------------------------------------- 1 | { 2 | "methods": [ 3 | "POST", 4 | "DELETE", 5 | "get", 6 | "post", 7 | "put", 8 | "patch" 9 | ], 10 | "tags": [], 11 | "operationIds": [], 12 | "operations": [], 13 | "flags": [], 14 | "flagValues": [] 15 | } 16 | -------------------------------------------------------------------------------- /test/json-delete-method/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "components": { 3 | "schemas": { 4 | "RequestBody": { 5 | "type": "object", 6 | "properties": { 7 | "delete": { 8 | "type": "boolean", 9 | "default": false 10 | }, 11 | "get": { 12 | "type": "boolean", 13 | "default": false 14 | }, 15 | "put": { 16 | "type": "boolean", 17 | "default": false 18 | }, 19 | "patch": { 20 | "type": "boolean", 21 | "default": false 22 | }, 23 | "post": { 24 | "type": "boolean", 25 | "default": false 26 | } 27 | }, 28 | "required": [ 29 | "delete", 30 | "get", 31 | "post", 32 | "put", 33 | "patch" 34 | ] 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/json-delete-method/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.json 4 | filterFile: customFilter.json 5 | -------------------------------------------------------------------------------- /test/json-delete-method/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "components": { 3 | "schemas": { 4 | "RequestBody": { 5 | "type": "object", 6 | "properties": { 7 | "delete": { 8 | "type": "boolean", 9 | "default": false 10 | }, 11 | "get": { 12 | "type": "boolean", 13 | "default": false 14 | }, 15 | "put": { 16 | "type": "boolean", 17 | "default": false 18 | }, 19 | "patch": { 20 | "type": "boolean", 21 | "default": false 22 | }, 23 | "post": { 24 | "type": "boolean", 25 | "default": false 26 | } 27 | }, 28 | "required": [ 29 | "delete", 30 | "get", 31 | "post", 32 | "put", 33 | "patch" 34 | ] 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/json-example-request/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "description": "This is a sample OpenAPI 3.0 specification. ", 5 | "version": "1.0.6-SNAPSHOT", 6 | "title": "Sample OpenAPI 3.0 app" 7 | }, 8 | "paths": { 9 | "/api": { 10 | "put": { 11 | "requestBody": { 12 | "required": true, 13 | "content": { 14 | "application/json": { 15 | "schema": { 16 | "type": "object", 17 | "properties": { 18 | "schemas": { 19 | "type": "array", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | }, 25 | "example": { 26 | "schemas": [ 27 | "urn:ietf:params:scim:schemas:core:2.0:Group" 28 | ] 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/json-example-request/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | -------------------------------------------------------------------------------- /test/json-example-request/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "description": "This is a sample OpenAPI 3.0 specification. ", 5 | "version": "1.0.6-SNAPSHOT", 6 | "title": "Sample OpenAPI 3.0 app" 7 | }, 8 | "paths": { 9 | "/api": { 10 | "put": { 11 | "requestBody": { 12 | "required": true, 13 | "content": { 14 | "application/json": { 15 | "schema": { 16 | "type": "object", 17 | "properties": { 18 | "schemas": { 19 | "type": "array", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | }, 25 | "example": { 26 | "schemas": [ 27 | "urn:ietf:params:scim:schemas:core:2.0:Group" 28 | ] 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /test/json-example-schemas/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "description": "This is a sample OpenAPI 3.0 specification. ", 5 | "version": "1.0.6-SNAPSHOT", 6 | "title": "Sample OpenAPI 3.0 app" 7 | }, 8 | "components": { 9 | "schemas": { 10 | "CreateGroupRequest": { 11 | "type": "object", 12 | "properties": { 13 | "schemas": { 14 | "type": "array", 15 | "items": { 16 | "type": "string" 17 | } 18 | } 19 | }, 20 | "example": { 21 | "displayName": "Test SCIM", 22 | "members": [], 23 | "schemas": [ 24 | "urn:ietf:params:scim:schemas:core:2.0:Group" 25 | ] 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/json-example-schemas/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | -------------------------------------------------------------------------------- /test/json-example-schemas/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "description": "This is a sample OpenAPI 3.0 specification. ", 5 | "version": "1.0.6-SNAPSHOT", 6 | "title": "Sample OpenAPI 3.0 app" 7 | }, 8 | "components": { 9 | "schemas": { 10 | "CreateGroupRequest": { 11 | "type": "object", 12 | "properties": { 13 | "schemas": { 14 | "type": "array", 15 | "items": { 16 | "type": "string" 17 | } 18 | } 19 | }, 20 | "example": { 21 | "displayName": "Test SCIM", 22 | "members": [], 23 | "schemas": [ 24 | "urn:ietf:params:scim:schemas:core:2.0:Group" 25 | ] 26 | } 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /test/json-filter-empty-paths/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/json-filter-empty-paths/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "paths": { 3 | "/to-remove": {}, 4 | "/to-keep": { 5 | "post": { 6 | "responses": { 7 | "200": { 8 | "description": "OK" 9 | } 10 | } 11 | } 12 | } 13 | }, 14 | "components": { 15 | "schemas": { 16 | "Pet": { 17 | "type": "object", 18 | "properties": { 19 | "id": { 20 | "type": "integer", 21 | "format": "int64", 22 | "example": 10 23 | }, 24 | "name": { 25 | "type": "string", 26 | "example": "doggie" 27 | }, 28 | "paths": { 29 | "type": "string", 30 | "example": "path" 31 | }, 32 | "tags": { 33 | "type": "array", 34 | "items": { 35 | "$ref": "#/components/schemas/Tag", 36 | "xml": { 37 | "name": "tag" 38 | } 39 | } 40 | }, 41 | "status": { 42 | "type": "string", 43 | "description": "pet status in the store", 44 | "enum": [ 45 | "available", 46 | "pending", 47 | "sold" 48 | ] 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /test/json-filter-empty-paths/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | filterFile: customFilter.yaml 4 | -------------------------------------------------------------------------------- /test/json-filter-empty-paths/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "paths": { 3 | "/to-keep": { 4 | "post": { 5 | "responses": { 6 | "200": { 7 | "description": "OK" 8 | } 9 | } 10 | } 11 | } 12 | }, 13 | "components": { 14 | "schemas": { 15 | "Pet": { 16 | "type": "object", 17 | "properties": { 18 | "id": { 19 | "type": "integer", 20 | "format": "int64", 21 | "example": 10 22 | }, 23 | "name": { 24 | "type": "string", 25 | "example": "doggie" 26 | }, 27 | "paths": { 28 | "type": "string", 29 | "example": "path" 30 | }, 31 | "tags": { 32 | "type": "array", 33 | "items": { 34 | "$ref": "#/components/schemas/Tag", 35 | "xml": { 36 | "name": "tag" 37 | } 38 | } 39 | }, 40 | "status": { 41 | "description": "pet status in the store", 42 | "type": "string", 43 | "enum": [ 44 | "available", 45 | "pending", 46 | "sold" 47 | ] 48 | } 49 | } 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /test/json-filter-inverse-operationids-126/customFilter.yaml: -------------------------------------------------------------------------------- 1 | unusedComponents: 2 | - schemas 3 | - parameters 4 | - examples 5 | - headers 6 | - requestBodies 7 | - responses 8 | inverseOperationIds: 9 | - createJob 10 | -------------------------------------------------------------------------------- /test/json-filter-inverse-operationids-126/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "contact": { 5 | "url": "" 6 | }, 7 | "description": "", 8 | "title": "", 9 | "version": "1.0.0" 10 | }, 11 | "servers": [ 12 | { 13 | "url": "" 14 | } 15 | ], 16 | "paths": { 17 | "/jobs": { 18 | "post": { 19 | "description": "New job", 20 | "operationId": "createJob", 21 | "requestBody": { 22 | "content": { 23 | "application/json": { 24 | "schema": { 25 | "$ref": "#/components/schemas/job-request" 26 | } 27 | } 28 | }, 29 | "required": true 30 | }, 31 | "responses": { 32 | "200": { 33 | "content": { 34 | "application/json": { 35 | "schema": { 36 | "type": "string" 37 | } 38 | } 39 | }, 40 | "description": "OK" 41 | } 42 | } 43 | } 44 | } 45 | }, 46 | "components": { 47 | "schemas": { 48 | "user": { 49 | "properties": { 50 | "email": { 51 | "type": "string" 52 | }, 53 | "name": { 54 | "type": "string" 55 | } 56 | }, 57 | "required": [ 58 | "email", 59 | "name" 60 | ], 61 | "type": "object" 62 | }, 63 | "job-request": { 64 | "additionalProperties": false, 65 | "properties": { 66 | "projectId": { 67 | "type": "string" 68 | }, 69 | "details": { 70 | "$ref": "#/components/schemas/details" 71 | } 72 | }, 73 | "required": [ 74 | "details" 75 | ], 76 | "type": "object" 77 | }, 78 | "details": { 79 | "additionalProperties": false, 80 | "properties": { 81 | "user": { 82 | "type": "string" 83 | }, 84 | "password": { 85 | "type": "string" 86 | } 87 | }, 88 | "required": [ 89 | "user", 90 | "password" 91 | ], 92 | "type": "object" 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /test/json-filter-inverse-operationids-126/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.json 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/json-filter-inverse-operationids-126/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "contact": { 5 | "url": "" 6 | }, 7 | "description": "", 8 | "title": "", 9 | "version": "1.0.0" 10 | }, 11 | "servers": [ 12 | { 13 | "url": "" 14 | } 15 | ], 16 | "paths": { 17 | "/jobs": { 18 | "post": { 19 | "description": "New job", 20 | "operationId": "createJob", 21 | "requestBody": { 22 | "content": { 23 | "application/json": { 24 | "schema": { 25 | "$ref": "#/components/schemas/job-request" 26 | } 27 | } 28 | }, 29 | "required": true 30 | }, 31 | "responses": { 32 | "200": { 33 | "content": { 34 | "application/json": { 35 | "schema": { 36 | "type": "string" 37 | } 38 | } 39 | }, 40 | "description": "OK" 41 | } 42 | } 43 | } 44 | } 45 | }, 46 | "components": { 47 | "schemas": { 48 | "job-request": { 49 | "additionalProperties": false, 50 | "properties": { 51 | "projectId": { 52 | "type": "string" 53 | }, 54 | "details": { 55 | "$ref": "#/components/schemas/details" 56 | } 57 | }, 58 | "required": [ 59 | "details" 60 | ], 61 | "type": "object" 62 | }, 63 | "details": { 64 | "additionalProperties": false, 65 | "properties": { 66 | "user": { 67 | "type": "string" 68 | }, 69 | "password": { 70 | "type": "string" 71 | } 72 | }, 73 | "required": [ 74 | "user", 75 | "password" 76 | ], 77 | "type": "object" 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /test/json-filter-inverse-operationids/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | inverseOperationIds: 8 | - addPet 9 | - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/json-filter-inverse-operationids/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.json 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/json-filter-markdown-comments/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | tags: 7 | - store 8 | # - user 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | -------------------------------------------------------------------------------- /test/json-filter-markdown-comments/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.json 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/json-filter-unused/customFilter.yaml: -------------------------------------------------------------------------------- 1 | operationIds: 2 | - pets/getPets 3 | unusedComponents: 4 | - schemas 5 | - parameters 6 | - examples 7 | - headers 8 | - requestBodies 9 | - responses -------------------------------------------------------------------------------- /test/json-filter-unused/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.json 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/json-filter-unused/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.0", 3 | "info": { 4 | "version": "12.0.0" 5 | }, 6 | "paths": { 7 | "/reviews": { 8 | "post": { 9 | "operationId": "reviews/postReview", 10 | "requestBody": { 11 | "content": { 12 | "application/json": { 13 | "schema": { 14 | "$ref": "#/components/schemas/ReviewRequest" 15 | } 16 | } 17 | } 18 | }, 19 | "responses": { 20 | "200": { 21 | "content": { 22 | "application/json": { 23 | "schema": { 24 | "$ref": "#/components/schemas/ReviewResponse" 25 | } 26 | } 27 | } 28 | }, 29 | "400": { 30 | "content": { 31 | "application/json": { 32 | "schema": { 33 | "$ref": "#/components/schemas/ClientError" 34 | } 35 | } 36 | } 37 | }, 38 | "500": { 39 | "content": { 40 | "application/json": { 41 | "schema": { 42 | "$ref": "#/components/schemas/ClientError" 43 | } 44 | } 45 | } 46 | } 47 | } 48 | } 49 | } 50 | }, 51 | "components": { 52 | "schemas": { 53 | "ClientError": { 54 | "type": "object", 55 | "properties": { 56 | "type": { 57 | "type": "string", 58 | "example": "error", 59 | "enum": [ 60 | "error" 61 | ], 62 | "nullable": false 63 | }, 64 | "status": { 65 | "type": "integer", 66 | "format": "int32", 67 | "example": 400, 68 | "nullable": false 69 | } 70 | } 71 | }, 72 | "Comment": { 73 | "type": "object", 74 | "properties": { 75 | "id": { 76 | "type": "string", 77 | "example": "123", 78 | "nullable": false 79 | }, 80 | "type": { 81 | "type": "string", 82 | "example": "comment", 83 | "enum": [ 84 | "comment" 85 | ], 86 | "nullable": false 87 | } 88 | }, 89 | "required": [ 90 | "id", 91 | "type" 92 | ] 93 | }, 94 | "ReviewRequest": { 95 | "type": "object", 96 | "properties": { 97 | "id": { 98 | "type": "string", 99 | "example": "123", 100 | "nullable": false, 101 | "readOnly": true 102 | } 103 | }, 104 | "required": [ 105 | "id" 106 | ] 107 | }, 108 | "ReviewResponse": { 109 | "type": "object", 110 | "properties": { 111 | "id": { 112 | "type": "string", 113 | "example": "123", 114 | "nullable": false, 115 | "readOnly": true 116 | }, 117 | "type": { 118 | "type": "string", 119 | "example": "review", 120 | "enum": [ 121 | "review" 122 | ], 123 | "nullable": false, 124 | "readOnly": true 125 | }, 126 | "comment": { 127 | "allOf": [ 128 | { 129 | "$ref": "#/components/schemas/Comment" 130 | } 131 | ], 132 | "nullable": false, 133 | "readOnly": true 134 | } 135 | }, 136 | "required": [ 137 | "id", 138 | "type", 139 | "comment" 140 | ] 141 | } 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /test/json-no-sort/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.json 4 | -------------------------------------------------------------------------------- /test/json-rename/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | no-sort: true 4 | rename: 'OpenAPI Petstore - OpenAPI 3.0' 5 | -------------------------------------------------------------------------------- /test/json-sort-components/customSortComponents.json: -------------------------------------------------------------------------------- 1 | ["schemas", "parameters", "headers", "requestBodies", "responses", "securitySchemes"] 2 | -------------------------------------------------------------------------------- /test/json-sort-components/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | sortComponentsFile: customSortComponents.json 3 | output: output.json 4 | -------------------------------------------------------------------------------- /test/json-sort-request-params/customSortComponents.yaml: -------------------------------------------------------------------------------- 1 | - parameters 2 | -------------------------------------------------------------------------------- /test/json-sort-request-params/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "version": "1.0.6-SNAPSHOT", 5 | "title": "OpenAPI 3.0" 6 | }, 7 | "paths": { 8 | "/api/products": { 9 | "get": { 10 | "summary": "Get the list of existing products.", 11 | "parameters": [ 12 | { 13 | "name": "offset", 14 | "in": "query", 15 | "description": "The offset to apply to the paginated query." 16 | }, 17 | { 18 | "name": "limit", 19 | "in": "query", 20 | "description": "The limit to apply to the paginated query." 21 | } 22 | ], 23 | "responses": { 24 | "200": { 25 | "description": "OK" 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/json-sort-request-params/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | sortComponentsFile: customSortComponents.yaml 3 | output: output.json 4 | -------------------------------------------------------------------------------- /test/json-sort-request-params/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.2", 3 | "info": { 4 | "version": "1.0.6-SNAPSHOT", 5 | "title": "OpenAPI 3.0" 6 | }, 7 | "paths": { 8 | "/api/products": { 9 | "get": { 10 | "summary": "Get the list of existing products.", 11 | "parameters": [ 12 | { 13 | "name": "limit", 14 | "in": "query", 15 | "description": "The limit to apply to the paginated query." 16 | }, 17 | { 18 | "name": "offset", 19 | "in": "query", 20 | "description": "The offset to apply to the paginated query." 21 | } 22 | ], 23 | "responses": { 24 | "200": { 25 | "description": "OK" 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /test/json-yaml-null/customFilter.yaml: -------------------------------------------------------------------------------- 1 | tags: [] 2 | #preserveEmptyObjects: true 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/json-yaml-null/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.3", 3 | "info": { 4 | "title": "Minimal API", 5 | "version": "1.0.0" 6 | }, 7 | "paths": { 8 | "/test": { 9 | "get": { 10 | "responses": { 11 | "200": { 12 | "description": "Successful response", 13 | "content": { 14 | "application/json": { 15 | "schema": { 16 | "oneOf": [ 17 | { 18 | "type": "object", 19 | "properties": { 20 | "message": { 21 | "type": "string" 22 | } 23 | } 24 | }, 25 | {} 26 | ] 27 | } 28 | } 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/json-yaml-null/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/json-yaml-null/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /test: 7 | get: 8 | responses: 9 | '200': 10 | description: Successful response 11 | content: 12 | application/json: 13 | schema: 14 | oneOf: 15 | - type: object 16 | properties: 17 | message: 18 | type: string 19 | - {} 20 | -------------------------------------------------------------------------------- /test/overlay-combi/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | title: Original API 4 | version: 1.0.0 5 | servers: 6 | - url: 'https://api.example.com' 7 | description: Default server 8 | -------------------------------------------------------------------------------- /test/overlay-combi/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | overlayFile: overlay.yaml 5 | 6 | -------------------------------------------------------------------------------- /test/overlay-combi/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | title: Original API 4 | version: 1.0.0 5 | description: An updated description 6 | contact: 7 | name: Support 8 | url: 'https://example.com/contact' 9 | servers: 10 | - url: 'https://api.new-example.com' 11 | description: New server 12 | -------------------------------------------------------------------------------- /test/overlay-combi/overlay.yaml: -------------------------------------------------------------------------------- 1 | actions: 2 | - target: $.info 3 | update: 4 | description: An updated description 5 | contact: 6 | name: Support 7 | url: 'https://example.com/contact' 8 | - target: '$.servers[*]' 9 | remove: true 10 | - target: '$.server[*]' 11 | remove: true 12 | - target: $.servers 13 | update: 14 | - url: 'https://api.new-example.com' 15 | description: New server 16 | -------------------------------------------------------------------------------- /test/overlay-params/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | info: 3 | title: Datasource API 4 | description: API to work with Datasources. 5 | termsOfService: 'urn:tos''' 6 | paths: 7 | /timeseries: 8 | get: 9 | operationId: searchTimeSeriesDefinitions 10 | summary: Search the time series definitions 11 | parameters: 12 | - name: searchPattern 13 | in: query 14 | description: Pattern to search time series definitions. Cannot be used at the same time as name parameter. 15 | required: false 16 | schema: 17 | type: string -------------------------------------------------------------------------------- /test/overlay-params/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | overlayFile: overlay.yaml 5 | 6 | -------------------------------------------------------------------------------- /test/overlay-params/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | info: 3 | title: Datasource API 4 | description: API to work with Datasources. 5 | termsOfService: 'urn:tos''' 6 | paths: 7 | /timeseries: 8 | get: 9 | operationId: searchTimeSeriesDefinitions 10 | summary: Search the time series definitions 11 | parameters: 12 | - name: searchPattern 13 | in: query 14 | description: A pattern used to search time series definitions. 15 | required: false 16 | schema: 17 | type: string 18 | example: temp- 19 | description: Retrieve a list of all time series definitions. This endpoint supports search and pagination. 20 | -------------------------------------------------------------------------------- /test/overlay-params/overlay.yaml: -------------------------------------------------------------------------------- 1 | overlay: 1.0.0 2 | info: 3 | title: Structured Overlay 4 | version: 1.0.0 5 | actions: 6 | - target: "$" # Root of document 7 | update: 8 | paths: 9 | /timeseries: 10 | get: 11 | description: Retrieve a list of all time series definitions. This endpoint supports search and pagination. 12 | parameters: 13 | - name: searchPattern 14 | in: query 15 | description: A pattern used to search time series definitions. 16 | schema: 17 | example: temp- -------------------------------------------------------------------------------- /test/overlay-preserve-required/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.1.0 2 | info: 3 | title: Example API 4 | version: 1.0.0 5 | paths: 6 | /items: 7 | get: 8 | summary: List items 9 | responses: 10 | '200': 11 | description: Successful response 12 | content: 13 | application/json: 14 | schema: 15 | type: array 16 | items: 17 | type: string 18 | 'default': 19 | description: Error response 20 | content: 21 | application/problem+json: 22 | schema: 23 | $ref: '#/components/schemas/ProblemDetailsComponent' 24 | components: 25 | schemas: {} 26 | -------------------------------------------------------------------------------- /test/overlay-preserve-required/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | overlayFile: overlay.yaml 5 | 6 | -------------------------------------------------------------------------------- /test/overlay-preserve-required/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.1.0 2 | info: 3 | title: Example API 4 | version: 1.0.0 5 | paths: 6 | /items: 7 | get: 8 | summary: List items 9 | responses: 10 | '200': 11 | description: Successful response 12 | content: 13 | application/json: 14 | schema: 15 | type: array 16 | items: 17 | type: string 18 | default: 19 | description: Error response 20 | content: 21 | application/problem+json: 22 | schema: 23 | $ref: '#/components/schemas/ProblemDetailsComponent' 24 | components: 25 | schemas: 26 | ProblemDetailsComponent: 27 | type: object 28 | description: A problem details object as defined in RFC 9457 for HTTP API error responses 29 | required: 30 | - type 31 | properties: 32 | type: 33 | description: A URI reference that identifies the problem type 34 | example: 'https://example.com/probs/permissions' 35 | format: uri 36 | type: string 37 | title: 38 | description: 'A short, human-readable summary of the problem type' 39 | example: You do not have permissions to perform this action 40 | type: string 41 | status: 42 | description: The HTTP status code generated by the origin server for this occurrence of the problem 43 | example: 403 44 | maximum: 599 45 | minimum: 100 46 | type: integer 47 | detail: 48 | description: A human-readable explanation specific to this occurrence of the problem 49 | example: Administrator privileges are required for this operation 50 | type: string 51 | instance: 52 | description: A URI reference that identifies the specific occurrence of the problem 53 | example: 'https://example.com/account/12345/message/delete' 54 | format: uri 55 | type: string 56 | -------------------------------------------------------------------------------- /test/overlay-preserve-required/overlay.yaml: -------------------------------------------------------------------------------- 1 | overlay: 1.0.0 2 | info: 3 | title: '' 4 | version: '' 5 | actions: 6 | - target: $.components 7 | update: 8 | schemas: 9 | ProblemDetailsComponent: 10 | type: object 11 | description: A problem details object as defined in RFC 9457 for HTTP API error responses 12 | required: 13 | - type 14 | properties: 15 | type: 16 | description: A URI reference that identifies the problem type 17 | example: 'https://example.com/probs/permissions' 18 | format: uri 19 | type: string 20 | title: 21 | description: 'A short, human-readable summary of the problem type' 22 | example: You do not have permissions to perform this action 23 | type: string 24 | status: 25 | description: The HTTP status code generated by the origin server for this occurrence of the problem 26 | example: 403 27 | maximum: 599 28 | minimum: 100 29 | type: integer 30 | detail: 31 | description: A human-readable explanation specific to this occurrence of the problem 32 | example: Administrator privileges are required for this operation 33 | type: string 34 | instance: 35 | description: A URI reference that identifies the specific occurrence of the problem 36 | example: 'https://example.com/account/12345/message/delete' 37 | format: uri 38 | type: string 39 | -------------------------------------------------------------------------------- /test/yaml-casing-component-keys/customCasing.yaml: -------------------------------------------------------------------------------- 1 | componentsExamples: PascalCase 2 | componentsSchemas: snake_case 3 | componentsHeaders: kebab-case 4 | componentsResponses: snake_case 5 | componentsRequestBodies: snake_case 6 | componentsSecuritySchemes: snake_case 7 | -------------------------------------------------------------------------------- /test/yaml-casing-component-keys/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | casingFile: customCasing.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-casing-component-parameters-keys/customCasing.yaml: -------------------------------------------------------------------------------- 1 | # Component Parameter Keys 2 | componentsParametersHeader: kebab-case 3 | componentsParametersQuery: snake_case 4 | componentsParametersPath: kebab-case 5 | componentsParametersCookie: PascalCase 6 | 7 | # Component Parameter Names 8 | parametersCookie: PascalCase 9 | -------------------------------------------------------------------------------- /test/yaml-casing-component-parameters-keys/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | casingFile: customCasing.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-casing-operationId/customCasing.yaml: -------------------------------------------------------------------------------- 1 | operationId: snake_case 2 | 3 | -------------------------------------------------------------------------------- /test/yaml-casing-operationId/customFilter.yaml: -------------------------------------------------------------------------------- 1 | unusedComponents: 2 | - schemas 3 | - parameters 4 | - headers 5 | - requestBodies 6 | - responses 7 | 8 | -------------------------------------------------------------------------------- /test/yaml-casing-operationId/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | casingFile: customCasing.yaml 5 | filterFile: customFilter.yaml 6 | -------------------------------------------------------------------------------- /test/yaml-casing-parameters/customCasing.yaml: -------------------------------------------------------------------------------- 1 | parametersQuery: snake_case 2 | parametersHeader: snake_case 3 | parametersPath: snake_case 4 | -------------------------------------------------------------------------------- /test/yaml-casing-parameters/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | casingFile: customCasing.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-casing-properties/customCasing.yaml: -------------------------------------------------------------------------------- 1 | properties: snake_case 2 | -------------------------------------------------------------------------------- /test/yaml-casing-properties/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | casingFile: customCasing.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-casing-required/customCasing.yaml: -------------------------------------------------------------------------------- 1 | properties: snake_case 2 | -------------------------------------------------------------------------------- /test/yaml-casing-required/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | components: 3 | schemas: 4 | UserModel: 5 | type: object 6 | properties: 7 | id: 8 | type: integer 9 | example: 10 10 | emailAddress: 11 | type: string 12 | example: john@doe.com 13 | firstName: 14 | type: string 15 | example: John 16 | required: 17 | - id 18 | - emailAddress 19 | -------------------------------------------------------------------------------- /test/yaml-casing-required/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | casingFile: customCasing.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-casing-required/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | components: 3 | schemas: 4 | UserModel: 5 | type: object 6 | properties: 7 | id: 8 | type: integer 9 | example: 10 10 | email_address: 11 | type: string 12 | example: john@doe.com 13 | first_name: 14 | type: string 15 | example: John 16 | required: 17 | - id 18 | - email_address 19 | -------------------------------------------------------------------------------- /test/yaml-casing/customCasing.yaml: -------------------------------------------------------------------------------- 1 | operationId: snake_case 2 | properties: snake_case 3 | 4 | parametersQuery: snake_case 5 | parametersHeader: kebab-case 6 | parametersPath: snake_case 7 | 8 | componentsExamples: PascalCase 9 | componentsSchemas: snake_case 10 | componentsHeaders: snake_case 11 | componentsResponses: snake_case 12 | componentsRequestBodies: snake_case 13 | componentsSecuritySchemes: snake_case 14 | 15 | componentsParametersQuery: snake_case 16 | componentsParametersHeader: kebab-case 17 | componentsParametersPath: camelCase 18 | 19 | -------------------------------------------------------------------------------- /test/yaml-casing/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | casingFile: customCasing.yaml 5 | 6 | -------------------------------------------------------------------------------- /test/yaml-convert-3.1/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | convertTo: 3.1 5 | -------------------------------------------------------------------------------- /test/yaml-custom-3.1/customSort.yaml: -------------------------------------------------------------------------------- 1 | root: 2 | - openapi 3 | - info 4 | - servers 5 | - paths 6 | - components 7 | - tags 8 | - x-tagGroups 9 | - externalDocs 10 | get: 11 | - parameters 12 | - requestBody 13 | - responses 14 | - operationId 15 | - summary 16 | - description 17 | post: 18 | - operationId 19 | - summary 20 | - description 21 | - parameters 22 | - requestBody 23 | - responses 24 | put: 25 | - operationId 26 | - summary 27 | - description 28 | - parameters 29 | - requestBody 30 | - responses 31 | patch: 32 | - operationId 33 | - summary 34 | - description 35 | - parameters 36 | - requestBody 37 | - responses 38 | delete: 39 | - operationId 40 | - summary 41 | - description 42 | - parameters 43 | - requestBody 44 | - responses 45 | parameters: 46 | - required 47 | - schema 48 | - name 49 | - in 50 | - description 51 | requestBody: 52 | - description 53 | - headers 54 | - content 55 | - links 56 | responses: 57 | - description 58 | - headers 59 | - content 60 | - links 61 | content: [] 62 | components: 63 | - parameters 64 | - schemas 65 | Schema: 66 | - description 67 | - type 68 | - items 69 | - properties 70 | - format 71 | - example 72 | - default 73 | schemas: 74 | - description 75 | - type 76 | - items 77 | - properties 78 | - format 79 | - example 80 | - default 81 | properties: 82 | - description 83 | - type 84 | - items 85 | - format 86 | - example 87 | - default 88 | - enum 89 | -------------------------------------------------------------------------------- /test/yaml-custom-3.1/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | sortFile: customSort.yaml 4 | -------------------------------------------------------------------------------- /test/yaml-custom-json/customSort.yaml: -------------------------------------------------------------------------------- 1 | root: 2 | - openapi 3 | - info 4 | - servers 5 | - paths 6 | - components 7 | - tags 8 | - x-tagGroups 9 | - externalDocs 10 | get: 11 | - parameters 12 | - requestBody 13 | - responses 14 | - operationId 15 | - summary 16 | - description 17 | post: 18 | - operationId 19 | - summary 20 | - description 21 | - parameters 22 | - requestBody 23 | - responses 24 | put: 25 | - operationId 26 | - summary 27 | - description 28 | - parameters 29 | - requestBody 30 | - responses 31 | patch: 32 | - operationId 33 | - summary 34 | - description 35 | - parameters 36 | - requestBody 37 | - responses 38 | delete: 39 | - operationId 40 | - summary 41 | - description 42 | - parameters 43 | - requestBody 44 | - responses 45 | parameters: 46 | - required 47 | - schema 48 | - name 49 | - in 50 | - description 51 | requestBody: 52 | - description 53 | - headers 54 | - content 55 | - links 56 | responses: 57 | - description 58 | - headers 59 | - content 60 | - links 61 | content: [] 62 | components: 63 | - parameters 64 | - schemas 65 | Schema: 66 | - description 67 | - type 68 | - items 69 | - properties 70 | - format 71 | - example 72 | - default 73 | schemas: 74 | - description 75 | - type 76 | - items 77 | - properties 78 | - format 79 | - example 80 | - default 81 | properties: 82 | - description 83 | - type 84 | - items 85 | - format 86 | - example 87 | - default 88 | - enum 89 | -------------------------------------------------------------------------------- /test/yaml-custom-json/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | sortFile: customSort.yaml 4 | -------------------------------------------------------------------------------- /test/yaml-custom/customSort.yaml: -------------------------------------------------------------------------------- 1 | root: 2 | - openapi 3 | - info 4 | - servers 5 | - paths 6 | - components 7 | - tags 8 | - x-tagGroups 9 | - externalDocs 10 | get: 11 | - parameters 12 | - requestBody 13 | - responses 14 | - operationId 15 | - summary 16 | - description 17 | post: 18 | - operationId 19 | - summary 20 | - description 21 | - parameters 22 | - requestBody 23 | - responses 24 | put: 25 | - operationId 26 | - summary 27 | - description 28 | - parameters 29 | - requestBody 30 | - responses 31 | patch: 32 | - operationId 33 | - summary 34 | - description 35 | - parameters 36 | - requestBody 37 | - responses 38 | delete: 39 | - operationId 40 | - summary 41 | - description 42 | - parameters 43 | - requestBody 44 | - responses 45 | parameters: 46 | - required 47 | - schema 48 | - name 49 | - in 50 | - description 51 | requestBody: 52 | - description 53 | - headers 54 | - content 55 | - links 56 | responses: 57 | - description 58 | - headers 59 | - content 60 | - links 61 | content: [] 62 | components: 63 | - parameters 64 | - schemas 65 | Schema: 66 | - description 67 | - type 68 | - items 69 | - properties 70 | - format 71 | - example 72 | - default 73 | schemas: 74 | - description 75 | - type 76 | - items 77 | - properties 78 | - format 79 | - example 80 | - default 81 | properties: 82 | - description 83 | - type 84 | - items 85 | - format 86 | - example 87 | - default 88 | - enum 89 | -------------------------------------------------------------------------------- /test/yaml-custom/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | sortFile: customSort.yaml 4 | -------------------------------------------------------------------------------- /test/yaml-default-bug-big-numbers/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | title: Test 4 | version: 0.0.1 5 | paths: 6 | /pet: 7 | get: 8 | operationId: getPet 9 | responses: 10 | '200': 11 | description: Successful operation 12 | content: 13 | application/json: 14 | schema: 15 | $ref: '#/components/schemas/Pet' 16 | components: 17 | schemas: 18 | Pet: 19 | title: '500.1' 20 | type: object 21 | properties: 22 | properties: 23 | type: string 24 | example: 123e4567-e89b-12d3-a456-426614174000 25 | id: 26 | type: integer 27 | format: int64 28 | example: 10 29 | rate: 30 | type: integer 31 | format: int64 32 | example: 0.61 33 | title: 34 | type: string 35 | example: 500.1 36 | name: 37 | type: string 38 | example: 123456789012345678901234567890 39 | NumberLimitsSchema: 40 | type: number 41 | maximum: 9999999999999.99999 42 | minimum: 0 43 | multipleOf: 0.0000000001 44 | required: 45 | - name 46 | -------------------------------------------------------------------------------- /test/yaml-default-bug-big-numbers/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | -------------------------------------------------------------------------------- /test/yaml-default-bug-big-numbers/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | title: Test 4 | version: 0.0.1 5 | paths: 6 | /pet: 7 | get: 8 | operationId: getPet 9 | responses: 10 | '200': 11 | description: Successful operation 12 | content: 13 | application/json: 14 | schema: 15 | $ref: '#/components/schemas/Pet' 16 | components: 17 | schemas: 18 | Pet: 19 | title: '500.1' 20 | type: object 21 | properties: 22 | properties: 23 | type: string 24 | example: 123e4567-e89b-12d3-a456-426614174000 25 | id: 26 | type: integer 27 | format: int64 28 | example: 10 29 | rate: 30 | type: integer 31 | format: int64 32 | example: 0.61 33 | title: 34 | type: string 35 | example: 500.1 36 | name: 37 | type: string 38 | example: 123456789012345678901234567890 39 | NumberLimitsSchema: 40 | type: number 41 | maximum: 9999999999999.99999 42 | minimum: 0 43 | multipleOf: 0.0000000001 44 | required: 45 | - name 46 | -------------------------------------------------------------------------------- /test/yaml-default-bug-examples-properties/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | -------------------------------------------------------------------------------- /test/yaml-default-bug-nested-properties/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | -------------------------------------------------------------------------------- /test/yaml-default-bug-numbers-x-tag/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | version: 1.0.6-SNAPSHOT 4 | title: Swagger Petstore - OpenAPI 3.0 5 | termsOfService: 'http://swagger.io/terms/' 6 | contact: 7 | email: apiteam@swagger.io 8 | license: 9 | name: Apache 2.0 10 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 11 | servers: 12 | - url: /v3 13 | paths: 14 | /pet: 15 | get: 16 | operationId: getPets 17 | summary: Get all pet from the store 18 | description: Get all pet from the store 19 | responses: 20 | '200': 21 | description: Successful operation 22 | x-typescript-params: |- 23 | { 24 | id: 'id_example', 25 | payment: { 26 | currency: 'USD', 27 | currency_rate: 0.69, 28 | total_amount: 49.99, 29 | reference: '123456', 30 | payment_method: 'Credit Card', 31 | payment_method_reference: '123456' 32 | } 33 | -------------------------------------------------------------------------------- /test/yaml-default-bug-numbers-x-tag/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | -------------------------------------------------------------------------------- /test/yaml-default-bug-numbers-x-tag/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | version: 1.0.6-SNAPSHOT 4 | title: Swagger Petstore - OpenAPI 3.0 5 | termsOfService: 'http://swagger.io/terms/' 6 | contact: 7 | email: apiteam@swagger.io 8 | license: 9 | name: Apache 2.0 10 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 11 | servers: 12 | - url: /v3 13 | paths: 14 | /pet: 15 | get: 16 | operationId: getPets 17 | summary: Get all pet from the store 18 | description: Get all pet from the store 19 | responses: 20 | '200': 21 | description: Successful operation 22 | x-typescript-params: |- 23 | { 24 | id: 'id_example', 25 | payment: { 26 | currency: 'USD', 27 | currency_rate: 0.69, 28 | total_amount: 49.99, 29 | reference: '123456', 30 | payment_method: 'Credit Card', 31 | payment_method_reference: '123456' 32 | } 33 | -------------------------------------------------------------------------------- /test/yaml-default-json/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.json 3 | -------------------------------------------------------------------------------- /test/yaml-default/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-default-3.1/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: 4 | - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | operationIds: 8 | - addPet 9 | - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-default-3.1/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | filterFile: customFilter.yaml 4 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flags-flagsValues/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: 4 | - x-visibility 5 | flagValues: 6 | - x-release: preview 7 | - x-release: dev 8 | tags: [] 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | 13 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flags-flagsValues/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flags/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: 4 | - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | #operationIds: 8 | # - addPet 9 | # - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flags/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array-taggroups/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: [] 4 | flagValues: 5 | - x-versions: 1.0 6 | - x-versions: 2.0 7 | tags: [] 8 | #operationIds: 9 | # - addPet 10 | # - findPetsByStatus 11 | 12 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array-taggroups/input.yaml: -------------------------------------------------------------------------------- 1 | x-tagGroups: 2 | - name: Tag Group 1 3 | x-test: stay 4 | x-versions: 5 | - 5.0 6 | tags: 7 | - Marco Polo 8 | - name: Tag Group 2 9 | x-test: filtered 10 | x-versions: 11 | - 1.0 12 | - 3.0 13 | - 5.0 14 | tags: 15 | - Colombus 16 | - name: Tag Group 3 17 | x-test: filtered 18 | x-versions: 19 | - 2.0 20 | tags: 21 | - John Cabot 22 | - name: Tag Group 4 23 | x-test: filtered 24 | x-versions: 25 | - 1.0 26 | - 3.0 27 | - 5.0 28 | tags: 29 | - Ferdinand Magellan 30 | - Hernan Cortes 31 | - Francis Drake 32 | - name: Tag Group 5 33 | x-test: stay 34 | x-versions: 35 | - 3.0 36 | - 5.0 37 | tags: 38 | - Amerigo Vespucci 39 | - name: Tag Group 6 40 | x-test: filtered 41 | x-versions: 42 | - 1.0 43 | tags: 44 | - Walter Raleigh 45 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array-taggroups/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array-taggroups/output.yaml: -------------------------------------------------------------------------------- 1 | x-tagGroups: 2 | - name: Tag Group 1 3 | x-test: stay 4 | x-versions: 5 | - 5 6 | tags: 7 | - Marco Polo 8 | - name: Tag Group 5 9 | x-test: stay 10 | x-versions: 11 | - 3 12 | - 5 13 | tags: 14 | - Amerigo Vespucci 15 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array-tags/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: [] 4 | flagValues: 5 | - x-release: preview 6 | - x-release: dev 7 | tags: [] 8 | #operationIds: 9 | # - addPet 10 | # - findPetsByStatus 11 | 12 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array-tags/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | tags: 3 | - name: pet 4 | x-release: dev 5 | description: Everything about your Pets 6 | - name: store 7 | x-release: preview 8 | description: Everything about your store 9 | - name: user 10 | description: Everything about your user 11 | - name: group 12 | description: Everything about groups 13 | - name: types 14 | x-release: preview 15 | description: Everything about types 16 | 17 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array-tags/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array-tags/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | tags: 3 | - name: user 4 | description: Everything about your user 5 | - name: group 6 | description: Everything about groups 7 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: [] 4 | flagValues: 5 | - x-versions: 1.0 6 | - x-versions: 2.0 7 | tags: [] 8 | #operationIds: 9 | # - addPet 10 | # - findPetsByStatus 11 | 12 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-array/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value-array/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | servers: 3 | - url: 'https://server-a' 4 | x-stage-e-exclude: 5 | - true 6 | - url: 'https://server-b' 7 | x-stage-e-exclude: 8 | - true 9 | - url: 'https://server-c' 10 | x-stage-e-exclude: 11 | - true 12 | - url: 'https://server-d' 13 | x-stage-e-exclude: 14 | - false 15 | - url: 'https://server-e' 16 | x-stage-e-exclude: 17 | - true -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value-array/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterSet: 5 | flagValues: 6 | - x-stage-e-exclude: true 7 | 8 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value-array/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | servers: 3 | - url: 'https://server-d' 4 | x-stage-e-exclude: 5 | - false 6 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value-taggroups/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: [] 4 | flagValues: 5 | - x-release: preview 6 | - x-release: dev 7 | tags: [] 8 | #operationIds: 9 | # - addPet 10 | # - findPetsByStatus 11 | 12 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value-taggroups/input.yaml: -------------------------------------------------------------------------------- 1 | x-tagGroups: 2 | - name: Tag Group 1 3 | x-test: stay 4 | x-release: live 5 | tags: 6 | - Marco Polo 7 | - name: Tag Group 2 8 | x-test: filtered 9 | x-release: dev 10 | tags: 11 | - Colombus 12 | - name: Tag Group 3 13 | x-test: stay 14 | x-release: live 15 | tags: 16 | - John Cabot 17 | - name: Tag Group 4 18 | x-test: filtered 19 | x-release: dev 20 | tags: 21 | - Ferdinand Magellan 22 | - Hernan Cortes 23 | - Francis Drake 24 | - name: Tag Group 5 25 | x-test: filtered 26 | x-release: preview 27 | tags: 28 | - Amerigo Vespucci 29 | - name: Tag Group 6 30 | x-test: stay 31 | x-release: live 32 | tags: 33 | - Walter Raleigh 34 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value-taggroups/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value-taggroups/output.yaml: -------------------------------------------------------------------------------- 1 | x-tagGroups: 2 | - name: Tag Group 1 3 | x-test: stay 4 | x-release: live 5 | tags: 6 | - Marco Polo 7 | - name: Tag Group 3 8 | x-test: stay 9 | x-release: live 10 | tags: 11 | - John Cabot 12 | - name: Tag Group 6 13 | x-test: stay 14 | x-release: live 15 | tags: 16 | - Walter Raleigh 17 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: [] 4 | flagValues: 5 | - x-version: 1.0 6 | - x-version: 3.0 7 | tags: [] 8 | #operationIds: 9 | # - addPet 10 | # - findPetsByStatus 11 | 12 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-flagsvalue-value/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-methods/customFilter.yaml: -------------------------------------------------------------------------------- 1 | methods: 2 | - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | #tags: [] 7 | #operationIds: 8 | # - addPet 9 | # - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-methods/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-operationids/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | operationIds: 8 | - addPet 9 | - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-operationids/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-operations-method-wildcard/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | operations: 8 | - '*::/pet' 9 | - 'GET::/pet/findByStatus' 10 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-operations-method-wildcard/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-operations-path-wildcard/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | operations: 8 | - GET::/pet/* 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-operations-path-wildcard/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-operations/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | operations: 8 | - POST::/pet 9 | - GET::/pet/findByStatus 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-operations/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-tags/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | tags: 7 | - store 8 | - user 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | 13 | -------------------------------------------------------------------------------- /test/yaml-filter-custom-tags/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-custom/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: 4 | - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | operationIds: 8 | - addPet 9 | - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-custom/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-default/customFilter.yaml: -------------------------------------------------------------------------------- 1 | methods: [] 2 | tags: [] 3 | operationIds: [] 4 | flags: [] 5 | flagValues: [] 6 | -------------------------------------------------------------------------------- /test/yaml-filter-default/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | filterFile: customFilter.yaml 4 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-all-methods/customFilter.yaml: -------------------------------------------------------------------------------- 1 | inverseMethods: 2 | - head 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-all-methods/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | servers: 6 | - url: https://api.example.com/v1 7 | paths: 8 | /resource: 9 | get: 10 | summary: Get a resource 11 | responses: 12 | '200': 13 | description: Successful response 14 | post: 15 | summary: Create a resource 16 | requestBody: 17 | description: New resource data 18 | required: true 19 | content: 20 | application/json: 21 | schema: 22 | type: object 23 | responses: 24 | '201': 25 | description: Resource created 26 | put: 27 | summary: Update a resource 28 | requestBody: 29 | description: Updated resource data 30 | required: true 31 | content: 32 | application/json: 33 | schema: 34 | type: object 35 | responses: 36 | '200': 37 | description: Resource updated 38 | patch: 39 | summary: Partially update a resource 40 | requestBody: 41 | description: Partial resource data 42 | required: true 43 | content: 44 | application/json: 45 | schema: 46 | type: object 47 | responses: 48 | '200': 49 | description: Resource partially updated 50 | delete: 51 | summary: Delete a resource 52 | responses: 53 | '204': 54 | description: Resource deleted 55 | head: 56 | summary: Get headers of a resource 57 | responses: 58 | '200': 59 | description: Successful response (headers only) 60 | options: 61 | summary: Get supported HTTP methods 62 | responses: 63 | '200': 64 | description: Successful response, listing allowed methods 65 | headers: 66 | Allow: 67 | description: Allowed HTTP methods 68 | schema: 69 | type: string 70 | trace: 71 | summary: Trace the path to a resource 72 | responses: 73 | '200': 74 | description: Trace successful 75 | 76 | components: {} 77 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-all-methods/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-all-methods/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | servers: 6 | - url: 'https://api.example.com/v1' 7 | paths: 8 | /resource: 9 | head: 10 | summary: Get headers of a resource 11 | responses: 12 | '200': 13 | description: Successful response (headers only) 14 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-flagsValues-minimal/customFilter.yaml: -------------------------------------------------------------------------------- 1 | inverseFlagValues: 2 | - x-visibility: public 3 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-flagsValues-minimal/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.1.0 2 | info: 3 | title: Entity Manager API 4 | version: 1.0.0 5 | paths: 6 | /entities: 7 | get: 8 | x-visibility: public 9 | operationId: entityIndex 10 | responses: 11 | '200': 12 | description: Ok 13 | content: 14 | application/json: 15 | schema: 16 | properties: 17 | results: 18 | type: array 19 | items: 20 | $ref: '#/components/schemas/Entity' 21 | /entities2: 22 | get: 23 | operationId: entityIndex 24 | responses: 25 | '200': 26 | description: Ok 27 | content: 28 | application/json: 29 | schema: 30 | properties: 31 | results: 32 | type: array 33 | items: 34 | $ref: '#/components/schemas/Entity' 35 | components: 36 | schemas: 37 | Entity: 38 | properties: 39 | uuid: 40 | type: string -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-flagsValues-minimal/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-flagsValues-minimal/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.1.0 2 | info: 3 | title: Entity Manager API 4 | version: 1.0.0 5 | paths: 6 | /entities: 7 | get: 8 | x-visibility: public 9 | operationId: entityIndex 10 | responses: 11 | '200': 12 | description: Ok 13 | content: 14 | application/json: 15 | schema: 16 | properties: 17 | results: 18 | type: array 19 | items: 20 | $ref: '#/components/schemas/Entity' 21 | components: 22 | schemas: 23 | Entity: 24 | properties: 25 | uuid: 26 | type: string 27 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-flagsValues/customFilter.yaml: -------------------------------------------------------------------------------- 1 | inverseFlagValues: 2 | - x-release: preview 3 | - x-release: dev 4 | unusedComponents: 5 | - schemas 6 | - parameters 7 | - examples 8 | - headers 9 | - requestBodies 10 | - responses 11 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-flagsValues/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-minimal/customFilter.yaml: -------------------------------------------------------------------------------- 1 | inverseFlags: 2 | - x-public 3 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-minimal/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.1.0 2 | info: 3 | title: Entity Manager API 4 | version: 1.0.0 5 | paths: 6 | /entities: 7 | get: 8 | x-public: true 9 | operationId: entityIndex 10 | responses: 11 | '200': 12 | description: Ok 13 | content: 14 | application/json: 15 | schema: 16 | properties: 17 | results: 18 | type: array 19 | items: 20 | $ref: '#/components/schemas/Entity' 21 | /entities2: 22 | get: 23 | operationId: entityIndex 24 | responses: 25 | '200': 26 | description: Ok 27 | content: 28 | application/json: 29 | schema: 30 | properties: 31 | results: 32 | type: array 33 | items: 34 | $ref: '#/components/schemas/Entity' 35 | components: 36 | schemas: 37 | Entity: 38 | properties: 39 | uuid: 40 | type: string -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-minimal/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags-minimal/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.1.0 2 | info: 3 | title: Entity Manager API 4 | version: 1.0.0 5 | paths: 6 | /entities: 7 | get: 8 | x-public: true 9 | operationId: entityIndex 10 | responses: 11 | '200': 12 | description: Ok 13 | content: 14 | application/json: 15 | schema: 16 | properties: 17 | results: 18 | type: array 19 | items: 20 | $ref: '#/components/schemas/Entity' 21 | components: 22 | schemas: 23 | Entity: 24 | properties: 25 | uuid: 26 | type: string 27 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags/customFilter.yaml: -------------------------------------------------------------------------------- 1 | inverseFlags: 2 | - x-visibility 3 | - x-stage 4 | unusedComponents: 5 | - schemas 6 | - parameters 7 | - examples 8 | - headers 9 | - requestBodies 10 | - responses 11 | 12 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flags/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flagsvalue-value-array/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | servers: 3 | - url: 'https://server-a' 4 | x-stage: 5 | - a 6 | - url: 'https://server-b' 7 | x-stage: 8 | - b 9 | - url: 'https://server-c' 10 | x-stage: 11 | - c 12 | - url: 'https://server-d' 13 | x-stage: 14 | - d 15 | - url: 'https://server-e' 16 | x-stage: 17 | - e -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flagsvalue-value-array/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterSet: 5 | inverseFlagValues: 6 | - x-stage: e 7 | 8 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-flagsvalue-value-array/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | servers: 3 | - url: 'https://server-e' 4 | x-stage: 5 | - e -------------------------------------------------------------------------------- /test/yaml-filter-inverse-methods/customFilter.yaml: -------------------------------------------------------------------------------- 1 | inverseMethods: 2 | - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | #tags: [] 7 | #operationIds: 8 | # - addPet 9 | # - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-methods/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-operationids-free-form/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | inverseOperationIds: 8 | - GetCatIndicesWithIndex 9 | 10 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-operationids-free-form/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | title: OpenSearch 4 | version: '2021-11-23' 5 | paths: 6 | /_cat/indices: 7 | get: 8 | description: 'Returns information about indices: number of primaries and replicas, document counts, disk size, etc.' 9 | operationId: GetCatIndices 10 | parameters: 11 | - name: bytes 12 | in: query 13 | schema: 14 | type: number 15 | nullable: true 16 | - name: expand_wildcards 17 | in: query 18 | schema: 19 | $ref: '#/components/schemas/ExpandWildcards' 20 | - name: health 21 | in: query 22 | schema: 23 | $ref: '#/components/schemas/HealthStatus' 24 | - name: include_unloaded_segments 25 | in: query 26 | schema: 27 | type: boolean 28 | nullable: true 29 | - name: pri 30 | in: query 31 | schema: 32 | type: boolean 33 | nullable: true 34 | - name: master_timeout 35 | in: query 36 | schema: 37 | type: string 38 | pattern: '^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$' 39 | - name: timeout 40 | in: query 41 | schema: 42 | type: string 43 | pattern: '^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$' 44 | responses: 45 | '200': 46 | description: GetCatIndices 200 response 47 | content: 48 | application/json: 49 | schema: 50 | $ref: '#/components/schemas/GetCatIndicesOutputPayload' 51 | '/_cat/indices/{index}': 52 | get: 53 | description: 'Returns information about indices: number of primaries and replicas, document counts, disk size, etc.' 54 | operationId: GetCatIndicesWithIndex 55 | parameters: 56 | - name: index 57 | in: path 58 | schema: 59 | type: string 60 | pattern: '^[^+_\-\.][^\\, /*?"<>| ,#\nA-Z]+$' 61 | required: true 62 | example: books 63 | - name: bytes 64 | in: query 65 | schema: 66 | type: number 67 | nullable: true 68 | - name: expand_wildcards 69 | in: query 70 | schema: 71 | $ref: '#/components/schemas/ExpandWildcards' 72 | - name: health 73 | in: query 74 | schema: 75 | $ref: '#/components/schemas/HealthStatus' 76 | - name: include_unloaded_segments 77 | in: query 78 | schema: 79 | type: boolean 80 | nullable: true 81 | - name: pri 82 | in: query 83 | schema: 84 | type: boolean 85 | nullable: true 86 | - name: master_timeout 87 | in: query 88 | schema: 89 | type: string 90 | pattern: '^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$' 91 | - name: timeout 92 | in: query 93 | schema: 94 | type: string 95 | pattern: '^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$' 96 | responses: 97 | '200': 98 | description: GetCatIndicesWithIndex 200 response 99 | content: 100 | application/json: 101 | schema: 102 | $ref: '#/components/schemas/GetCatIndicesWithIndexOutputPayload' 103 | components: 104 | schemas: 105 | ExpandWildcards: 106 | type: string 107 | enum: 108 | - all 109 | - open 110 | - closed 111 | - hidden 112 | - none 113 | GetCatIndicesOutputPayload: {} 114 | GetCatIndicesWithIndexOutputPayload: {} 115 | HealthStatus: 116 | type: string 117 | enum: 118 | - green 119 | - yellow 120 | - red 121 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-operationids-free-form/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-operationids-free-form/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | title: OpenSearch 4 | version: '2021-11-23' 5 | paths: 6 | '/_cat/indices/{index}': 7 | get: 8 | description: 'Returns information about indices: number of primaries and replicas, document counts, disk size, etc.' 9 | operationId: GetCatIndicesWithIndex 10 | parameters: 11 | - name: index 12 | in: path 13 | schema: 14 | type: string 15 | pattern: '^[^+_\-\.][^\\, /*?"<>| ,#\nA-Z]+$' 16 | required: true 17 | example: books 18 | - name: bytes 19 | in: query 20 | schema: 21 | type: number 22 | nullable: true 23 | - name: expand_wildcards 24 | in: query 25 | schema: 26 | $ref: '#/components/schemas/ExpandWildcards' 27 | - name: health 28 | in: query 29 | schema: 30 | $ref: '#/components/schemas/HealthStatus' 31 | - name: include_unloaded_segments 32 | in: query 33 | schema: 34 | type: boolean 35 | nullable: true 36 | - name: pri 37 | in: query 38 | schema: 39 | type: boolean 40 | nullable: true 41 | - name: master_timeout 42 | in: query 43 | schema: 44 | type: string 45 | pattern: '^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$' 46 | - name: timeout 47 | in: query 48 | schema: 49 | type: string 50 | pattern: '^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$' 51 | responses: 52 | '200': 53 | description: GetCatIndicesWithIndex 200 response 54 | content: 55 | application/json: 56 | schema: 57 | $ref: '#/components/schemas/GetCatIndicesWithIndexOutputPayload' 58 | components: 59 | schemas: 60 | ExpandWildcards: 61 | type: string 62 | enum: 63 | - all 64 | - open 65 | - closed 66 | - hidden 67 | - none 68 | GetCatIndicesOutputPayload: {} 69 | GetCatIndicesWithIndexOutputPayload: {} 70 | HealthStatus: 71 | type: string 72 | enum: 73 | - green 74 | - yellow 75 | - red 76 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-operationids/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | flagValues: [] 6 | tags: [] 7 | inverseOperationIds: 8 | - addPet 9 | - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-operationids/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-request-content/customFilter.yaml: -------------------------------------------------------------------------------- 1 | inverseRequestContent: 2 | - application/json 3 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-request-content/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | servers: 3 | - url: /v3 4 | info: 5 | version: 1.0.6-SNAPSHOT 6 | title: Swagger Petstore - OpenAPI 3.0 7 | paths: 8 | /pet: 9 | post: 10 | summary: Add a new pet to the store 11 | description: Add a new pet to the store 12 | operationId: addPet 13 | x-visibility: true 14 | requestBody: 15 | description: Create a new pet in the store 16 | required: true 17 | content: 18 | application/json: 19 | schema: 20 | $ref: '#/components/schemas/Pet' 21 | application/xml: 22 | schema: 23 | $ref: '#/components/schemas/Pet' 24 | application/x-www-form-urlencoded: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | responses: 28 | '200': 29 | description: Successful operation 30 | content: 31 | application/xml: 32 | schema: 33 | $ref: '#/components/schemas/Pet' 34 | application/json: 35 | schema: 36 | $ref: '#/components/schemas/Pet' 37 | '405': 38 | description: Invalid input 39 | security: 40 | - petstore_auth: 41 | - 'write:pets' 42 | - 'read:pets' 43 | components: 44 | schemas: 45 | Category: 46 | x-swagger-router-model: io.swagger.petstore.model.Category 47 | properties: 48 | id: 49 | type: integer 50 | format: int64 51 | example: 1 52 | name: 53 | type: string 54 | example: Dogs 55 | xml: 56 | name: category 57 | type: object 58 | Pet: 59 | x-swagger-router-model: io.swagger.petstore.model.Pet 60 | required: 61 | - name 62 | - photoUrls 63 | properties: 64 | id: 65 | type: integer 66 | format: int64 67 | example: 10 68 | name: 69 | type: string 70 | example: doggie 71 | category: 72 | $ref: '#/components/schemas/Category' 73 | photoUrls: 74 | type: array 75 | xml: 76 | wrapped: true 77 | items: 78 | type: string 79 | xml: 80 | name: photoUrl 81 | status: 82 | type: string 83 | description: pet status in the store 84 | enum: 85 | - available 86 | - pending 87 | - sold 88 | xml: 89 | name: pet 90 | type: object 91 | securitySchemes: 92 | petstore_auth: 93 | type: oauth2 94 | flows: 95 | implicit: 96 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 97 | scopes: 98 | 'write:pets': modify pets in your account 99 | 'read:pets': read your pets 100 | api_key: 101 | type: apiKey 102 | name: api_key 103 | in: header 104 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-request-content/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-request-content/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | servers: 3 | - url: /v3 4 | info: 5 | version: 1.0.6-SNAPSHOT 6 | title: Swagger Petstore - OpenAPI 3.0 7 | paths: 8 | /pet: 9 | post: 10 | summary: Add a new pet to the store 11 | description: Add a new pet to the store 12 | operationId: addPet 13 | x-visibility: true 14 | requestBody: 15 | description: Create a new pet in the store 16 | required: true 17 | content: 18 | application/json: 19 | schema: 20 | $ref: '#/components/schemas/Pet' 21 | responses: 22 | '200': 23 | description: Successful operation 24 | content: 25 | application/xml: 26 | schema: 27 | $ref: '#/components/schemas/Pet' 28 | application/json: 29 | schema: 30 | $ref: '#/components/schemas/Pet' 31 | '405': 32 | description: Invalid input 33 | security: 34 | - petstore_auth: 35 | - 'write:pets' 36 | - 'read:pets' 37 | components: 38 | schemas: 39 | Category: 40 | x-swagger-router-model: io.swagger.petstore.model.Category 41 | properties: 42 | id: 43 | type: integer 44 | format: int64 45 | example: 1 46 | name: 47 | type: string 48 | example: Dogs 49 | xml: 50 | name: category 51 | type: object 52 | Pet: 53 | x-swagger-router-model: io.swagger.petstore.model.Pet 54 | required: 55 | - name 56 | - photoUrls 57 | properties: 58 | id: 59 | type: integer 60 | format: int64 61 | example: 10 62 | name: 63 | type: string 64 | example: doggie 65 | category: 66 | $ref: '#/components/schemas/Category' 67 | photoUrls: 68 | type: array 69 | xml: 70 | wrapped: true 71 | items: 72 | type: string 73 | xml: 74 | name: photoUrl 75 | status: 76 | type: string 77 | description: pet status in the store 78 | enum: 79 | - available 80 | - pending 81 | - sold 82 | xml: 83 | name: pet 84 | type: object 85 | securitySchemes: 86 | petstore_auth: 87 | type: oauth2 88 | flows: 89 | implicit: 90 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 91 | scopes: 92 | 'write:pets': modify pets in your account 93 | 'read:pets': read your pets 94 | api_key: 95 | type: apiKey 96 | name: api_key 97 | in: header 98 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-response-content/customFilter.yaml: -------------------------------------------------------------------------------- 1 | inverseResponseContent: 2 | - application/json -------------------------------------------------------------------------------- /test/yaml-filter-inverse-response-content/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-tags/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | inverseTags: 7 | - store 8 | - user 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | 13 | -------------------------------------------------------------------------------- /test/yaml-filter-inverse-tags/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-markdown-comments/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | tags: 7 | - store 8 | # - user 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | -------------------------------------------------------------------------------- /test/yaml-filter-markdown-comments/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-refs/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: 4 | - x-internal-field 5 | flagValues: [] 6 | tags: [] 7 | #operationIds: 8 | # - addPet 9 | # - findPetsByStatus 10 | 11 | -------------------------------------------------------------------------------- /test/yaml-filter-refs/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | paths: 3 | /payment_requests: 4 | post: 5 | operationId: CreatePaymentRequest 6 | summary: Create Payment Request 7 | parameters: 8 | - $ref: '#/components/parameters/IdempotencyKey' 9 | x-internal-field: true 10 | - $ref: '#/components/parameters/BusinessID' 11 | x-internal-field: true 12 | - $ref: '#/components/parameters/CallbackURL' 13 | - $ref: '#/components/parameters/ServiceID' 14 | x-internal-field: true 15 | 16 | components: 17 | schemas: 18 | Pet: 19 | properties: 20 | id: 21 | $ref: '#/components/schemas/Id' 22 | category: 23 | $ref: '#/components/schemas/Category' 24 | x-internal-field: true 25 | -------------------------------------------------------------------------------- /test/yaml-filter-refs/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-refs/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | paths: 3 | /payment_requests: 4 | post: 5 | operationId: CreatePaymentRequest 6 | summary: Create Payment Request 7 | parameters: 8 | - $ref: '#/components/parameters/CallbackURL' 9 | components: 10 | schemas: 11 | Pet: 12 | properties: 13 | id: 14 | $ref: '#/components/schemas/Id' 15 | -------------------------------------------------------------------------------- /test/yaml-filter-replace-text/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | #tags: 7 | # - store 8 | # - user 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | textReplace: 13 | - searchFor: 'Pets' 14 | replaceWith: 'Animals' 15 | - searchFor: 'Pet Store' 16 | replaceWith: 'Animal Store' 17 | - searchFor: 'swagger.io' 18 | replaceWith: 'openapis.org/' 19 | - searchFor: 'http://www.apache.org/licenses/LICENSE-2.0.html' 20 | replaceWith: 'https://www.apache.org/licenses/LICENSE-2.0.html' 21 | - searchFor: '?.[]*(){}' 22 | replaceWith: 'ABCDE' 23 | -------------------------------------------------------------------------------- /test/yaml-filter-replace-text/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-request-content/customFilter.yaml: -------------------------------------------------------------------------------- 1 | requestContent: 2 | - application/json 3 | -------------------------------------------------------------------------------- /test/yaml-filter-request-content/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | servers: 3 | - url: /v3 4 | info: 5 | version: 1.0.6-SNAPSHOT 6 | title: Swagger Petstore - OpenAPI 3.0 7 | paths: 8 | /pet: 9 | post: 10 | summary: Add a new pet to the store 11 | description: Add a new pet to the store 12 | operationId: addPet 13 | x-visibility: true 14 | requestBody: 15 | description: Create a new pet in the store 16 | required: true 17 | content: 18 | application/json: 19 | schema: 20 | $ref: '#/components/schemas/Pet' 21 | application/xml: 22 | schema: 23 | $ref: '#/components/schemas/Pet' 24 | application/x-www-form-urlencoded: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | responses: 28 | '200': 29 | description: Successful operation 30 | content: 31 | application/xml: 32 | schema: 33 | $ref: '#/components/schemas/Pet' 34 | application/json: 35 | schema: 36 | $ref: '#/components/schemas/Pet' 37 | '405': 38 | description: Invalid input 39 | security: 40 | - petstore_auth: 41 | - 'write:pets' 42 | - 'read:pets' 43 | components: 44 | schemas: 45 | Category: 46 | x-swagger-router-model: io.swagger.petstore.model.Category 47 | properties: 48 | id: 49 | type: integer 50 | format: int64 51 | example: 1 52 | name: 53 | type: string 54 | example: Dogs 55 | xml: 56 | name: category 57 | type: object 58 | Pet: 59 | x-swagger-router-model: io.swagger.petstore.model.Pet 60 | required: 61 | - name 62 | - photoUrls 63 | properties: 64 | id: 65 | type: integer 66 | format: int64 67 | example: 10 68 | name: 69 | type: string 70 | example: doggie 71 | category: 72 | $ref: '#/components/schemas/Category' 73 | photoUrls: 74 | type: array 75 | xml: 76 | wrapped: true 77 | items: 78 | type: string 79 | xml: 80 | name: photoUrl 81 | status: 82 | type: string 83 | description: pet status in the store 84 | enum: 85 | - available 86 | - pending 87 | - sold 88 | xml: 89 | name: pet 90 | type: object 91 | securitySchemes: 92 | petstore_auth: 93 | type: oauth2 94 | flows: 95 | implicit: 96 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 97 | scopes: 98 | 'write:pets': modify pets in your account 99 | 'read:pets': read your pets 100 | api_key: 101 | type: apiKey 102 | name: api_key 103 | in: header 104 | -------------------------------------------------------------------------------- /test/yaml-filter-request-content/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-request-content/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | servers: 3 | - url: /v3 4 | info: 5 | version: 1.0.6-SNAPSHOT 6 | title: Swagger Petstore - OpenAPI 3.0 7 | paths: 8 | /pet: 9 | post: 10 | summary: Add a new pet to the store 11 | description: Add a new pet to the store 12 | operationId: addPet 13 | x-visibility: true 14 | requestBody: 15 | description: Create a new pet in the store 16 | required: true 17 | content: 18 | application/xml: 19 | schema: 20 | $ref: '#/components/schemas/Pet' 21 | application/x-www-form-urlencoded: 22 | schema: 23 | $ref: '#/components/schemas/Pet' 24 | responses: 25 | '200': 26 | description: Successful operation 27 | content: 28 | application/xml: 29 | schema: 30 | $ref: '#/components/schemas/Pet' 31 | application/json: 32 | schema: 33 | $ref: '#/components/schemas/Pet' 34 | '405': 35 | description: Invalid input 36 | security: 37 | - petstore_auth: 38 | - 'write:pets' 39 | - 'read:pets' 40 | components: 41 | schemas: 42 | Category: 43 | x-swagger-router-model: io.swagger.petstore.model.Category 44 | properties: 45 | id: 46 | type: integer 47 | format: int64 48 | example: 1 49 | name: 50 | type: string 51 | example: Dogs 52 | xml: 53 | name: category 54 | type: object 55 | Pet: 56 | x-swagger-router-model: io.swagger.petstore.model.Pet 57 | required: 58 | - name 59 | - photoUrls 60 | properties: 61 | id: 62 | type: integer 63 | format: int64 64 | example: 10 65 | name: 66 | type: string 67 | example: doggie 68 | category: 69 | $ref: '#/components/schemas/Category' 70 | photoUrls: 71 | type: array 72 | xml: 73 | wrapped: true 74 | items: 75 | type: string 76 | xml: 77 | name: photoUrl 78 | status: 79 | type: string 80 | description: pet status in the store 81 | enum: 82 | - available 83 | - pending 84 | - sold 85 | xml: 86 | name: pet 87 | type: object 88 | securitySchemes: 89 | petstore_auth: 90 | type: oauth2 91 | flows: 92 | implicit: 93 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 94 | scopes: 95 | 'write:pets': modify pets in your account 96 | 'read:pets': read your pets 97 | api_key: 98 | type: apiKey 99 | name: api_key 100 | in: header 101 | -------------------------------------------------------------------------------- /test/yaml-filter-response-content/customFilter.yaml: -------------------------------------------------------------------------------- 1 | responseContent: 2 | - application/json -------------------------------------------------------------------------------- /test/yaml-filter-response-content/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-security-empty/customFilter.yaml: -------------------------------------------------------------------------------- 1 | tags: [] 2 | operationIds: [] 3 | operations: [] 4 | flags: [] 5 | flagValues: [], 6 | unusedComponents: [] 7 | stripFlags: [] 8 | -------------------------------------------------------------------------------- /test/yaml-filter-security-empty/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | description: Sample 4 | version: 1.0.6-SNAPSHOT 5 | title: Swagger Petstore - OpenAPI 3.0 6 | termsOfService: 'http://swagger.io/terms/' 7 | contact: 8 | email: apiteam@swagger.io 9 | license: 10 | name: Apache 2.0 11 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 12 | servers: 13 | - url: /v3 14 | paths: 15 | /pet: 16 | post: 17 | operationId: addPet 18 | summary: Add a new pet to the store 19 | description: Add a new pet to the store 20 | requestBody: 21 | description: Create a new pet in the store 22 | content: 23 | application/json: 24 | schema: 25 | $ref: '#/components/schemas/Pet' 26 | required: true 27 | responses: 28 | '200': 29 | description: Successful operation 30 | content: 31 | application/json: 32 | schema: 33 | $ref: '#/components/schemas/Pet' 34 | '405': 35 | description: Invalid input 36 | security: 37 | - BasicAuth: [] 38 | - {} 39 | tags: 40 | - pet 41 | x-visibility: true 42 | components: 43 | schemas: 44 | Pet: 45 | type: object 46 | properties: 47 | id: 48 | type: integer 49 | format: int64 50 | example: 10 51 | name: 52 | type: string 53 | example: doggie 54 | category: 55 | $ref: '#/components/schemas/Category' 56 | photoUrls: 57 | type: array 58 | items: 59 | type: string 60 | xml: 61 | name: photoUrl 62 | xml: 63 | wrapped: true 64 | tags: 65 | type: array 66 | items: 67 | $ref: '#/components/schemas/Tag' 68 | xml: 69 | wrapped: true 70 | status: 71 | description: pet status in the store 72 | type: string 73 | enum: 74 | - available 75 | - pending 76 | - sold 77 | required: 78 | - name 79 | - photoUrls 80 | x-swagger-router-model: io.swagger.petstore.model.Pet 81 | xml: 82 | name: pet 83 | Category: 84 | type: object 85 | properties: 86 | id: 87 | type: integer 88 | format: int64 89 | example: 1 90 | name: 91 | type: string 92 | example: Dogs 93 | xml: 94 | name: category 95 | Tag: 96 | type: object 97 | properties: 98 | id: 99 | type: integer 100 | format: int64 101 | name: 102 | type: string 103 | xml: 104 | name: tag 105 | ApiResponse: 106 | type: object 107 | properties: 108 | code: 109 | type: integer 110 | format: int32 111 | type: 112 | type: string 113 | message: 114 | type: string 115 | xml: 116 | name: '##default' 117 | securitySchemes: 118 | petstore_auth: 119 | type: oauth2 120 | flows: 121 | implicit: 122 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 123 | scopes: 124 | 'write:pets': modify pets in your account 125 | 'read:pets': read your pets 126 | api_key: 127 | type: apiKey 128 | name: api_key 129 | in: header 130 | tags: 131 | - name: pet 132 | description: Everything about your Pets 133 | externalDocs: 134 | description: Find out more about Swagger 135 | url: 'http://swagger.io' 136 | security: 137 | - BasicAuth: [] 138 | - {} 139 | -------------------------------------------------------------------------------- /test/yaml-filter-security-empty/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | filterFile: customFilter.yaml 4 | -------------------------------------------------------------------------------- /test/yaml-filter-security-empty/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | description: Sample 4 | version: 1.0.6-SNAPSHOT 5 | title: Swagger Petstore - OpenAPI 3.0 6 | termsOfService: 'http://swagger.io/terms/' 7 | contact: 8 | email: apiteam@swagger.io 9 | license: 10 | name: Apache 2.0 11 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 12 | servers: 13 | - url: /v3 14 | paths: 15 | /pet: 16 | post: 17 | operationId: addPet 18 | summary: Add a new pet to the store 19 | description: Add a new pet to the store 20 | requestBody: 21 | description: Create a new pet in the store 22 | required: true 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | responses: 28 | '200': 29 | description: Successful operation 30 | content: 31 | application/json: 32 | schema: 33 | $ref: '#/components/schemas/Pet' 34 | '405': 35 | description: Invalid input 36 | security: 37 | - BasicAuth: [] 38 | - {} 39 | tags: 40 | - pet 41 | x-visibility: true 42 | components: 43 | schemas: 44 | Pet: 45 | type: object 46 | properties: 47 | id: 48 | type: integer 49 | format: int64 50 | example: 10 51 | name: 52 | type: string 53 | example: doggie 54 | category: 55 | $ref: '#/components/schemas/Category' 56 | photoUrls: 57 | type: array 58 | items: 59 | type: string 60 | xml: 61 | name: photoUrl 62 | xml: 63 | wrapped: true 64 | tags: 65 | type: array 66 | items: 67 | $ref: '#/components/schemas/Tag' 68 | xml: 69 | wrapped: true 70 | status: 71 | description: pet status in the store 72 | type: string 73 | enum: 74 | - available 75 | - pending 76 | - sold 77 | required: 78 | - name 79 | - photoUrls 80 | x-swagger-router-model: io.swagger.petstore.model.Pet 81 | xml: 82 | name: pet 83 | Category: 84 | type: object 85 | properties: 86 | id: 87 | type: integer 88 | format: int64 89 | example: 1 90 | name: 91 | type: string 92 | example: Dogs 93 | xml: 94 | name: category 95 | Tag: 96 | type: object 97 | properties: 98 | id: 99 | type: integer 100 | format: int64 101 | name: 102 | type: string 103 | xml: 104 | name: tag 105 | ApiResponse: 106 | type: object 107 | properties: 108 | code: 109 | type: integer 110 | format: int32 111 | type: 112 | type: string 113 | message: 114 | type: string 115 | xml: 116 | name: '##default' 117 | securitySchemes: 118 | petstore_auth: 119 | type: oauth2 120 | flows: 121 | implicit: 122 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 123 | scopes: 124 | 'write:pets': modify pets in your account 125 | 'read:pets': read your pets 126 | api_key: 127 | type: apiKey 128 | name: api_key 129 | in: header 130 | tags: 131 | - name: pet 132 | description: Everything about your Pets 133 | externalDocs: 134 | description: Find out more about Swagger 135 | url: 'http://swagger.io' 136 | security: 137 | - BasicAuth: [] 138 | - {} 139 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components-path/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | #tags: 7 | # - store 8 | # - user 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | unusedComponents: 13 | - schemas 14 | - parameters 15 | - examples 16 | - headers 17 | - requestBodies 18 | - responses 19 | 20 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components-path/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components-path/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Test API 4 | version: 1.0.0 5 | paths: 6 | /pets: 7 | get: 8 | summary: List all pets 9 | parameters: 10 | - $ref: '#/components/parameters/ParamUsed' 11 | responses: 12 | '200': 13 | description: A list of pets 14 | headers: 15 | X-RateLimit: 16 | $ref: '#/components/headers/HeaderUsed' 17 | content: 18 | application/json: 19 | schema: 20 | type: array 21 | items: 22 | $ref: '#/components/schemas/SchemaUsed' 23 | examples: 24 | petExample: 25 | $ref: '#/components/examples/ExampleUsed' 26 | post: 27 | summary: Add a new pet 28 | requestBody: 29 | $ref: '#/components/requestBodies/RequestBodyUsed' 30 | responses: 31 | '201': 32 | $ref: '#/components/responses/ResponseUsed' 33 | /users: 34 | get: 35 | summary: Get all users 36 | responses: 37 | '200': 38 | description: OK 39 | content: 40 | application/json: 41 | schema: 42 | $ref: '#/components/schemas/User' 43 | components: 44 | schemas: 45 | User: 46 | type: object 47 | properties: 48 | id: 49 | type: integer 50 | name: 51 | type: string 52 | SchemaUsed: 53 | type: object 54 | properties: 55 | id: 56 | type: integer 57 | responses: 58 | ResponseUsed: 59 | description: Created successfully 60 | parameters: 61 | ParamUsed: 62 | name: status 63 | in: query 64 | schema: 65 | type: string 66 | examples: 67 | ExampleUsed: 68 | summary: A single pet 69 | value: 70 | id: 1 71 | requestBodies: 72 | RequestBodyUsed: 73 | description: New pet to add 74 | content: 75 | application/json: 76 | schema: 77 | $ref: '#/components/schemas/SchemaUsed' 78 | headers: 79 | HeaderUsed: 80 | description: Rate limit info 81 | schema: 82 | type: integer 83 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components-period/customFilter.yaml: -------------------------------------------------------------------------------- 1 | unusedComponents: 2 | - schemas 3 | - parameters 4 | - examples 5 | - headers 6 | - requestBodies 7 | - responses 8 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components-period/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | paths: 3 | /user: 4 | get: 5 | tags: 6 | - user 7 | summary: Get user 8 | description: This can only be done by the logged in user. 9 | operationId: getUser 10 | responses: 11 | default: 12 | description: successful operation 13 | content: 14 | application/json: 15 | schema: 16 | $ref: '#/components/schemas/Token.Id' 17 | components: 18 | schemas: 19 | Token.Id: 20 | properties: 21 | id: 22 | type: integer 23 | format: int64 24 | example: 10 25 | User: 26 | x-swagger-router-model: io.swagger.petstore.model.User 27 | properties: 28 | id: 29 | type: integer 30 | format: int64 31 | example: 10 32 | username: 33 | type: string 34 | example: theUser 35 | firstName: 36 | type: string 37 | example: John 38 | lastName: 39 | type: string 40 | example: James 41 | email: 42 | type: string 43 | example: john@email.com 44 | password: 45 | type: string 46 | example: 12345 47 | phone: 48 | type: string 49 | example: 12345 50 | userStatus: 51 | type: integer 52 | format: int32 53 | example: 1 54 | description: User Status 55 | xml: 56 | name: user 57 | type: object 58 | parameters: 59 | username: 60 | name: username 61 | in: path 62 | description: name that need to be deleted 63 | required: true 64 | schema: 65 | type: string 66 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components-period/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components-period/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | paths: 3 | /user: 4 | get: 5 | tags: 6 | - user 7 | summary: Get user 8 | description: This can only be done by the logged in user. 9 | operationId: getUser 10 | responses: 11 | default: 12 | description: successful operation 13 | content: 14 | application/json: 15 | schema: 16 | $ref: '#/components/schemas/Token.Id' 17 | components: 18 | schemas: 19 | Token.Id: 20 | properties: 21 | id: 22 | type: integer 23 | format: int64 24 | example: 10 25 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | #tags: 7 | # - store 8 | # - user 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | unusedComponents: 13 | - schemas 14 | - parameters 15 | - examples 16 | - headers 17 | - requestBodies 18 | - responses 19 | 20 | -------------------------------------------------------------------------------- /test/yaml-filter-unused-components/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite-casing/customCasing.yaml: -------------------------------------------------------------------------------- 1 | operationId: camelCase 2 | 3 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite-casing/customGenerate.yaml: -------------------------------------------------------------------------------- 1 | operationIdTemplate: _ 2 | 3 | overwriteExisting: true 4 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite-casing/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /trains: 7 | get: 8 | summary: Retrieve a list of trains 9 | operationId: getTrains 10 | responses: 11 | '200': 12 | description: A list of trains 13 | post: 14 | summary: Create a new train 15 | responses: 16 | '201': 17 | description: Train created 18 | 19 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite-casing/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | casingFile: customCasing.yaml 4 | generateFile: customGenerate.yaml 5 | 6 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite-casing/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /trains: 7 | get: 8 | operationId: getTrains 9 | summary: Retrieve a list of trains 10 | responses: 11 | '200': 12 | description: A list of trains 13 | post: 14 | operationId: postTrains 15 | summary: Create a new train 16 | responses: 17 | '201': 18 | description: Train created 19 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite/customGenerate.yaml: -------------------------------------------------------------------------------- 1 | operationIdTemplate: _ 2 | 3 | overwriteExisting: true 4 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /trains: 7 | get: 8 | summary: Retrieve a list of trains 9 | operationId: getTrains 10 | responses: 11 | '200': 12 | description: A list of trains 13 | post: 14 | summary: Create a new train 15 | responses: 16 | '201': 17 | description: Train created 18 | 19 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | generateFile: customGenerate.yaml 5 | 6 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId-overwrite/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /trains: 7 | get: 8 | summary: Retrieve a list of trains 9 | operationId: get_trains 10 | responses: 11 | '200': 12 | description: A list of trains 13 | post: 14 | summary: Create a new train 15 | responses: 16 | '201': 17 | description: Train created 18 | operationId: post_trains 19 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId/customGenerate.yaml: -------------------------------------------------------------------------------- 1 | operationIdTemplate: _ 2 | 3 | overwriteExisting: false 4 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /trains: 7 | get: 8 | summary: Retrieve a list of trains 9 | operationId: getTrains 10 | responses: 11 | '200': 12 | description: A list of trains 13 | post: 14 | summary: Create a new train 15 | responses: 16 | '201': 17 | description: Train created 18 | 19 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | generateFile: customGenerate.yaml 5 | 6 | -------------------------------------------------------------------------------- /test/yaml-generate-operationId/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /trains: 7 | get: 8 | summary: Retrieve a list of trains 9 | operationId: getTrains 10 | responses: 11 | '200': 12 | description: A list of trains 13 | post: 14 | summary: Create a new train 15 | responses: 16 | '201': 17 | description: Train created 18 | operationId: post_trains 19 | -------------------------------------------------------------------------------- /test/yaml-linewidth/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | lineWidth: 60 5 | -------------------------------------------------------------------------------- /test/yaml-no-sort-keep-comments/customFilter.yaml: -------------------------------------------------------------------------------- 1 | methods: 2 | - post 3 | -------------------------------------------------------------------------------- /test/yaml-no-sort-keep-comments/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /example: 7 | get: # This is a comment in the OpenAPI file 8 | description: The description of the example # This is a comment in the OpenAPI file 9 | # This is a comment in the OpenAPI file 10 | summary: Returns an example 11 | # A more detailed description of the operation 12 | responses: 13 | '200': 14 | description: A successful response 15 | post: # This is a comment in the OpenAPI file 16 | summary: Creates an example 17 | # A more detailed description of the operation 18 | responses: 19 | '200': 20 | description: A successful response 21 | -------------------------------------------------------------------------------- /test/yaml-no-sort-keep-comments/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | keepComments: true 5 | filterFile: customFilter.yaml 6 | -------------------------------------------------------------------------------- /test/yaml-no-sort-keep-comments/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /example: 7 | get: # This is a comment in the OpenAPI file 8 | description: The description of the example # This is a comment in the OpenAPI file 9 | # This is a comment in the OpenAPI file 10 | summary: Returns an example 11 | # A more detailed description of the operation 12 | responses: 13 | '200': 14 | description: A successful response 15 | -------------------------------------------------------------------------------- /test/yaml-no-sort/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-no-filter/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | info: 3 | title: Test 4 | version: 1.0.0 5 | description: Test 6 | servers: 7 | - url: https://example.de/test 8 | security: 9 | - bearerToken: [ ] 10 | tags: 11 | - name: Test API 12 | paths: 13 | /test: 14 | get: 15 | summary: Get test 16 | tags: 17 | - Test API 18 | responses: 19 | '200': 20 | description: OK 21 | content: 22 | application/json: 23 | schema: 24 | type: object 25 | properties: 26 | test-value: 27 | type: string 28 | examples: { } 29 | operationId: get-test 30 | description: Test 31 | securitySchemes: 32 | bearerToken: 33 | type: http 34 | scheme: bearer 35 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-no-filter/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-no-filter/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | info: 3 | title: Test 4 | version: 1.0.0 5 | description: Test 6 | servers: 7 | - url: 'https://example.de/test' 8 | security: 9 | - bearerToken: [] 10 | tags: 11 | - name: Test API 12 | paths: 13 | /test: 14 | get: 15 | summary: Get test 16 | tags: 17 | - Test API 18 | responses: 19 | '200': 20 | description: OK 21 | content: 22 | application/json: 23 | schema: 24 | type: object 25 | properties: 26 | test-value: 27 | type: string 28 | examples: {} 29 | operationId: get-test 30 | description: Test 31 | securitySchemes: 32 | bearerToken: 33 | type: http 34 | scheme: bearer 35 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-default/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | description: Sample 4 | version: 1.0.6-SNAPSHOT 5 | title: Swagger Petstore - OpenAPI 3.0 6 | termsOfService: 'http://swagger.io/terms/' 7 | contact: 8 | email: apiteam@swagger.io 9 | license: 10 | name: Apache 2.0 11 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 12 | servers: 13 | - url: /v3 14 | paths: 15 | /pet: 16 | post: 17 | operationId: addPet 18 | summary: Add a new pet to the store 19 | description: Add a new pet to the store 20 | requestBody: 21 | description: Create a new pet in the store 22 | required: true 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | examples: 28 | example1: 29 | key1: { } # should be kept 30 | key2: 31 | key: { } # should be kept 32 | example2: 33 | key1: { } # should be kept 34 | key2: 35 | key: { } # should be kept 36 | responses: 37 | '200': 38 | description: Successful operation 39 | content: 40 | application/json: 41 | schema: { } # should be kept 42 | '405': 43 | description: Invalid input 44 | security: 45 | - BasicAuth: [] 46 | - {} 47 | tags: 48 | - pet 49 | x-visibility: true 50 | components: 51 | schemas: 52 | Pet: 53 | type: object 54 | properties: 55 | id: 56 | type: integer 57 | format: int64 58 | example: 10 59 | name: 60 | type: string 61 | example: doggie 62 | category: 63 | $ref: '#/components/schemas/Category' 64 | photoUrls: 65 | type: array 66 | items: 67 | type: string 68 | xml: 69 | name: photoUrl 70 | xml: 71 | wrapped: true 72 | tags: 73 | type: array 74 | items: 75 | $ref: '#/components/schemas/Tag' 76 | xml: 77 | wrapped: true 78 | status: 79 | description: pet status in the store 80 | type: string 81 | enum: 82 | - available 83 | - pending 84 | - sold 85 | example: 86 | default: 87 | key1: 88 | key: { } # should be kept 89 | key2: { } # should be kept 90 | key: 91 | key1: { } # should be kept 92 | key2: 93 | key: { } # should be kept 94 | required: 95 | - name 96 | - photoUrls 97 | x-swagger-router-model: io.swagger.petstore.model.Pet 98 | xml: 99 | name: pet 100 | Category: 101 | type: object 102 | properties: 103 | id: 104 | type: integer 105 | format: int64 106 | example: 1 107 | name: 108 | type: string 109 | example: Dogs 110 | xml: 111 | name: category 112 | Tag: 113 | type: object 114 | properties: 115 | id: 116 | type: integer 117 | format: int64 118 | name: 119 | type: string 120 | xml: 121 | name: tag 122 | ApiResponse: 123 | type: object 124 | properties: 125 | code: 126 | type: integer 127 | format: int32 128 | type: 129 | type: string 130 | message: 131 | type: string 132 | xml: 133 | name: '##default' 134 | securitySchemes: 135 | petstore_auth: 136 | type: oauth2 137 | flows: 138 | implicit: 139 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 140 | scopes: 141 | 'write:pets': modify pets in your account 142 | 'read:pets': read your pets 143 | api_key: 144 | type: apiKey 145 | name: api_key 146 | in: header 147 | tags: 148 | - name: pet 149 | description: Everything about your Pets 150 | externalDocs: 151 | description: Find out more about Swagger 152 | url: 'http://swagger.io' 153 | security: 154 | - BasicAuth: [] 155 | - {} 156 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-default/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-default/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | description: Sample 4 | version: 1.0.6-SNAPSHOT 5 | title: Swagger Petstore - OpenAPI 3.0 6 | termsOfService: 'http://swagger.io/terms/' 7 | contact: 8 | email: apiteam@swagger.io 9 | license: 10 | name: Apache 2.0 11 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 12 | servers: 13 | - url: /v3 14 | paths: 15 | /pet: 16 | post: 17 | operationId: addPet 18 | summary: Add a new pet to the store 19 | description: Add a new pet to the store 20 | requestBody: 21 | description: Create a new pet in the store 22 | required: true 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | examples: 28 | example1: 29 | key1: {} 30 | key2: 31 | key: {} 32 | example2: 33 | key1: {} 34 | key2: 35 | key: {} 36 | responses: 37 | '200': 38 | description: Successful operation 39 | content: 40 | application/json: 41 | schema: {} 42 | '405': 43 | description: Invalid input 44 | security: 45 | - BasicAuth: [] 46 | - {} 47 | tags: 48 | - pet 49 | x-visibility: true 50 | components: 51 | schemas: 52 | Pet: 53 | type: object 54 | properties: 55 | id: 56 | type: integer 57 | format: int64 58 | example: 10 59 | name: 60 | type: string 61 | example: doggie 62 | category: 63 | $ref: '#/components/schemas/Category' 64 | photoUrls: 65 | type: array 66 | items: 67 | type: string 68 | xml: 69 | name: photoUrl 70 | xml: 71 | wrapped: true 72 | tags: 73 | type: array 74 | items: 75 | $ref: '#/components/schemas/Tag' 76 | xml: 77 | wrapped: true 78 | status: 79 | description: pet status in the store 80 | type: string 81 | enum: 82 | - available 83 | - pending 84 | - sold 85 | example: 86 | default: 87 | key1: 88 | key: {} 89 | key2: {} 90 | key: 91 | key1: {} 92 | key2: 93 | key: {} 94 | required: 95 | - name 96 | - photoUrls 97 | x-swagger-router-model: io.swagger.petstore.model.Pet 98 | xml: 99 | name: pet 100 | Category: 101 | type: object 102 | properties: 103 | id: 104 | type: integer 105 | format: int64 106 | example: 1 107 | name: 108 | type: string 109 | example: Dogs 110 | xml: 111 | name: category 112 | Tag: 113 | type: object 114 | properties: 115 | id: 116 | type: integer 117 | format: int64 118 | name: 119 | type: string 120 | xml: 121 | name: tag 122 | ApiResponse: 123 | type: object 124 | properties: 125 | code: 126 | type: integer 127 | format: int32 128 | type: 129 | type: string 130 | message: 131 | type: string 132 | xml: 133 | name: '##default' 134 | securitySchemes: 135 | petstore_auth: 136 | type: oauth2 137 | flows: 138 | implicit: 139 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 140 | scopes: 141 | 'write:pets': modify pets in your account 142 | 'read:pets': read your pets 143 | api_key: 144 | type: apiKey 145 | name: api_key 146 | in: header 147 | tags: 148 | - name: pet 149 | description: Everything about your Pets 150 | externalDocs: 151 | description: Find out more about Swagger 152 | url: 'http://swagger.io' 153 | security: 154 | - BasicAuth: [] 155 | - {} 156 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-false/customFilter.yaml: -------------------------------------------------------------------------------- 1 | preserveEmptyObjects: false 2 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-false/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | description: Sample 4 | version: 1.0.6-SNAPSHOT 5 | title: Swagger Petstore - OpenAPI 3.0 6 | termsOfService: 'http://swagger.io/terms/' 7 | contact: 8 | email: apiteam@swagger.io 9 | license: 10 | name: Apache 2.0 11 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 12 | servers: 13 | - url: /v3 14 | paths: 15 | /pet: 16 | post: 17 | operationId: addPet 18 | summary: Add a new pet to the store 19 | description: Add a new pet to the store 20 | requestBody: 21 | description: Create a new pet in the store 22 | required: true 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | examples: # should not be kept 28 | example1: # should not be kept 29 | key1: { } # should not be kept 30 | key2: # should not be kept 31 | key: { } # should not be kept 32 | example2: # should not be kept 33 | key1: { } # should not be kept 34 | key2: # should not be kept 35 | key: { } # should not be kept 36 | responses: 37 | '200': 38 | description: Successful operation 39 | content: # should not be kept 40 | application/json: # should not be kept 41 | schema: { } # should not be kept 42 | '405': 43 | description: Invalid input 44 | security: 45 | - BasicAuth: [] 46 | - {} 47 | tags: 48 | - pet 49 | x-visibility: true 50 | components: 51 | schemas: 52 | Pet: 53 | type: object 54 | properties: 55 | id: 56 | type: integer 57 | format: int64 58 | example: 10 59 | name: 60 | type: string 61 | example: doggie 62 | category: 63 | $ref: '#/components/schemas/Category' 64 | photoUrls: 65 | type: array 66 | items: 67 | type: string 68 | xml: 69 | name: photoUrl 70 | xml: 71 | wrapped: true 72 | tags: 73 | type: array 74 | items: 75 | $ref: '#/components/schemas/Tag' 76 | xml: 77 | wrapped: true 78 | status: 79 | description: pet status in the store 80 | type: string 81 | enum: 82 | - available 83 | - pending 84 | - sold 85 | example: 86 | default: 87 | key1: # should not be kept 88 | key: { } # should not be kept 89 | key2: { } # should not be kept 90 | key: 91 | key1: { } # should not be kept 92 | key2: 93 | key: { } # should not be kept 94 | required: 95 | - name 96 | - photoUrls 97 | x-swagger-router-model: io.swagger.petstore.model.Pet 98 | xml: 99 | name: pet 100 | Category: 101 | type: object 102 | properties: 103 | id: 104 | type: integer 105 | format: int64 106 | example: 1 107 | name: 108 | type: string 109 | example: Dogs 110 | xml: 111 | name: category 112 | Tag: 113 | type: object 114 | properties: 115 | id: 116 | type: integer 117 | format: int64 118 | name: 119 | type: string 120 | xml: 121 | name: tag 122 | ApiResponse: 123 | type: object 124 | properties: 125 | code: 126 | type: integer 127 | format: int32 128 | type: 129 | type: string 130 | message: 131 | type: string 132 | xml: 133 | name: '##default' 134 | securitySchemes: 135 | petstore_auth: 136 | type: oauth2 137 | flows: 138 | implicit: 139 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 140 | scopes: 141 | 'write:pets': modify pets in your account 142 | 'read:pets': read your pets 143 | api_key: 144 | type: apiKey 145 | name: api_key 146 | in: header 147 | tags: 148 | - name: pet 149 | description: Everything about your Pets 150 | externalDocs: 151 | description: Find out more about Swagger 152 | url: 'http://swagger.io' 153 | security: 154 | - BasicAuth: [] 155 | - {} 156 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-false/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | filterFile: ./customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-false/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | description: Sample 4 | version: 1.0.6-SNAPSHOT 5 | title: Swagger Petstore - OpenAPI 3.0 6 | termsOfService: 'http://swagger.io/terms/' 7 | contact: 8 | email: apiteam@swagger.io 9 | license: 10 | name: Apache 2.0 11 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 12 | servers: 13 | - url: /v3 14 | paths: 15 | /pet: 16 | post: 17 | operationId: addPet 18 | summary: Add a new pet to the store 19 | description: Add a new pet to the store 20 | requestBody: 21 | description: Create a new pet in the store 22 | required: true 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | responses: 28 | '200': 29 | description: Successful operation 30 | '405': 31 | description: Invalid input 32 | security: 33 | - BasicAuth: [] 34 | - {} 35 | tags: 36 | - pet 37 | x-visibility: true 38 | components: 39 | schemas: 40 | Pet: 41 | type: object 42 | properties: 43 | id: 44 | type: integer 45 | format: int64 46 | example: 10 47 | name: 48 | type: string 49 | example: doggie 50 | category: 51 | $ref: '#/components/schemas/Category' 52 | photoUrls: 53 | type: array 54 | items: 55 | type: string 56 | xml: 57 | name: photoUrl 58 | xml: 59 | wrapped: true 60 | tags: 61 | type: array 62 | items: 63 | $ref: '#/components/schemas/Tag' 64 | xml: 65 | wrapped: true 66 | status: 67 | description: pet status in the store 68 | type: string 69 | enum: 70 | - available 71 | - pending 72 | - sold 73 | example: 74 | default: 75 | key1: {} 76 | key2: {} 77 | required: 78 | - name 79 | - photoUrls 80 | x-swagger-router-model: io.swagger.petstore.model.Pet 81 | xml: 82 | name: pet 83 | Category: 84 | type: object 85 | properties: 86 | id: 87 | type: integer 88 | format: int64 89 | example: 1 90 | name: 91 | type: string 92 | example: Dogs 93 | xml: 94 | name: category 95 | Tag: 96 | type: object 97 | properties: 98 | id: 99 | type: integer 100 | format: int64 101 | name: 102 | type: string 103 | xml: 104 | name: tag 105 | ApiResponse: 106 | type: object 107 | properties: 108 | code: 109 | type: integer 110 | format: int32 111 | type: 112 | type: string 113 | message: 114 | type: string 115 | xml: 116 | name: '##default' 117 | securitySchemes: 118 | petstore_auth: 119 | type: oauth2 120 | flows: 121 | implicit: 122 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 123 | scopes: 124 | 'write:pets': modify pets in your account 125 | 'read:pets': read your pets 126 | api_key: 127 | type: apiKey 128 | name: api_key 129 | in: header 130 | tags: 131 | - name: pet 132 | description: Everything about your Pets 133 | externalDocs: 134 | description: Find out more about Swagger 135 | url: 'http://swagger.io' 136 | security: 137 | - BasicAuth: [] 138 | - {} 139 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-schema-only/customFilter.yaml: -------------------------------------------------------------------------------- 1 | preserveEmptyObjects: ['schema'] 2 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-schema-only/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | filterFile: ./customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-true/customFilter.yaml: -------------------------------------------------------------------------------- 1 | preserveEmptyObjects: true 2 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-true/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | description: Sample 4 | version: 1.0.6-SNAPSHOT 5 | title: Swagger Petstore - OpenAPI 3.0 6 | termsOfService: 'http://swagger.io/terms/' 7 | contact: 8 | email: apiteam@swagger.io 9 | license: 10 | name: Apache 2.0 11 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 12 | servers: 13 | - url: /v3 14 | paths: 15 | /pet: 16 | post: 17 | operationId: addPet 18 | summary: Add a new pet to the store 19 | description: Add a new pet to the store 20 | requestBody: 21 | description: Create a new pet in the store 22 | required: true 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | examples: 28 | example1: 29 | key1: { } # should be kept 30 | key2: 31 | key: { } # should be kept 32 | example2: 33 | key1: { } # should be kept 34 | key2: 35 | key: { } # should be kept 36 | responses: 37 | '200': 38 | description: Successful operation 39 | content: 40 | application/json: 41 | schema: { } # should be kept 42 | '405': 43 | description: Invalid input 44 | security: 45 | - BasicAuth: [] 46 | - {} 47 | tags: 48 | - pet 49 | x-visibility: true 50 | components: 51 | schemas: 52 | Pet: 53 | type: object 54 | properties: 55 | id: 56 | type: integer 57 | format: int64 58 | example: 10 59 | name: 60 | type: string 61 | example: doggie 62 | category: 63 | $ref: '#/components/schemas/Category' 64 | photoUrls: 65 | type: array 66 | items: 67 | type: string 68 | xml: 69 | name: photoUrl 70 | xml: 71 | wrapped: true 72 | tags: 73 | type: array 74 | items: 75 | $ref: '#/components/schemas/Tag' 76 | xml: 77 | wrapped: true 78 | status: 79 | description: pet status in the store 80 | type: string 81 | enum: 82 | - available 83 | - pending 84 | - sold 85 | example: 86 | default: 87 | key1: 88 | key: { } # should be kept 89 | key2: { } # should be kept 90 | key: 91 | key1: { } # should be kept 92 | key2: 93 | key: { } # should be kept 94 | required: 95 | - name 96 | - photoUrls 97 | x-swagger-router-model: io.swagger.petstore.model.Pet 98 | xml: 99 | name: pet 100 | Category: 101 | type: object 102 | properties: 103 | id: 104 | type: integer 105 | format: int64 106 | example: 1 107 | name: 108 | type: string 109 | example: Dogs 110 | xml: 111 | name: category 112 | Tag: 113 | type: object 114 | properties: 115 | id: 116 | type: integer 117 | format: int64 118 | name: 119 | type: string 120 | xml: 121 | name: tag 122 | ApiResponse: 123 | type: object 124 | properties: 125 | code: 126 | type: integer 127 | format: int32 128 | type: 129 | type: string 130 | message: 131 | type: string 132 | xml: 133 | name: '##default' 134 | securitySchemes: 135 | petstore_auth: 136 | type: oauth2 137 | flows: 138 | implicit: 139 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 140 | scopes: 141 | 'write:pets': modify pets in your account 142 | 'read:pets': read your pets 143 | api_key: 144 | type: apiKey 145 | name: api_key 146 | in: header 147 | tags: 148 | - name: pet 149 | description: Everything about your Pets 150 | externalDocs: 151 | description: Find out more about Swagger 152 | url: 'http://swagger.io' 153 | security: 154 | - BasicAuth: [] 155 | - {} 156 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-true/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | filterFile: ./customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-preserve-empty-objects-true/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | info: 3 | description: Sample 4 | version: 1.0.6-SNAPSHOT 5 | title: Swagger Petstore - OpenAPI 3.0 6 | termsOfService: 'http://swagger.io/terms/' 7 | contact: 8 | email: apiteam@swagger.io 9 | license: 10 | name: Apache 2.0 11 | url: 'http://www.apache.org/licenses/LICENSE-2.0.html' 12 | servers: 13 | - url: /v3 14 | paths: 15 | /pet: 16 | post: 17 | operationId: addPet 18 | summary: Add a new pet to the store 19 | description: Add a new pet to the store 20 | requestBody: 21 | description: Create a new pet in the store 22 | required: true 23 | content: 24 | application/json: 25 | schema: 26 | $ref: '#/components/schemas/Pet' 27 | examples: 28 | example1: 29 | key1: {} 30 | key2: 31 | key: {} 32 | example2: 33 | key1: {} 34 | key2: 35 | key: {} 36 | responses: 37 | '200': 38 | description: Successful operation 39 | content: 40 | application/json: 41 | schema: {} 42 | '405': 43 | description: Invalid input 44 | security: 45 | - BasicAuth: [] 46 | - {} 47 | tags: 48 | - pet 49 | x-visibility: true 50 | components: 51 | schemas: 52 | Pet: 53 | type: object 54 | properties: 55 | id: 56 | type: integer 57 | format: int64 58 | example: 10 59 | name: 60 | type: string 61 | example: doggie 62 | category: 63 | $ref: '#/components/schemas/Category' 64 | photoUrls: 65 | type: array 66 | items: 67 | type: string 68 | xml: 69 | name: photoUrl 70 | xml: 71 | wrapped: true 72 | tags: 73 | type: array 74 | items: 75 | $ref: '#/components/schemas/Tag' 76 | xml: 77 | wrapped: true 78 | status: 79 | description: pet status in the store 80 | type: string 81 | enum: 82 | - available 83 | - pending 84 | - sold 85 | example: 86 | default: 87 | key1: 88 | key: {} 89 | key2: {} 90 | key: 91 | key1: {} 92 | key2: 93 | key: {} 94 | required: 95 | - name 96 | - photoUrls 97 | x-swagger-router-model: io.swagger.petstore.model.Pet 98 | xml: 99 | name: pet 100 | Category: 101 | type: object 102 | properties: 103 | id: 104 | type: integer 105 | format: int64 106 | example: 1 107 | name: 108 | type: string 109 | example: Dogs 110 | xml: 111 | name: category 112 | Tag: 113 | type: object 114 | properties: 115 | id: 116 | type: integer 117 | format: int64 118 | name: 119 | type: string 120 | xml: 121 | name: tag 122 | ApiResponse: 123 | type: object 124 | properties: 125 | code: 126 | type: integer 127 | format: int32 128 | type: 129 | type: string 130 | message: 131 | type: string 132 | xml: 133 | name: '##default' 134 | securitySchemes: 135 | petstore_auth: 136 | type: oauth2 137 | flows: 138 | implicit: 139 | authorizationUrl: 'https://petstore.swagger.io/oauth/authorize' 140 | scopes: 141 | 'write:pets': modify pets in your account 142 | 'read:pets': read your pets 143 | api_key: 144 | type: apiKey 145 | name: api_key 146 | in: header 147 | tags: 148 | - name: pet 149 | description: Everything about your Pets 150 | externalDocs: 151 | description: Find out more about Swagger 152 | url: 'http://swagger.io' 153 | security: 154 | - BasicAuth: [] 155 | - {} 156 | -------------------------------------------------------------------------------- /test/yaml-preserve-example-props/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Repro 4 | paths: 5 | /items: 6 | get: 7 | responses: 8 | '200': 9 | description: Successful response 10 | content: 11 | application/json: 12 | schema: 13 | type: object 14 | properties: 15 | properties: 16 | type: object 17 | text: 18 | type: string 19 | example: 20 | properties: 21 | text: "test" -------------------------------------------------------------------------------- /test/yaml-preserve-example-props/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | #no-sort: true 4 | -------------------------------------------------------------------------------- /test/yaml-preserve-example-props/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Repro 4 | paths: 5 | /items: 6 | get: 7 | responses: 8 | '200': 9 | description: Successful response 10 | content: 11 | application/json: 12 | schema: 13 | type: object 14 | properties: 15 | properties: 16 | type: object 17 | text: 18 | type: string 19 | example: 20 | properties: 21 | text: test 22 | -------------------------------------------------------------------------------- /test/yaml-ref-quotes/bundled.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | components: 3 | schemas: 4 | Case: 5 | description: Case file subset 6 | type: object 7 | properties: 8 | extern: 9 | $ref: '#/components/schemas/Extern' 10 | intern: 11 | $ref: '#/components/schemas/Extern' 12 | Extern: 13 | type: object 14 | properties: 15 | id: 16 | type: string -------------------------------------------------------------------------------- /test/yaml-ref-quotes/domain-types.openapi.yaml: -------------------------------------------------------------------------------- 1 | components: 2 | schemas: 3 | Extern: 4 | type: object 5 | properties: 6 | id: 7 | type: string 8 | -------------------------------------------------------------------------------- /test/yaml-ref-quotes/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | components: 3 | schemas: 4 | Case: 5 | description: Case file subset 6 | type: object 7 | properties: 8 | extern: 9 | $ref: "domain-types.openapi.yaml#/components/schemas/Extern" 10 | intern: 11 | $ref: 'domain-types.openapi.yaml#/components/schemas/Extern' 12 | -------------------------------------------------------------------------------- /test/yaml-ref-quotes/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | lineWidth: 80 3 | output: output.yaml 4 | bundle: false 5 | -------------------------------------------------------------------------------- /test/yaml-ref-quotes/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.2 2 | components: 3 | schemas: 4 | Case: 5 | description: Case file subset 6 | type: object 7 | properties: 8 | extern: 9 | $ref: "domain-types.openapi.yaml#/components/schemas/Extern" 10 | intern: 11 | $ref: "domain-types.openapi.yaml#/components/schemas/Extern" 12 | -------------------------------------------------------------------------------- /test/yaml-remove-empty-filter/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | info: 3 | title: Test 4 | version: 1.0.0 5 | description: Test 6 | servers: 7 | - url: https://example.de/test 8 | security: 9 | - bearerToken: [ ] 10 | tags: 11 | - name: Test API 12 | paths: 13 | /test: 14 | get: 15 | summary: Get test 16 | tags: 17 | - Test API 18 | responses: 19 | '200': 20 | description: OK 21 | content: 22 | application/json: 23 | schema: 24 | type: object 25 | properties: 26 | test-value: 27 | type: string 28 | examples: { } 29 | operationId: get-test 30 | description: Test 31 | securitySchemes: 32 | bearerToken: 33 | type: http 34 | scheme: bearer 35 | -------------------------------------------------------------------------------- /test/yaml-remove-empty-filter/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | filterSet: 5 | methods: 6 | - delete 7 | 8 | -------------------------------------------------------------------------------- /test/yaml-remove-empty-filter/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | info: 3 | title: Test 4 | version: 1.0.0 5 | description: Test 6 | servers: 7 | - url: 'https://example.de/test' 8 | security: 9 | - bearerToken: [] 10 | tags: 11 | - name: Test API 12 | paths: 13 | /test: 14 | get: 15 | summary: Get test 16 | tags: 17 | - Test API 18 | responses: 19 | '200': 20 | description: OK 21 | content: 22 | application/json: 23 | schema: 24 | type: object 25 | properties: 26 | test-value: 27 | type: string 28 | operationId: get-test 29 | description: Test 30 | -------------------------------------------------------------------------------- /test/yaml-rename/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | rename: OpenAPI Petstore - OpenAPI 3.0 5 | -------------------------------------------------------------------------------- /test/yaml-sort-components/customSortComponents.yaml: -------------------------------------------------------------------------------- 1 | - schemas 2 | - parameters 3 | - headers 4 | - requestBodies 5 | - responses 6 | - securitySchemes 7 | -------------------------------------------------------------------------------- /test/yaml-sort-components/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | sortComponentsFile: customSortComponents.yaml 3 | output: output.yaml 4 | 5 | -------------------------------------------------------------------------------- /test/yaml-sort-keep-comments/customFilter.yaml: -------------------------------------------------------------------------------- 1 | methods: 2 | - post 3 | -------------------------------------------------------------------------------- /test/yaml-sort-keep-comments/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /example: 7 | get: # 1 - This is a comment in the OpenAPI file 8 | description: The description of the example # 2 - This is a comment in the OpenAPI file 9 | # 3 - This is a comment in the OpenAPI file 10 | summary: Returns an example # 4 - This is a comment in the OpenAPI file 11 | # 5- A more detailed description of the operation 12 | responses: 13 | '200': 14 | description: A successful response 15 | post: # 6 -This is a comment in the OpenAPI file 16 | summary: Creates an example # 7 -This is a comment in the OpenAPI file 17 | # 8 -A more detailed description of the operation 18 | responses: 19 | '200': 20 | description: A successful response 21 | -------------------------------------------------------------------------------- /test/yaml-sort-keep-comments/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: false 4 | keepComments: true 5 | filterFile: customFilter.yaml 6 | -------------------------------------------------------------------------------- /test/yaml-sort-keep-comments/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Minimal API 4 | version: 1.0.0 5 | paths: 6 | /example: 7 | get: # 1 - This is a comment in the OpenAPI file 8 | # 3 - This is a comment in the OpenAPI file 9 | summary: Returns an example # 4 - This is a comment in the OpenAPI file 10 | description: The description of the example # 2 - This is a comment in the OpenAPI file 11 | # 5- A more detailed description of the operation 12 | responses: 13 | '200': 14 | description: A successful response 15 | -------------------------------------------------------------------------------- /test/yaml-sort-paths-alphabet/customSort.yaml: -------------------------------------------------------------------------------- 1 | sortPathsBy: path 2 | -------------------------------------------------------------------------------- /test/yaml-sort-paths-alphabet/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: MiniMap API 4 | version: 1.0.0 5 | paths: 6 | /tag-x: 7 | get: 8 | summary: Get list 9 | responses: 10 | '200': 11 | description: A JSON array 12 | content: 13 | application/json: 14 | schema: 15 | type: array 16 | items: 17 | type: string 18 | tags: 19 | - Tag 2 20 | /tag-b/details: 21 | get: 22 | summary: Get 23 | responses: 24 | '200': 25 | description: Lorem 26 | content: 27 | application/json: 28 | schema: 29 | type: object 30 | properties: 31 | id: 32 | type: string 33 | tags: 34 | - Tag 3 35 | /tag-b: 36 | get: 37 | summary: Get 38 | responses: 39 | '200': 40 | description: Lorem 41 | content: 42 | application/json: 43 | schema: 44 | type: object 45 | properties: 46 | id: 47 | type: string 48 | tags: 49 | - Tag 3 50 | /tag-c: 51 | get: 52 | summary: Get list 53 | responses: 54 | '200': 55 | description: A JSON array 56 | content: 57 | application/json: 58 | schema: 59 | type: array 60 | items: 61 | type: string 62 | tags: 63 | - Tag 1 64 | /tag-a: 65 | get: 66 | summary: Get list 67 | responses: 68 | '200': 69 | description: A JSON array 70 | content: 71 | application/json: 72 | schema: 73 | type: array 74 | items: 75 | type: string 76 | tags: 77 | - Tag 1 78 | tags: 79 | - name: Tag 1 80 | description: Operations related to users 81 | - name: Tag 2 82 | description: Operations related to products 83 | - name: Tag 3 84 | description: Operations related to products 85 | -------------------------------------------------------------------------------- /test/yaml-sort-paths-alphabet/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | sortFile: customSort.yaml 4 | -------------------------------------------------------------------------------- /test/yaml-sort-paths-alphabet/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: MiniMap API 4 | version: 1.0.0 5 | paths: 6 | /tag-a: 7 | get: 8 | summary: Get list 9 | responses: 10 | '200': 11 | description: A JSON array 12 | content: 13 | application/json: 14 | schema: 15 | type: array 16 | items: 17 | type: string 18 | tags: 19 | - Tag 1 20 | /tag-b: 21 | get: 22 | summary: Get 23 | responses: 24 | '200': 25 | description: Lorem 26 | content: 27 | application/json: 28 | schema: 29 | type: object 30 | properties: 31 | id: 32 | type: string 33 | tags: 34 | - Tag 3 35 | /tag-b/details: 36 | get: 37 | summary: Get 38 | responses: 39 | '200': 40 | description: Lorem 41 | content: 42 | application/json: 43 | schema: 44 | type: object 45 | properties: 46 | id: 47 | type: string 48 | tags: 49 | - Tag 3 50 | /tag-c: 51 | get: 52 | summary: Get list 53 | responses: 54 | '200': 55 | description: A JSON array 56 | content: 57 | application/json: 58 | schema: 59 | type: array 60 | items: 61 | type: string 62 | tags: 63 | - Tag 1 64 | /tag-x: 65 | get: 66 | summary: Get list 67 | responses: 68 | '200': 69 | description: A JSON array 70 | content: 71 | application/json: 72 | schema: 73 | type: array 74 | items: 75 | type: string 76 | tags: 77 | - Tag 2 78 | tags: 79 | - name: Tag 1 80 | description: Operations related to users 81 | - name: Tag 2 82 | description: Operations related to products 83 | - name: Tag 3 84 | description: Operations related to products 85 | -------------------------------------------------------------------------------- /test/yaml-sort-paths-tags/customSort.yaml: -------------------------------------------------------------------------------- 1 | sortPathsBy: tags 2 | -------------------------------------------------------------------------------- /test/yaml-sort-paths-tags/input.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: MiniMap API 4 | version: 1.0.0 5 | paths: 6 | /tag-x: 7 | get: 8 | summary: Get list 9 | responses: 10 | '200': 11 | description: A JSON array 12 | content: 13 | application/json: 14 | schema: 15 | type: array 16 | items: 17 | type: string 18 | tags: 19 | - Tag 2 20 | /tag-b/details: 21 | get: 22 | summary: Get 23 | responses: 24 | '200': 25 | description: Lorem 26 | content: 27 | application/json: 28 | schema: 29 | type: object 30 | properties: 31 | id: 32 | type: string 33 | tags: 34 | - Tag 3 35 | /tag-b: 36 | get: 37 | summary: Get 38 | responses: 39 | '200': 40 | description: Lorem 41 | content: 42 | application/json: 43 | schema: 44 | type: object 45 | properties: 46 | id: 47 | type: string 48 | tags: 49 | - Tag 3 50 | /tag-c: 51 | get: 52 | summary: Get list 53 | responses: 54 | '200': 55 | description: A JSON array 56 | content: 57 | application/json: 58 | schema: 59 | type: array 60 | items: 61 | type: string 62 | tags: 63 | - Tag 1 64 | /tag-a: 65 | get: 66 | summary: Get list 67 | responses: 68 | '200': 69 | description: A JSON array 70 | content: 71 | application/json: 72 | schema: 73 | type: array 74 | items: 75 | type: string 76 | tags: 77 | - Tag 1 78 | tags: 79 | - name: Tag 1 80 | description: Operations related to users 81 | - name: Tag 2 82 | description: Operations related to products 83 | - name: Tag 3 84 | description: Operations related to products 85 | -------------------------------------------------------------------------------- /test/yaml-sort-paths-tags/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | sortFile: customSort.yaml 4 | -------------------------------------------------------------------------------- /test/yaml-sort-paths-tags/output.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.3 2 | info: 3 | title: MiniMap API 4 | version: 1.0.0 5 | paths: 6 | /tag-c: 7 | get: 8 | summary: Get list 9 | responses: 10 | '200': 11 | description: A JSON array 12 | content: 13 | application/json: 14 | schema: 15 | type: array 16 | items: 17 | type: string 18 | tags: 19 | - Tag 1 20 | /tag-a: 21 | get: 22 | summary: Get list 23 | responses: 24 | '200': 25 | description: A JSON array 26 | content: 27 | application/json: 28 | schema: 29 | type: array 30 | items: 31 | type: string 32 | tags: 33 | - Tag 1 34 | /tag-x: 35 | get: 36 | summary: Get list 37 | responses: 38 | '200': 39 | description: A JSON array 40 | content: 41 | application/json: 42 | schema: 43 | type: array 44 | items: 45 | type: string 46 | tags: 47 | - Tag 2 48 | /tag-b/details: 49 | get: 50 | summary: Get 51 | responses: 52 | '200': 53 | description: Lorem 54 | content: 55 | application/json: 56 | schema: 57 | type: object 58 | properties: 59 | id: 60 | type: string 61 | tags: 62 | - Tag 3 63 | /tag-b: 64 | get: 65 | summary: Get 66 | responses: 67 | '200': 68 | description: Lorem 69 | content: 70 | application/json: 71 | schema: 72 | type: object 73 | properties: 74 | id: 75 | type: string 76 | tags: 77 | - Tag 3 78 | tags: 79 | - name: Tag 1 80 | description: Operations related to users 81 | - name: Tag 2 82 | description: Operations related to products 83 | - name: Tag 3 84 | description: Operations related to products 85 | -------------------------------------------------------------------------------- /test/yaml-sort-skip-components/customSortComponents.yaml: -------------------------------------------------------------------------------- 1 | - schemas 2 | - parameters 3 | - headers 4 | #- requestBodies 5 | - responses 6 | - securitySchemes 7 | -------------------------------------------------------------------------------- /test/yaml-sort-skip-components/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | sortComponentsFile: customSortComponents.yaml 3 | output: output.yaml 4 | 5 | -------------------------------------------------------------------------------- /test/yaml-stoplight-studio-style/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | output: output.yaml 3 | no-sort: true 4 | -------------------------------------------------------------------------------- /test/yaml-strip-flags/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | flags: 4 | - x-visibility 5 | #flagValues: [] 6 | #tags: [] 7 | #operationIds: 8 | # - addPet 9 | # - findPetsByStatus 10 | stripFlags: 11 | - x-visibility 12 | - x-swagger-router-controller 13 | 14 | -------------------------------------------------------------------------------- /test/yaml-strip-flags/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /test/yaml-unused-extra/customFilter.yaml: -------------------------------------------------------------------------------- 1 | #methods: 2 | # - get 3 | #flags: 4 | # - x-visibility 5 | #flagValues: [] 6 | #tags: 7 | # - store 8 | # - user 9 | #operationIds: 10 | # - addPet 11 | # - findPetsByStatus 12 | unusedComponents: 13 | - schemas 14 | - parameters 15 | - examples 16 | - headers 17 | - requestBodies 18 | - responses 19 | 20 | -------------------------------------------------------------------------------- /test/yaml-unused-extra/options.yaml: -------------------------------------------------------------------------------- 1 | verbose: true 2 | no-sort: true 3 | output: output.yaml 4 | filterFile: customFilter.yaml 5 | -------------------------------------------------------------------------------- /utils/filtering.js: -------------------------------------------------------------------------------- 1 | const {isString, isArray, isObject} = require('./types'); 2 | 3 | /** 4 | * Value replacement function 5 | * @param {string} valueAsString 6 | * @param {array} replacements 7 | * @returns {*} 8 | */ 9 | function valueReplace(valueAsString, replacements) { 10 | if (!isString(valueAsString)) return valueAsString; 11 | if (!isArray(replacements)) return valueAsString; 12 | 13 | replacements.map(({searchFor, replaceWith}) => { 14 | const pattern = searchFor.replace(/"/g, '\\\\"'); 15 | const replacement = replaceWith.replace(/"/g, '\\"'); 16 | valueAsString = valueAsString.replace(new RegExp(escapeRegExp(pattern), 'g'), replacement); 17 | return valueAsString; 18 | }); 19 | 20 | return valueAsString; 21 | } 22 | 23 | /** 24 | * Function for escaping input to be treated as a literal string within a regular expression 25 | * @param string 26 | * @returns {*} 27 | */ 28 | function escapeRegExp(string) { 29 | return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); 30 | } 31 | 32 | /** 33 | * Alternative optional chaining function, to provide support for NodeJS 12 34 | * TODO replace this with native ?. optional chaining once NodeJS12 is deprecated. 35 | * @param obj object 36 | * @param path path to access the properties 37 | * @param defaultValue 38 | * @returns {T} 39 | */ 40 | function get(obj, path, defaultValue = undefined) { 41 | const travel = regexp => 42 | String.prototype.split 43 | .call(path, regexp) 44 | .filter(Boolean) 45 | .reduce((res, key) => (res !== null && res !== undefined ? res[key] : res), obj); 46 | 47 | const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/); 48 | return result === undefined || result === obj ? defaultValue : result; 49 | } 50 | 51 | /** 52 | * Validate function if component contains a used property 53 | * @param obj 54 | * @param prop 55 | * @returns {boolean} 56 | */ 57 | function isUsedComp(obj, prop) { 58 | if (!isObject(obj)) return false; 59 | if (!isString(prop)) return false; 60 | const comp = obj[prop]; 61 | if (comp.used && comp.used === true) return true; 62 | return false; 63 | } 64 | 65 | module.exports = { 66 | valueReplace: valueReplace, 67 | get: get, 68 | isUsedComp: isUsedComp 69 | }; 70 | -------------------------------------------------------------------------------- /utils/logging.js: -------------------------------------------------------------------------------- 1 | // Helper function to display info message, depending on the verbose level 2 | function infoOut(msg) { 3 | console.warn(msg); 4 | } 5 | 6 | function logOut(msg, verboseLevel) { 7 | verboseLevel = verboseLevel === true ? 1 : verboseLevel || 0; 8 | if (verboseLevel >= 1) { 9 | console.warn(msg); 10 | } 11 | } 12 | 13 | function debugOut(msg, verboseLevel) { 14 | verboseLevel = verboseLevel === true ? 1 : verboseLevel || 0; 15 | if (verboseLevel >= 2) { 16 | console.warn(msg); 17 | } 18 | } 19 | 20 | function infoTable(obj, verboseLevel) { 21 | verboseLevel = verboseLevel === true ? 1 : verboseLevel || 0; 22 | if (verboseLevel >= 1) { 23 | const keys = Object.keys(obj); 24 | let maxKeyLength = 0; 25 | let maxValLength = 0; 26 | let table = ``; 27 | keys.map(key => { 28 | const keyLength = String(key).length; 29 | const valStr = Array.isArray(obj[key]) ? obj[key].join(', ') : String(obj[key]); 30 | const valLength = valStr.length; 31 | maxKeyLength = keyLength > maxKeyLength ? keyLength : maxKeyLength; 32 | maxValLength = valLength > maxValLength ? valLength : maxValLength; 33 | }); 34 | keys.map(key => { 35 | const keyLength = String(key).length; 36 | const valStr = Array.isArray(obj[key]) ? obj[key].join(', ') : String(obj[key]); 37 | const valLength = valStr.length; 38 | const remainingKeyLength = maxKeyLength - keyLength; 39 | const remainingValLength = maxValLength - valLength; 40 | table += `| ${key}${' '.repeat(remainingKeyLength)} | ${valStr}${' '.repeat(remainingValLength)} |\n`; 41 | }); 42 | let header = `|-${'-'.repeat(maxKeyLength)}-|-${'-'.repeat(maxValLength)}-|\n`; 43 | return header + table + header; 44 | } 45 | } 46 | 47 | module.exports = { 48 | infoTable: infoTable, 49 | logOut: logOut, 50 | debugOut: debugOut, 51 | infoOut: infoOut 52 | }; 53 | -------------------------------------------------------------------------------- /utils/split.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const traverse = require('neotraverse/legacy'); 3 | const {writeFile} = require('./../utils/file'); 4 | 5 | async function writeSplitOpenAPISpec(oaObj, options) { 6 | const {outputDir, format} = options; 7 | const openapiDoc = {...oaObj}; 8 | const ext = `${options.extension}`; 9 | 10 | // Replace paths with $ref links 11 | if (openapiDoc?.paths) { 12 | Object.keys(openapiDoc.paths).forEach(pathKey => { 13 | const sanitizedPath = sanitizeFileName(pathKey); 14 | openapiDoc.paths[pathKey] = {$ref: `paths/${sanitizedPath}.${ext}`}; 15 | }); 16 | } 17 | 18 | // Replace components with $ref links 19 | if (openapiDoc?.components) { 20 | Object.keys(openapiDoc.components).forEach(componentType => { 21 | Object.keys(openapiDoc.components[componentType]).forEach(componentName => { 22 | openapiDoc.components[componentType][componentName] = { 23 | $ref: `components/${componentType}/${componentName}.${ext}` 24 | }; 25 | }); 26 | }); 27 | } 28 | 29 | // Write the openapi.yaml file 30 | const outputFile = options.output; 31 | await writeFile(outputFile, openapiDoc, options); 32 | } 33 | 34 | async function writePaths(paths, options) { 35 | const {outputDir, format} = options; 36 | const ext = `${options.extension}`; 37 | const pathsDir = path.join(outputDir || './', 'paths'); 38 | 39 | for (const pathKey of Object.keys(paths)) { 40 | const sanitizedPath = sanitizeFileName(pathKey); 41 | const filePath = path.join(pathsDir, `${sanitizedPath}.${ext}`); 42 | 43 | // Update any component references to the proper file location in paths 44 | const updatedPath = convertComponentsToRef(paths[pathKey], ext, 'paths'); 45 | 46 | // Write each path to its own file 47 | await writeFile(filePath, updatedPath, options); 48 | } 49 | } 50 | 51 | async function writeComponents(components, options) { 52 | const {outputDir} = options; 53 | const ext = `${options.extension}`; 54 | 55 | const componentsDir = path.join(outputDir || './', 'components'); 56 | 57 | for (const componentType of Object.keys(components)) { 58 | for (const componentName of Object.keys(components[componentType])) { 59 | const fileDir = path.join(componentsDir, componentType); 60 | const filePath = path.join(fileDir, `${componentName}.${ext}`); 61 | 62 | // Update any component references within components 63 | const updatedComponent = convertComponentsToRef(components[componentType][componentName], ext, 'components'); 64 | 65 | // Write each component (schema, parameter, etc.) to its own YAML file 66 | await writeFile(filePath, updatedComponent, options); 67 | } 68 | } 69 | } 70 | 71 | function convertComponentsToRef(obj, ext, currentFileDir) { 72 | // Traverse the object to find and update $ref 73 | traverse(obj).forEach(function (node) { 74 | if (this.key === '$ref') { 75 | const refValue = node; 76 | const match = refValue.match(/^#\/components\/([^\/]+)\/([^\/]+)$/); 77 | 78 | if (match) { 79 | const componentType = match[1]; 80 | const componentName = match[2]; 81 | 82 | // Determine the correct relative path 83 | const refFilePath = path.join('components', componentType, `${componentName}.${ext}`); 84 | const relativePath = path.relative(currentFileDir, refFilePath).replace(/\\/g, '/'); 85 | 86 | // Update the reference to point to the correct relative path 87 | this.update(relativePath); 88 | } 89 | } 90 | }); 91 | 92 | return obj; 93 | } 94 | 95 | function sanitizeFileName(fileName) { 96 | // Replace slashes and any other problematic characters with underscores 97 | return fileName 98 | .replace(/^\//, '') 99 | .replace(/\//g, '_') 100 | .replace(/[^a-zA-Z0-9_{}]/g, ''); 101 | } 102 | 103 | module.exports = { 104 | writeSplitOpenAPISpec, 105 | writePaths, 106 | writeComponents, 107 | convertComponentsToRef, 108 | sanitizeFileName 109 | }; 110 | -------------------------------------------------------------------------------- /utils/types.js: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | function isBoolean(v) { 3 | return typeof v === 'boolean'; 4 | } 5 | function isNumber(v) { 6 | return typeof v === 'number'; 7 | } 8 | function isString(v) { 9 | return typeof v === 'string'; 10 | } 11 | function isNumeric(v) { 12 | return isNumber(v) || (isString(v) && String(v * 1) === v); 13 | } 14 | function isSymbol(v) { 15 | return typeof v === 'symbol'; 16 | } 17 | function isObject(v) { 18 | return v !== null && v === Object(v) && Object.prototype.toString.call(v) === '[object Object]'; 19 | } 20 | function isFunction(v) { 21 | return v && typeof v === 'function'; 22 | } 23 | function isArray(v) { 24 | return v && Array.isArray(v); 25 | } 26 | function isElement(v) { 27 | return v && v.tagName; 28 | } 29 | function isset(v) { 30 | return v !== null && typeof v !== 'undefined'; 31 | } 32 | function isNull(v) { 33 | return v === null; 34 | } 35 | function isUndefined(v) { 36 | return typeof v === 'undefined'; 37 | } 38 | function isPrimitive(v) { 39 | return isString(v) || isNumber(v) || isBoolean(v) || isNull(v) || isUndefined(v) || isSymbol(v); 40 | } 41 | function isReference(v) { 42 | return isObject(v); 43 | } 44 | function isNaN(v) { 45 | return Object.is(v, Number.NaN); 46 | } 47 | function type(v) { 48 | var regex = /^\[object (\S+?)\]$/; 49 | var matches = Object.prototype.toString.call(v).match(regex) || []; 50 | 51 | return (matches[1] || 'undefined').toLowerCase(); 52 | } 53 | module.exports = { 54 | isBoolean: isBoolean, 55 | isNumber: isNumber, 56 | isString: isString, 57 | isNumeric: isNumeric, 58 | isSymbol: isSymbol, 59 | isObject: isObject, 60 | isFunction: isFunction, 61 | isArray: isArray, 62 | isElement: isElement, 63 | isset: isset 64 | }; 65 | --------------------------------------------------------------------------------