-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Introduce OpenAPI validation #141
Merged
Merged
Conversation
This file contains 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
New packages Microsoft.OpenApi.OData and Microsoft.OpenApi.Readers were added to the csproj file to support OData and improved API documentation efforts. They were chosen for their comprehensive features and broad compatibility.
Implemented new classes for adding OpenAPI validation. The included changes allow us to validate the correctness and adherence of a given OpenAPI schema and report statistics about the schema elements such as the number of parameters, operations, headers, etc. The changes also handle exceptions encountered during validation and provide diagnostic details about the encountered issues.
In this commit, I have introduced the OpenAPI specification validation to the 'GenerateCommand' execution command. This will enable the application to validate the OpenAPI specifications before trying to generate any code, thus adding a layer of protection against invalid specifications. I have used the OpenApiValidator to perform the validation. I have also refined the error display, replacing generic Exception handling with specialized handling for OpenApiValidationException to improve error diagnosis.
A new option '--skip-validation' was introduced in the Settings class, allowing users to bypass the OpenAPI specification validation. This change was implemented to give users more flexibility. In the GenerateCommand class, a conditional statement checking this setting was also added to alter the execution flow based on the user's preference.
Included a new command line flag to README files, '--skip-validation', to allow users to skip validation of the OpenAPI specification. This is particularly useful when users want to expedite the testing process without validating the OpenAPI specification, wherein the tool will trust the input spec and won't raise any validation errors.
Codecov Report
@@ Coverage Diff @@
## main #141 +/- ##
=======================================
Coverage 98.55% 98.55%
=======================================
Files 37 37
Lines 1176 1176
=======================================
Hits 1159 1159
Misses 6 6
Partials 11 11
Flags with carried forward coverage won't be shown. Click here to find out more. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
The changes here implement OpenAPI validation using Microsoft OpenAPI libraries. With the changes here, Refitter will print out validation errors (in red) and warnings (in yellow).
A user can also choose to opt out of OpenAPI validation by using the
--skip-validation
CLI tool argumentThis pull request also includes a new feature that prints out OpenAPI specification statistics for the number of operations, links, parameters, requests, responses, etc...
It looks something like this: