feat: add JSON Schema export functionality#532
Open
doubledare704 wants to merge 3 commits intoalecthomas:masterfrom
Open
feat: add JSON Schema export functionality#532doubledare704 wants to merge 3 commits intoalecthomas:masterfrom
doubledare704 wants to merge 3 commits intoalecthomas:masterfrom
Conversation
Add comprehensive JSON Schema export capability to voluptuous schemas, addressing issue alecthomas#408. This enables integration with modern IDEs, API documentation tools, and other validation systems. Features: - Convert voluptuous schemas to JSON Schema format - Support for all major validators (Range, Length, Email, URL, etc.) - Handle composite validators (All, Any, ExactSequence) - Proper Required/Optional marker conversion - Nested object and array schema support - Default value handling with JSON serialization safety API: - Schema.to_json_schema() method on Schema instances - to_json_schema() standalone function - Full backward compatibility maintained Testing: - Comprehensive test suite with 100% coverage - Real-world example scenarios - Edge case handling - JSON serialization validation Documentation: - Updated README with usage examples - Complete example script demonstrating features - Inline documentation and docstrings Closes alecthomas#408
- Replace bare except clause with specific exception types - Fix all 17 mypy type checking errors: * Add proper type annotations for Dict[str, Any] * Replace callable with typing.Callable * Fix incompatible type assignments * Resolve indexing operation type issues * Add type safety for validator method parameters - Remove unused import (voluptuous.validators) - Maintain full backward compatibility and functionality All flake8 and mypy checks now pass with zero issues. All 162 existing tests continue to pass.
efd7df1 to
d8092eb
Compare
This file contains hidden or 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
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.
Add comprehensive JSON Schema export capability to voluptuous schemas, addressing issue #408. This enables integration with modern IDEs, API documentation tools, and other validation systems.
Features:
API:
Testing:
Documentation:
Closes #408