import pytest import json from pathlib import Path @pytest.fixture def sample_spec(tmp_path): spec = { "openapi": "3.0.0", "info": { "title": "API Documentation", "version": "1.0.0", "description": "A sample API for testing" }, "paths": { "/users": { "get": { "summary": "List all users", "description": "Returns a list of all users in the system", "tags": ["users"], "parameters": [ { "name": "limit", "in": "query", "schema": {"type": "integer"}, "description": "Maximum number of results" } ], "responses": { "200": {"description": "Successful response"}, "400": {"description": "Bad request"} } }, "post": { "summary": "Create user", "description": "Creates a new user in the system", "tags": ["users"], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "name": {"type": "string"}, "email": {"type": "string"} } } } } }, "responses": { "201": {"description": "User created"} } } }, "/users/{userId}": { "get": { "summary": "Get user by ID", "description": "Returns a single user by their ID", "tags": ["users"], "parameters": [ { "name": "userId", "in": "path", "required": True, "schema": {"type": "string"} } ], "responses": { "200": {"description": "Successful response"}, "404": {"description": "User not found"} } }, "delete": { "summary": "Delete user", "description": "Deletes a user from the system", "tags": ["users"], "responses": { "204": {"description": "User deleted"} } } }, "/products": { "get": { "summary": "List products", "description": "Returns a list of all products", "tags": ["products"], "responses": { "200": {"description": "Successful response"} } } } }, "tags": [ {"name": "users", "description": "User management"}, {"name": "products", "description": "Product management"} ] } path = tmp_path / "test.json" path.write_text(json.dumps(spec)) return path