├── .github
└── workflows
│ └── docs-tests.yaml
├── .gitignore
├── .markdownlint.yaml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── configurable-rules
├── .gitignore
├── api-health
│ ├── README.md
│ ├── openapi.yaml
│ └── redocly.yaml
├── azure-apim-unsupported-keyword
│ ├── README.md
│ ├── openapi.yaml
│ └── redocly.yaml
├── description-banned-words
│ ├── README.md
│ └── redocly.yaml
├── info-description
│ ├── README.md
│ └── redocly.yaml
├── json-schema-misconfigurations
│ ├── README.md
│ ├── openapi.yaml
│ └── redocly.yaml
├── no-script
│ ├── README.md
│ └── redocly.yaml
├── operation-delete-should-not-define-requestBody
│ ├── README.md
│ └── redocly.yaml
├── operation-get-should-not-define-requestBody
│ ├── README.md
│ └── redocly.yaml
├── operation-post-should-define-request-body
│ ├── README.md
│ └── redocly.yaml
├── operation-summary-sentence-case
│ ├── README.md
│ └── redocly.yaml
├── path-excludes-pattern
│ ├── README.md
│ └── redocly.yaml
├── required-items-for-array-schemas
│ ├── README.md
│ └── redocly.yaml
└── string-schemas-length-defined
│ ├── README.md
│ ├── openapi.yaml
│ └── redocly.yaml
├── custom-plugin-decorators
├── .gitignore
├── azure-apim
│ ├── README.md
│ └── azure-apim.js
├── openai-is-consequential
│ ├── README.md
│ └── openai-is-consequential.js
├── remove-extensions
│ ├── README.md
│ └── remove-extensions.js
├── remove-unused-tags
│ ├── README.md
│ ├── redocly.yaml
│ └── tags.js
├── swap-summary-description
│ ├── README.md
│ ├── redocly.yaml
│ └── swap-fields.js
├── tag-sorting
│ ├── README.md
│ ├── decorator-alpha.js
│ └── tag-sorting.js
└── update-example-dates
│ ├── README.md
│ ├── decorator.js
│ └── plugin.js
├── custom-plugin-rules
├── .gitignore
├── code-sample-checks
│ ├── README.md
│ ├── check-sdk-coverage.js
│ └── x-code-sample-checks.js
├── default-enum-match
│ ├── README.md
│ └── default-enum-plugin.js
└── markdown-validator
│ ├── README.md
│ ├── openapi-markdown.js
│ ├── package.json
│ └── rule-validate-markdown.js
├── custom-plugins
├── .gitignore
└── sorting
│ ├── README.md
│ ├── redocly.yaml
│ ├── rule-sort-methods.js
│ ├── rule-sort-props.js
│ ├── sort-enums.js
│ ├── sort-methods.js
│ ├── sort-props-alpha.js
│ ├── sort-props-required.js
│ ├── sort-tags.js
│ └── sorting.js
├── miscellaneous
└── reorder-bundled-description-properties
│ ├── README.md
│ ├── bundled.yaml
│ ├── openapi.yaml
│ ├── reorder.js
│ └── schema.yaml
├── readme-template.md
└── rulesets
├── .gitignore
├── common-mistakes
├── README.md
└── redocly.yaml
├── security
├── README.md
└── redocly.yaml
└── spec-compliant
├── README.md
└── redocly.yaml
/.github/workflows/docs-tests.yaml:
--------------------------------------------------------------------------------
1 | name: Documentation tests
2 | on:
3 | pull_request:
4 | types: [opened, synchronize, reopened]
5 |
6 | jobs:
7 | markdownlint:
8 | name: markdownlint
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v4
12 | - uses: articulate/actions-markdownlint@v1
13 | with:
14 | config: .markdownlint.yaml
15 | files: 'README.md'
16 | - uses: articulate/actions-markdownlint@v1
17 | with:
18 | config: .markdownlint.yaml
19 | files: '**/*.md'
20 |
21 | linkcheck:
22 | runs-on: ubuntu-latest
23 | steps:
24 | - name: Checkout Repository
25 | uses: actions/checkout@v4
26 | - name: Markup Link Checker (mlc)
27 | uses: becheran/mlc@v0.16.1
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/.markdownlint.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | # Default rules: https://github.com/github/super-linter/blob/master/TEMPLATES/.markdown-lint.yml
3 |
4 | # Rules by id
5 |
6 | # Unordered list style
7 | MD004: false
8 |
9 | # Unordered list indentation
10 | MD007:
11 | indent: 2
12 |
13 | # Trailing spaces
14 | MD009: false
15 |
16 | MD013:
17 | # TODO: Consider to decrease allowed line length
18 | line_length: 800
19 | tables: false
20 |
21 | ## Allow same headers in siblings
22 | MD024:
23 | siblings_only: true
24 |
25 | # Multiple top level headings in the same document
26 | MD025:
27 | front_matter_title: ''
28 |
29 | # Trailing punctuation in heading
30 | MD026:
31 | punctuation: '.,;:。,;:'
32 |
33 | # Ordered list item prefix
34 | MD029: false
35 |
36 | # Unordered lists inside of ordered lists
37 | MD030: false
38 |
39 | # Inline HTML
40 | MD033: false
41 |
42 | # No bare urls
43 | MD034: false
44 |
45 | # Emphasis used instead of a heading
46 | MD036: false
47 |
48 | # Disable "First line in file should be a top level heading"
49 | # We use uncommon format to add metadata.
50 | # TODO: Consider to use "YAML front matter".
51 | MD041: false
52 |
53 | # Rules by tags
54 | blank_lines: false
55 |
56 | MD046: false
57 | # code-block-style
58 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Redocly CLI Cookbook
2 |
3 | Thanks for sharing your Redocly CLI wisdom with everyone! In order to add your ideas in a way that everyone can understand, please follow these steps to contribute to the project.
4 |
5 | ## Add your work in a new directory
6 |
7 | Every item added to this repository belongs in its own directory. Identify which top-level directory is most appropriate, and then create a directory inside it, named for the thing you are adding.
8 |
9 | For example, to add a configurable rule that makes sure every endpoint is tagged "cupcake" (an imaginary example):
10 |
11 | ```text
12 | .
13 | ├── configurable-rules
14 | │ └── endpoints-are-tagged-cupcake
15 | ```
16 |
17 | Give the directory a meaningful name; people may browse the collection this way.
18 |
19 | ## Add your files
20 |
21 | Put the file or files that you want to share into your new directory. Try to name them in a way that can be re-used by other people and clearly understood.
22 |
23 | ## Create the README
24 |
25 | Copy the `readme-template.md` from the root of the project into your new directory, and name it `README.md`. Edit and complete this file - this is required for your contribution to be added to our collection. Your directory structure should look like this:
26 |
27 | ```text
28 | .
29 | ├── configurable-rules
30 | │ └── endpoints-are-tagged-cupcake
31 | │ └── README.md
32 | ```
33 |
34 | Give users a clear idea of what problem your addition solves and any other related context that can help them to be successful too.
35 |
36 | ## List your addition on the main page
37 |
38 | We keep a catalog of what's included in the main `README.md` file. Add your new entry at the end of the list in the relevant section.
39 |
40 | ## Open a pull request
41 |
42 | Commit your changes to a new branch in your own repository fork, and then open a pull request to our repo. Someone from Redocly will review and offer suggestions or let you know if anything needs changing. Once it's ready, we'll merge and others can benefit from your wisdom!
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Redocly
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Redocly CLI Cookbook
2 |
3 | A community collection of rulesets, configuration, custom plugins and other additions for [Redocly CLI](https://github.com/Redocly/redocly-cli). We know our users have some great tips, examples, and code to share, and this is the place to do just that. We would love to have your [contributions](#contributing) here too!
4 |
5 | > [!IMPORTANT]
6 | > Redocly are the repository maintainers, but we can't thoroughly test everything here. Please browse, share, and use what you find at your own risk.
7 |
8 | If you're new to Redocly CLI, start with the [documentation](https://redocly.com/docs/cli/) to get up and running, then come back here to pick out any elements you would like to re-use yourself. To keep up with new developments, either subscribe to the project repository, or [sign up for the Redocly product newsletter](https://redocly.com/product-updates/).
9 |
10 | ## Usage
11 |
12 | Use the content here as a starting point for your own work.
13 |
14 | 1. Take a look at what's available in each category, and pick any that you think apply to your situation.
15 |
16 | 2. Each section links to the documentation for that feature, incase you need an introduction or refresher.
17 |
18 | 3. Copy and paste the examples you want to use into your own setup, then edit them to fit your own needs.
19 |
20 | If you come up with something new, please consider sharing it here by opening a pull request.
21 |
22 | ## Categories
23 |
24 | ### Rulesets
25 |
26 | Combine existing [built-in rules](https://redocly.com/docs/cli/rules/built-in-rules/) in ways that serve a specific purpose, and make a [resuable ruleset](https://redocly.com/docs/cli/guides/configure-rules/#create-a-reusable-ruleset).
27 |
28 | - [Spec-compliant ruleset](rulesets/spec-compliant/)
29 | - [Spot common mistakes](rulesets/common-mistakes)
30 | - [Security ruleset](rulesets/security) adds some defensive rules to your description.
31 |
32 | ### Configurable rules
33 |
34 | There are some fantastic examples of [configurable rules](https://redocly.com/docs/cli/rules/configurable-rules/) in the wild, we hope the list here inspires you to share more of your own!
35 |
36 | - [Ban certain words from descriptions](configurable-rules/description-banned-words/)
37 | - [Require `items` field for schemas of type `array`](configurable-rules/required-items-for-array-schemas/)
38 | - [Ensure sentence case in operation summaries](configurable-rules/operation-summary-sentence-case)
39 | - [`POST` SHOULD define `requestBody` schema](configurable-rules/operation-post-should-define-request-body/)
40 | - [`GET` SHOULD NOT define `requestBody` schema](configurable-rules/operation-get-should-not-define-requestBody/)
41 | - [`DELETE` SHOULD NOT define `requestBody` schema](configurable-rules/operation-delete-should-not-define-requestBody/)
42 | - [Info section must have a description](configurable-rules/info-description)
43 | - [No ` API
39 | paths: {}
40 | ```
41 |
42 | When you lint this OpenAPI file with the `rule/no-script-tags-in-markdown` rule, you'll see a warning:
43 |
44 | ```text
45 | Markdown descriptions should not contain script tags.
46 | ```
47 |
48 | ## References
49 |
50 | Inspired by the Spectral rule [no-script-tags-in-markdown](https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules#no-script-tags-in-markdown).
51 |
--------------------------------------------------------------------------------
/configurable-rules/no-script/redocly.yaml:
--------------------------------------------------------------------------------
1 | extends: []
2 |
3 | rules:
4 | rule/no-script-tags-in-markdown:
5 | subject:
6 | type: any
7 | property: description
8 | assertions:
9 | notPattern: '