Skip to content
Last updated

I'll help you with these Redocly-specific questions. Here are the answers to each:

1. Protecting a Page with Role-Based Access

To protect your debrief.md page so it requires the "pearl" role:

# In your redocly.yaml or page frontmatter
pages:
  - page: debrief.md
    access:
      roles: ["pearl"]

Or in the frontmatter of debrief.md:


access:
  roles: ["pearl"]


# Your debrief content here

2. Creating a Code Walkthrough

Create a code walkthrough using Redocly's interactive code samples:


title: API Code Walkthrough


# Code Walkthrough

<CodeSample lang="javascript">
```javascript
// Step 1: Initialize the API client
const client = new APIClient({
  baseURL: 'https://api.example.com',
  apiKey: 'your-api-key'
});

// Step 2: Make a request
const response = await client.get('/users');

// Step 3: Handle the response
console.log(response.data);

Use the <Walkthrough> component for step-by-step guides:

<Walkthrough>
  <Step title="Setup">
    Configure your API client with credentials
  </Step>
  <Step title="Request">
    Make your first API call
  </Step>
  <Step title="Response">
    Process the returned data
  </Step>
</Walkthrough>

3. Showing Only Mock Server in Try It Console

Configure the try-it console to use only mock servers:

# In redocly.yaml
apis:
  main:
    root: openapi.yaml
    tryItOut:
      servers:
        - url: https://mock.example.com
          description: Mock Server
      hideRealServers: true

Or in your OpenAPI spec:

servers:
  - url: https://mock.example.com
    description: Mock Server (Try It)
    x-internal: false
  - url: https://api.example.com
    description: Production Server
    x-internal: true  # This hides it from try-it

4. Running API Monitoring on a Schedule

Set up scheduled API monitoring using Redocly CLI with cron jobs or GitHub Actions:

Using GitHub Actions:

# .github/workflows/api-monitoring.yml
name: API Monitoring
on:
  schedule:
    - cron: '0 */6 * * *'  # Every 6 hours

jobs:
  monitor:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install Redocly CLI
        run: npm install -g @redocly/cli
      - name: Run API monitoring
        run: |
          redocly lint openapi.yaml
          redocly test openapi.yaml

Using cron (Linux/Mac):

# Add to crontab (crontab -e)
0 */6 * * * cd /path/to/project && redocly test openapi.yaml >> monitoring.log 2>&1

5. Making Headings Purple in Redocly

Customize heading colors using CSS in your theme:

/* In your custom CSS file or theme */
h1, h2, h3, h4, h5, h6 {
  color: #8B5CF6; /* Purple color */
}

/* Or more specific targeting */
.redoc-content h1,
.redoc-content h2,
.redoc-content h3 {
  color: #8B5CF6;
}

In your redocly.yaml:

theme:
  colors:
    primary:
      main: ‘#8B5CF6’
  typography:
    headings:
      color: ‘#8B5CF6’

Or using CSS custom properties:

:root {
  --heading-color: #8B5CF6;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--heading-color);
}

These configurations will help you achieve the specific Redocly customizations you’re looking for. Make sure to test these changes in your development environment before deploying to production.