You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- add validations for `multipleOf`
- add validations for some `format` specifiers for string, number and integer types
- convert to string when numbers are assigned to string types in models, because some languages may send data with numbers when the format specifier for string type allows it
Copy file name to clipboardExpand all lines: README.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,11 +54,49 @@ Following validations are incorporated into models:
54
54
- minimum length: must be a string value of length greater than or equal to a specified value
55
55
- maximum item count: must be a list value with number of items less than or equal to a specified value
56
56
- minimum item count: must be a list value with number of items greater than or equal to a specified value
57
+
- unique items: items must be unique
58
+
- maximum properties count: number of properties must be less than or equal to a specified value
59
+
- minimum properties count: number of properties must be greater than or equal to a specified value
57
60
- pattern: must match the specified regex pattern
61
+
- format: must match the specified format specifier (see subsection below for details)
58
62
- enum: value must be from a list of allowed values
63
+
- multiple of: must be a multiple of a specified value
59
64
60
65
Validations are imposed in the constructor and `setproperty!` methods of models.
61
66
67
+
#### Validations for format specifiers
68
+
69
+
String, number and integer data types can have an optional format modifier that serves as a hint at the contents and format of the string. Validations for the following OpenAPI defined formats are built in:
70
+
71
+
| Data Type | Format | Description |
72
+
|-----------|-----------|-------------|
73
+
| number | float | Floating-point numbers. |
74
+
| number | double | Floating-point numbers with double precision. |
75
+
| integer | int32 | Signed 32-bit integers (commonly used integer type). |
| string | date | full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21 |
78
+
| string | date-time | the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z |
79
+
| string | byte | base64-encoded characters, for example, U3dhZ2dlciByb2Nrcw== |
80
+
81
+
Validations for custom formats can be plugged in by overloading the `OpenAPI.val_format` method.
82
+
83
+
E.g.:
84
+
85
+
```julia
86
+
# add a new validation named `custom` for the number type
87
+
function OpenAPI.val_format(val::AbstractFloat, ::Val{:custom})
88
+
returntrue# do some validations and return result
89
+
end
90
+
# add a new validation named `custom` for the integer type
91
+
function OpenAPI.val_format(val::Integer, ::Val{:custom})
92
+
returntrue# do some validations and return result
93
+
end
94
+
# add a new validation named `custom` for the string type
95
+
function OpenAPI.val_format(val::AbstractString, ::Val{:custom})
96
+
returntrue# do some validations and return result
97
+
end
98
+
```
99
+
62
100
### Client APIs
63
101
64
102
Each client API set is generated into a file named `api_<apiname>.jl`. It is represented as a `struct` and the APIs under it are generated as methods. An API set can be constructed by providing the OpenAPI client instance that it can use for communication.
0 commit comments