libopenapi-validator
Full Documentation coming shortly, now ready for early testing.
Example use:
// 1. Load the OpenAPI 3+ spec into a byte array petstore, err := os.ReadFile("test_specs/invalid_31.yaml") if err != nil { panic(err) } // 2. Create a new OpenAPI document using libopenapi document, docErrs := libopenapi.NewDocument(petstore) if docErrs != nil { panic(docErrs) } // 3. Create a new validator docValidator, validatorErrs := NewValidator(document) if validatorErrs != nil { panic(validatorErrs) } // 4. Validate! valid, validationErrs := docValidator.ValidateDocument() if !valid { for i, e := range validationErrs { // 5. Handle the error fmt.Printf("%d: Type: %s, Failure: %s\n", i, e.ValidationType, e.Message) fmt.Printf("Fix: %s\n\n", e.HowToFix) } } // Output: 0: Type: schema, Failure: Document does not pass validation //Fix: Ensure that the object being submitted, matches the schema correctly
0 commit comments