MCPcopy Create free account
hub / github.com/baerwang/openapi-rs / test_pattern_validation

Function test_pattern_validation

src/validator/validator_test.rs:868–1009  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

866
867 #[test]
868 fn test_pattern_validation() {
869 let content = r#"
870openapi: 3.1.0
871info:
872 title: Pattern Validation Test API
873 description: API for testing pattern validation
874 version: '1.0.0'
875
876components:
877 schemas:
878 UserRequest:
879 type: object
880 properties:
881 email:
882 type: string
883 pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
884 description: User email address
885 phone:
886 type: string
887 pattern: '^\+?1?[-.\s]?\(?[0-9]{3}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}$'
888 description: User phone number
889 username:
890 type: string
891 pattern: '^[a-zA-Z0-9_]{3,20}$'
892 description: Username with alphanumeric and underscore only
893 required:
894 - email
895 - username
896
897paths:
898 /users:
899 post:
900 parameters:
901 - name: userId
902 in: query
903 required: true
904 schema:
905 type: string
906 pattern: '^[0-9]+$'
907 description: Numeric user ID
908 - name: token
909 in: query
910 required: false
911 schema:
912 type: string
913 pattern: '^[A-Za-z0-9]{32}$'
914 description: 32-character alphanumeric token
915 requestBody:
916 required: true
917 content:
918 application/json:
919 schema:
920 $ref: '#/components/schemas/UserRequest'
921 responses:
922 '201':
923 description: User created successfully
924"#;
925

Callers

nothing calls this directly

Calls 2

validatorMethod · 0.80

Tested by

no test coverage detected