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
Copy file name to clipboardExpand all lines: README.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,8 +31,12 @@ go get github.com/pb33f/libopenapi-validator
31
31
## Validate OpenAPI Document
32
32
33
33
```bash
34
-
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest [--regexengine] <file>
34
+
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest [--regexengine] [--yaml2json] <file>
35
35
```
36
+
37
+
### Options
38
+
39
+
#### --regexengine
36
40
🔍 Example: Use a custom regex engine/flag (e.g., ecmascript)
37
41
```bash
38
42
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest --regexengine=ecmascript <file>
@@ -51,6 +55,26 @@ go run github.com/pb33f/libopenapi-validator/cmd/validate@latest --regexengine=e
51
55
- re2
52
56
- unicode
53
57
58
+
#### --yaml2json
59
+
🔍 Convert YAML files to JSON before validation (ℹ️ Default: false)
60
+
61
+
[libopenapi](https://github.com/pb33f/libopenapi/blob/main/datamodel/spec_info.go#L115) passes `map[interface{}]interface{}` structures for deeply nested objects or complex mappings in the OpenAPI specification, which are not allowed in JSON.
62
+
These structures cannot be properly converted to JSON by libopenapi and cannot be validated by jsonschema, resulting in ambiguous errors.
63
+
64
+
This flag allows pre-converting from YAML to JSON to bypass this limitation of the libopenapi.
65
+
66
+
**When does this happen?**
67
+
- OpenAPI specs with deeply nested schema definitions
68
+
- Complex `allOf`, `oneOf`, or `anyOf` structures with multiple levels
69
+
- Specifications with intricate object mappings in examples or schema properties
70
+
71
+
Enabling this flag pre-converts the YAML document from YAML to JSON, ensuring a clean JSON structure before validation.
72
+
73
+
Example:
74
+
```bash
75
+
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest --yaml2json <file>
76
+
```
77
+
54
78
## Documentation
55
79
56
80
-[The structure of the validator](https://pb33f.io/libopenapi/validation/#the-structure-of-the-validator)
0 commit comments