evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a utility that analyzes OpenAPI documents regardless of their specification version (2.0, 3.0, or 3.1). The analyzer should extract and count key elements from any valid OpenAPI document.
Implement a function analyzeDocument that accepts an OpenAPI document of any version and returns an analysis object containing:
version: The OpenAPI version string (e.g., "2.0", "3.0.0", "3.1.0")operationCount: Total number of operations across all pathsparameterCount: Total number of parameters used across all operationsThe function should work with OpenAPI 2.0 (Swagger), OpenAPI 3.0, and OpenAPI 3.1 documents without requiring version-specific handling.
Given an OpenAPI 3.0 document with 2 paths (GET /users and POST /users), where GET has 1 query parameter and POST has 1 body parameter, the function returns {version: "3.0.0", operationCount: 2, parameterCount: 2} @test
Given an OpenAPI 2.0 document with 1 path (GET /items) that has 2 query parameters, the function returns {version: "2.0", operationCount: 1, parameterCount: 2} @test
Given an OpenAPI 3.1 document with 3 paths each containing 1 operation with no parameters, the function returns {version: "3.1.0", operationCount: 3, parameterCount: 0} @test
export interface AnalysisResult {
version: string;
operationCount: number;
parameterCount: number;
}
export function analyzeDocument(document: unknown): AnalysisResult;Provides TypeScript type definitions for OpenAPI specifications.