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

Implement an OpenAPIComparator #194

Merged
merged 16 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add documentation
abdelfetah18 committed Dec 9, 2024
commit ad6cae14ac78bb1486ebba2bb626c77b5e9c28a9
Original file line number Diff line number Diff line change
@@ -11,6 +11,21 @@ object OpenAPIComparator {
new OpenAPIComparator(clientOpenAPI, serverOpenAPI)
}

/**
* A utility for comparing two OpenAPI specifications to validate their compatibility.
*
* The `OpenAPIComparator` class compares the client's OpenAPI specification with the server's
* specification to detect and highlight compatibility issues. It evaluates various components
* including paths, operations, parameters, request bodies, responses, headers, schemas, content,
* and media types.
*
* Note: This comparator does not compare meta-data, such as the info object, server lists, or
* descriptions in properties.
*
* @param clientOpenAPI the OpenAPI specification provided by the client.
* @param serverOpenAPI the OpenAPI specification provided by the server.
*/

class OpenAPIComparator private (
clientOpenAPI: OpenAPI,
serverOpenAPI: OpenAPI
@@ -45,6 +60,16 @@ class OpenAPIComparator private (
case _ => Map.empty[String, Schema]
}

/**
* Compares the client and server OpenAPI specifications for compatibility.
*
* This method compares the paths in both specifications to identify compatibility issues.
* It detects incompatibilities such as missing paths, parameter mismatches, schema inconsistencies,
* and other discrepancies. It organizes the issues into a tree-like structure, with main issues and their sub-issues.
*
* @return a list of `OpenAPICompatibilityIssue` instances detailing the identified issues.
*/

def compare(): List[OpenAPICompatibilityIssue] = {
abdelfetah18 marked this conversation as resolved.
Show resolved Hide resolved
clientOpenAPI.paths.pathItems.toList.flatMap {
case (pathName, clientPathItem) =>