diff --git a/src/mockapi/core/validator.py b/src/mockapi/core/validator.py index 8f4d6e9..cf22cc2 100644 --- a/src/mockapi/core/validator.py +++ b/src/mockapi/core/validator.py @@ -10,20 +10,12 @@ class OpenAPIValidator: """Validates OpenAPI 3.x specifications.""" def __init__(self, spec: Dict[str, Any]): - """Initialize the validator. - - Args: - spec: The OpenAPI specification dictionary - """ + """Initialize the validator.""" self.spec = spec self._validation_errors: List[str] = [] def validate(self) -> List[str]: - """Validate the OpenAPI specification. - - Returns: - List of validation error messages (empty if valid) - """ + """Validate the OpenAPI specification.""" self._validation_errors = [] try: @@ -48,49 +40,23 @@ class OpenAPIValidator: return str(error) def is_valid(self) -> bool: - """Check if the specification is valid. - - Returns: - True if valid, False otherwise - """ + """Check if the specification is valid.""" return len(self.validate()) == 0 def get_paths(self) -> List[str]: - """Get list of paths in the spec. - - Returns: - List of path strings - """ + """Get list of paths in the spec.""" return list(self.spec.get("paths", {}).keys()) def get_operations(self, path: str) -> Dict[str, Any]: - """Get all operations for a given path. - - Args: - path: The path to get operations for - - Returns: - Dictionary of method -> operation - """ + """Get all operations for a given path.""" path_item = self.spec.get("paths", {}).get(path, {}) methods = ["get", "post", "put", "delete", "patch", "options", "head", "trace"] return {m: path_item[m] for m in methods if m in path_item} def get_schema(self, schema_name: str) -> Optional[Dict[str, Any]]: - """Get a schema by name from components/schemas. - - Args: - schema_name: Name of the schema - - Returns: - Schema definition or None if not found - """ + """Get a schema by name from components/schemas.""" return self.spec.get("components", {}).get("schemas", {}).get(schema_name) def get_all_schemas(self) -> Dict[str, Any]: - """Get all schemas from the spec. - - Returns: - Dictionary of schema name -> schema definition - """ - return self.spec.get("components", {}).get("schemas", {}) \ No newline at end of file + """Get all schemas from the spec.""" + return self.spec.get("components", {}).get("schemas", {})