Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Redocly CLI to validate OpenAPI definitions #1558

Merged
merged 3 commits into from
Jun 9, 2023

Conversation

zecakeh
Copy link
Contributor

@zecakeh zecakeh commented Jun 8, 2023

When I worked on upgrading the OpenAPI data (#1310), I found swagger-parser unreliable, mostly because this tool found errors that swagger-parser didn't report. There are also other benefits for using this:

  • It's a linting tool, so other rules can be enforced if wanted
  • The errors reported are much easier to understand than with swagger-parser
  • It has a rule that checks that examples are valid according to the schemas, which could replace the (currently unused) check-swagger-sources.py script. However to make it work we need to remove $refs inside examples, as it is not spec compliant.

I found this tool with this list: openapi.tools. Of the tools that advertise support for OpenAPI 3.1, only two work with our definition files:

They both have similar features so we could use Spectral instead, but I found Redocly CLI visibly faster (although it's a matter of seconds in both cases). Another advantage for some is that Redocly CLI integrates with VS Code It turns out Spectral too.

The configuration file here deactivates the minimum number of rules to make our definitions pass validation. They can be re-enabled by fixing the errors reported in subsequent PRs.

Signed-off-by: Kévin Commaille zecakeh@tedomum.fr

Preview: https://pr1558--matrix-spec-previews.netlify.app

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
@zecakeh zecakeh requested a review from a team as a code owner June 8, 2023 15:20
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
Copy link
Member

@KitsuneRal KitsuneRal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The less we have things invented around OpenAPI, the more we can focus on making Matrix awesome.

@KitsuneRal KitsuneRal merged commit 3c5355a into matrix-org:main Jun 9, 2023
10 checks passed
@zecakeh zecakeh deleted the openapi-validator branch June 9, 2023 18:58
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.

None yet

2 participants