Skip to content
Last updated

How to protect a page in Redocly so that it requires a specific role?

To secure a page in Redocly, you can use the x-security field in your OpenAPI definition. To require a specific role, like "pearl," you can set the security property in your API definition. Here's an example:

paths:
  /debrief.md:
    get:
      security:
        - pearl: []

This will ensure that only users with the "pearl" role can access the /debrief.md page. ^1

How to create a code walkthrough in Redocly?

Redocly supports code snippets and examples, but it doesn't have a built-in feature for creating code walkthroughs. However, you can use the x-code-samples property to provide code examples related to your API endpoints. Here's an example:

paths:
  /example:
    get:
      summary: An example endpoint
      x-code-samples:
        - lang: javascript
          source: |
            const response = await fetch('/example');
            const data = await response.json();

This will display a code sample in the API documentation. ^1

How to show only the mock server in the try it console?

Redocly uses the servers field in your OpenAPI definition to determine which server to use in the try it console. To show only the mock server, you can specify it in the servers array like this:

servers:
  - url: https://mock-server.com/api

This will ensure that the try it console only shows the mock server. ^1

How to run API monitoring using Redocly on a regular schedule?

Redocly doesn’t have a built-in feature for running API monitoring on a regular schedule. However, you can use external tools like Postman or Apigee to monitor your APIs and set up scheduled tests. Source

How to make headings purple in Redocly?

To change the color of headings in Redocly, you can use custom CSS. You can target the heading elements using their CSS selectors and apply the desired color. Here’s an example:

h1, h2, h3, h4, h5, h6 {
  color: purple;
}

You can add this CSS to your project’s styles.css file. ^2