How to Rate OpenAPI Schemas

January 30, 2026 Β· View on GitHub

Overview

Rate AI-generated OpenAPI schemas by comparing them against official published schemas. This helps you:

  • Track generation quality
  • Identify systematic gaps
  • Improve prompts based on results
  • Measure progress over time

Quick Start

  1. Run the command, providing file paths, as exemplified:

    /rate-openapi
    generated: generated-docs/2025-10-28-Claude-4-Sonnet-Cursor/session/session-openapi.json
    published: VTEX - Session Manager API.json
    
  2. Review the report saved to ratings/ directory.


πŸ“Š Scoring System

Rating Criteria

CriterionWeightWhat it Measures
Endpoints Coverage20%All endpoints present?
Parameters Completeness17%All parameters correct?
Request Bodies Accuracy17%Request schemas complete?
Response Schemas Accuracy16%Response schemas complete?
Spectral Compliance20%Passes quality/standards checks?
Schema Components5%Components properly defined?
Metadata & Documentation5%API info correct?

Overall Score Formula

Score = (Endpoints Γ— 0.20) + (Parameters Γ— 0.17) + (Request Γ— 0.17) +
        (Response Γ— 0.16) + (Spectral Γ— 0.20) + (Components Γ— 0.05) +
        (Metadata Γ— 0.05)

Grading Scale

ScoreGradeStatusAction
90-100Aβœ… ExcellentMinor polish β†’ Tech writing review
80-89Bβœ… GoodFix critical β†’ Tech writing review
70-79C⚠️ FairMajor fixes β†’ Tech writing review
60-69D⚠️ PoorSignificant rework needed
0-59F❌ FailingRe-generate

Important: All generated schemas require tech writing review before publication.

Target Metrics

MetricTarget
Endpoints Coverageβ‰₯ 95%
Parameters Completenessβ‰₯ 90%
Request Bodies Accuracyβ‰₯ 85%
Response Schemas Accuracyβ‰₯ 85%
Spectral Complianceβ‰₯ 90%
Overall Scoreβ‰₯ 80

πŸ” Criteria summary

1. Endpoints Coverage (25%)

  • βœ… All paths + methods present
  • ❌ Missing endpoints
  • ⚠️ Extra/hallucinated endpoints
  • πŸ”„ Path differences

2. Parameters Completeness (15%)

  • βœ… Path parameters (e.g., {id}, {accountName})
  • βœ… Query parameters (e.g., ?page=1&limit=10)
  • βœ… Header parameters (Content-Type, Accept, etc.)
  • βœ… Correct types and required status
  • πŸ“ Parameter descriptions

3. Request Bodies Accuracy (15%)

  • βœ… All fields present
  • βœ… Correct data types
  • βœ… Nested objects complete
  • βœ… Array items defined
  • πŸ“ Examples at schema level
  • πŸ“„ Field descriptions

4. Response Schemas Accuracy (15%)

  • βœ… All status codes (200, 201, 400, 401, 403, 404, 500)
  • βœ… Response body schemas complete
  • βœ… All response fields present
  • βœ… Nested objects complete
  • πŸ“ Examples at schema level

5. Spectral Compliance (25%)

  • βœ… No linting errors (descriptions, schemas, etc.)
  • βœ… Minimal warnings (best practices)
  • βœ… VTEX-specific rules compliance
  • πŸ“‹ Automated quality validation
  • Score: 100 - (errorsΓ—5 + warningsΓ—2 + infoΓ—0.5)
  • Command: /spectral {schema-file-name}
  • Weight: 25% (highest priority - equal to endpoints)

6. Schema Components (2%)

  • βœ… Reusable schemas in components
  • βœ… Proper $ref usage
  • βœ… Parameter definitions
  • βœ… Security schemes

7. Metadata & Documentation (3%)

  • βœ… Title, description, version
  • βœ… Server configurations
  • βœ… Tags organization
  • βœ… Security schemes defined

Understanding Your Report

1. Overall Score

Quick overview showing total score and breakdown by criterion.

2. Detailed Findings

Each criterion section shows:

  • Statistics (counts and percentages)
  • Specific issues with examples
  • Affected endpoints/fields
  • Impact assessment (High/Medium/Low)

3. Top Issues

Prioritized list of critical problems to fix first.

4. Recommendations

  • High Priority: Must fix
  • Medium Priority: Should fix for quality
  • Low Priority: Nice to have

Common Issues & Solutions

Low Endpoints Coverage (< 90%)

Causes:

  • AI didn't explore entire codebase
  • Non-standard routing patterns
  • Controllers in unexpected locations

Solutions:

  • Provide explicit list of controller files
  • Review route configuration files
  • Use more specific codebase search

Low Parameters Completeness (< 85%)

Causes:

  • Parameters defined in attributes/decorators
  • Implicit parameters (accountName, environment)
  • Inherited parameters from base controllers

Solutions:

  • Review controller base classes
  • Check authentication middleware
  • Review VTEX-specific conventions

Incomplete Response Schemas (< 80%)

Causes:

  • Response types not explicitly defined
  • Dynamic/runtime field generation
  • Partial responses based on permissions

Solutions:

  • Provide example API responses (Postman)
  • Review response DTO classes
  • Check for response mappers/transformers

Low Spectral Compliance (< 90%)

Causes:

  • Empty or missing descriptions
  • Missing permissions documentation
  • Incorrect formatting

Solutions:

  • Run /spectral command for auto-fixes
  • Add meaningful descriptions
  • Include "## Permissions" sections
  • See Spectral Linting Guide

Example Report

# OpenAPI Schema Rating Report

**Generated**: generated-docs/2025-10-28-Claude-4-Sonnet-Cursor/session/session-openapi.json
**Published**: VTEX - Session Manager API.json
**Date**: 2025-10-28

## πŸ“Š Overall Score: 82/100 (Grade: B)

| Criteria | Score | Weighted |
| -------- | ----- | -------- |
| Endpoints | 85/100 | 21.25 |
| Parameters | 78/100 | 11.70 |
| Request Bodies | 80/100 | 12.00 |
| Response Schemas | 84/100 | 12.60 |
| Spectral | 85/100 | 21.25 |
| Components | 70/100 | 1.40 |
| Metadata | 95/100 | 2.85 |
| **Total** | | **83.05** |

## πŸ” Top 3 Critical Issues

1. **Missing Parameter**: accountName (8 endpoints)
   - Impact: High
   - Fix: Add to all path parameters

2. **Missing Response**: 404 Not Found (6 endpoints)
   - Impact: High
   - Fix: Define 404 error response schema

3. **Low Spectral Score**: 12 empty descriptions
   - Impact: Medium
   - Fix: Run `/spectral` for auto-fix

## βœ… What Was Done Well

- All major endpoints present (100% coverage)
- Request bodies comprehensive
- Security schemes correct

Additional Resources