feat: add OpenAPI spec validation on load with error recovery - #269
Open
ayomidearegbeshola29-dev wants to merge 1 commit into
Open
feat: add OpenAPI spec validation on load with error recovery#269ayomidearegbeshola29-dev wants to merge 1 commit into
ayomidearegbeshola29-dev wants to merge 1 commit into
Conversation
- Fetch and parse YAML spec before passing to Redoc - Validate spec against OpenAPI 3.0 schema using @readme/openapi-parser - Display structured error messages with line numbers and fix suggestions - Add retry mechanism for network and parse failures - Add loading state with spinner during validation - Add SpecErrorDisplay component for rendering validation errors - Add validateSpec utility with YAML parsing and OpenAPI validation - Add TypeScript module declarations for js-yaml and openapi-parser - Add CSS keyframe animation for loading spinner Closes Pidoko257#221
|
@ayomidearegbeshola29-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds runtime OpenAPI specification validation to the API reference page. Invalid specs now show clear, actionable error messages instead of Redoc failing silently or showing cryptic errors.
Problem
When an invalid OpenAPI spec is placed in
static/openapi.yaml, Redoc either fails silently or displays cryptic error messages that don't help developers identify or fix the issue.Solution
Added a three-stage validation pipeline that runs on page load:
@readme/openapi-parserIf validation fails, the user sees a structured error display with:
Changes
New Files
src/utils/validateSpec.tssrc/components/SpecErrorDisplay.tsxsrc/types/modules.d.tsjs-yamland@readme/openapi-parserModified Files
src/components/ApiReference.tsxsrc/css/custom.css@keyframes spinfor loading spinnerpackage.jsonjs-yamland@readme/openapi-parserdependenciesAcceptance Criteria
Error Handling Coverage
static/Testing
info.title— shows error with line number and suggestioninfo.version— shows error with line number and suggestionDependencies Added
js-yaml— YAML parser for browser-side spec parsing@readme/openapi-parser— OpenAPI 3.0 schema validationCloses #221