@@ -21,13 +21,13 @@ ensuring that data complies with an expected format before it is used, which red
2121| 🚧 Null Safety | Full support for nullable and optional fields |
2222| ⚙️ Composable | Compiled and reusable schemas |
2323| ⚡ Fast Performance | ~ 29 000 000 ops/s |
24- | 📦 Extremely small size | Package size ` < 20kb ` |
24+ | 📦 Extremely small size | Package size ` < 21kb ` |
25+ | 🚀 OpenApi reporter | Export your schemas as OpenApi spec |
2526
2627## 🚀 Usage
2728
2829Vine is a data structure validation library for Dart. You may use it to validate the HTTP request body or any data in
29- your
30- backend applications.
30+ your backend applications.
3131
3232### Built for validating form data and JSON payloads
3333
@@ -57,13 +57,13 @@ import 'package:vine/vine.dart';
5757
5858void main() {
5959 final validator = vine.compile(
60- vine.object({
61- 'username': vine.string().minLength(3).maxLength(20),
62- 'email': vine.string().email(),
63- 'age': vine.number().min(18).optional(),
64- 'isAdmin': vine.boolean(),
65- 'features': vine.array(vine.string()),
66- }));
60+ vine.object({
61+ 'username': vine.string().minLength(3).maxLength(20),
62+ 'email': vine.string().email(),
63+ 'age': vine.number().min(18).optional(),
64+ 'isAdmin': vine.boolean(),
65+ 'features': vine.array(vine.string()),
66+ }));
6767
6868 try {
6969 final payload = {
@@ -82,6 +82,29 @@ void main() {
8282}
8383```
8484
85+ ### OpenAPI reporter
86+
87+ Vine can generate an OpenAPI schema from your validation schemas.
88+ This feature is useful when you want to document your API
89+
90+ ``` dart
91+ final schema = vine.object({
92+ 'stringField': vine.string().minLength(3).maxLength(20),
93+ 'emailField': vine.string().email(),
94+ 'numberField': vine.number().min(18).max(100),
95+ 'booleanField': vine.boolean(),
96+ 'enumField': vine.enumerate(MyEnum.values),
97+ 'arrayField': vine.array(vine.string().minLength(3).maxLength(20)).minLength(1),
98+ 'unionField': vine.union([
99+ vine.string().minLength(3).maxLength(20),
100+ vine.number().min(10).max(20),
101+ ]),
102+ });
103+
104+ final reporter = vine.openApi.report(schemas: {'MySchema': schema});
105+ print(reporter);
106+ ```
107+
85108## ❤️ Credit
86109
87110I would like to thank [ Harminder Virk] ( https://github.com/thetutlage ) for all his open-source work on Adonis.js and for
0 commit comments