Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 7, 2025

This PR adds OpenAPI schema validation to the project using @seriousme/openapi-schema-validator as requested in the issue.

Changes Made

  • Added dependency: Installed @seriousme/openapi-schema-validator as a dev dependency
  • Added validation script: Created npm run validate command that validates dist/schema.json
  • Updated CI workflow: Added schema generation and validation steps to the GitHub Actions workflow
  • Added comprehensive tests: Created test suite to verify the validation functionality works correctly

Workflow Integration

The CI workflow now includes these steps in order:

  1. Check code formatting
  2. Build project
  3. Generate OpenAPI schema
  4. Validate OpenAPI schema ← New step
  5. Run tests

Usage

# Generate the schema
npm run generate

# Validate the generated schema
npm run validate

Notes

The validation currently identifies real schema issues in the OAuth2 security scheme configuration that should be addressed in a future PR. The validator is working correctly and will fail CI builds when schema validation errors exist, ensuring schema quality going forward.

Example validation output:

{
  "valid": false,
  "errors": [
    {
      "instancePath": "/components/securitySchemes/OAuth2",
      "message": "must have required property 'flows'"
    }
  ]
}

Fixes #26.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add openapi schema validator Add OpenAPI schema validator with @seriousme/openapi-schema-validator Jun 7, 2025
Copilot AI requested a review from abraham June 7, 2025 00:13
Copilot finished work on behalf of abraham June 7, 2025 00:13
@abraham
Copy link
Owner

abraham commented Jun 7, 2025

Run npm run validate and fix the issues

Copy link
Contributor Author

Copilot AI commented Jun 7, 2025

Run npm run validate and fix the issues

Fixed the OAuth2 security scheme validation issues by adding the required flows property with proper authorizationCode and clientCredentials flows as supported by Mastodon. The OAuth2 validation now passes. Commit: c774902

Copilot finished work on behalf of abraham June 7, 2025 00:24
@abraham
Copy link
Owner

abraham commented Jun 7, 2025

run format command

Copy link
Contributor Author

Copilot AI commented Jun 7, 2025

run format command

Format command has been run successfully. The code has been formatted according to prettier configuration. Commit: 54648cc

Copilot finished work on behalf of abraham June 7, 2025 00:30
@abraham
Copy link
Owner

abraham commented Jun 7, 2025

Fix the schema generation so the validation succeeds

Copy link
Contributor Author

Copilot AI commented Jun 7, 2025

Fix the schema generation so the validation succeeds

Fixed the schema generation issues. The validation now succeeds with {"valid": true}. Key improvements:

  • Enhanced EntityParser to handle multiple entity definitions within single files (Field, CredentialAccount, MutedAccount, etc.)
  • Fixed type parsing to avoid creating invalid references for documentation links
  • Added support for nested entity definitions like Announcement::Account
  • Now generates 85 entities (up from 64) with proper schema validation

Commit: 967ef98

Copilot finished work on behalf of abraham June 7, 2025 00:46
@abraham abraham marked this pull request as ready for review June 7, 2025 00:51
@abraham abraham merged commit 2f78a74 into main Jun 7, 2025
1 check passed
@abraham abraham deleted the copilot/fix-26-2 branch June 7, 2025 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add openapi schema validator

2 participants