OpenAPI validation extension for libopenapi, validate http requests and responses as well as schemas
See the code
A validation module for libopenapi.
Document validation is explicitly covered for OpenAPI 3.0, 3.1, and 3.2.
The arazzo package also validates Arazzo 1.0 and 1.1
workflows, expressions and references to supplied API descriptions.
libopenapi-validator will validate the following elements against an OpenAPI 3+ specification
👉👉 Check out the full documentation 👈👈
The validator uses the maintained pb33f/jsonschema/v6 fork.
If you pass compiled schemas, implement a schema cache, configure a regex engine, or inspect
OriginalJsonSchemaError, update direct imports from github.com/santhosh-tekuri/jsonschema/v6
to github.com/pb33f/jsonschema/v6 (including /kind imports). Types from the two module
paths have different Go identities. Standard validator calls need no code changes.
The validator now includes a standalone OpenAPI router, authentication callbacks with route context and replayable bodies, immutable custom body codecs, opt-in request defaults, Parameter.content decoding, validation policy switches, and explicit OpenAPI 3.2 document validation.
Existing behavior remains the default. Strict server matching, non-JSON codecs, request mutation, and new rejection policies are opt-in:
v := validator.NewValidatorFromV3Model(&model.Model,
config.WithStrictServerMatching(),
config.WithStandardBodyDecoders(),
config.WithRejectUnsupportedBodyContent(),
config.WithRequestDefaults(),
)
Use router.NewRouter for routing without validation, WithBodyDecoder and WithBodyEncoder for proprietary formats, and WithAuthenticationFunc for application-owned security checks. See the complete validation guide for defaults, options, and examples.
go get github.com/pb33f/libopenapi-validator
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest [--regexengine] [--yaml2json] <file>
To install the pre-commit hook, run the following command in your terminal:
pre-commit install
🔍 Example: Use a custom regex engine/flag (e.g., ecmascript)
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest --regexengine=ecmascript <file>
🔧 Supported --regexengine flags/values (ℹ️ Default: re2)
🔍 Convert YAML files to JSON before validation (ℹ️ Default: false)
libopenapi passes map[interface{}]interface{} structures for deeply nested objects or complex mappings in the OpenAPI specification, which are not allowed in JSON.
These structures cannot be properly converted to JSON by libopenapi and cannot be validated by jsonschema, resulting in ambiguous errors.
This flag allows pre-converting from YAML to JSON to bypass this limitation of the libopenapi.
When does this happen?
allOf, oneOf, or anyOf structures with multiple levelsEnabling this flag pre-converts the YAML document from YAML to JSON, ensuring a clean JSON structure before validation.
Example:
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest --yaml2json <file>
libopenapi and libopenapi-validator are products of Princess Beef Heavy Industries, LLC
Overall
Maintained
Code review
Latest release
Releases this year
670 followers · starred May 2024
29 followers · starred Oct 2023
183 followers · starred Feb 2026
54 followers · starred Apr 2026
OpenAPI validation extension for libopenapi, validate http requests and responses as well as schemas
See the code
A validation module for libopenapi.
Document validation is explicitly covered for OpenAPI 3.0, 3.1, and 3.2.
The arazzo package also validates Arazzo 1.0 and 1.1
workflows, expressions and references to supplied API descriptions.
libopenapi-validator will validate the following elements against an OpenAPI 3+ specification
👉👉 Check out the full documentation 👈👈
The validator uses the maintained pb33f/jsonschema/v6 fork.
If you pass compiled schemas, implement a schema cache, configure a regex engine, or inspect
OriginalJsonSchemaError, update direct imports from github.com/santhosh-tekuri/jsonschema/v6
to github.com/pb33f/jsonschema/v6 (including /kind imports). Types from the two module
paths have different Go identities. Standard validator calls need no code changes.
The validator now includes a standalone OpenAPI router, authentication callbacks with route context and replayable bodies, immutable custom body codecs, opt-in request defaults, Parameter.content decoding, validation policy switches, and explicit OpenAPI 3.2 document validation.
Existing behavior remains the default. Strict server matching, non-JSON codecs, request mutation, and new rejection policies are opt-in:
v := validator.NewValidatorFromV3Model(&model.Model,
config.WithStrictServerMatching(),
config.WithStandardBodyDecoders(),
config.WithRejectUnsupportedBodyContent(),
config.WithRequestDefaults(),
)
Use router.NewRouter for routing without validation, WithBodyDecoder and WithBodyEncoder for proprietary formats, and WithAuthenticationFunc for application-owned security checks. See the complete validation guide for defaults, options, and examples.
go get github.com/pb33f/libopenapi-validator
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest [--regexengine] [--yaml2json] <file>
To install the pre-commit hook, run the following command in your terminal:
pre-commit install
🔍 Example: Use a custom regex engine/flag (e.g., ecmascript)
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest --regexengine=ecmascript <file>
🔧 Supported --regexengine flags/values (ℹ️ Default: re2)
🔍 Convert YAML files to JSON before validation (ℹ️ Default: false)
libopenapi passes map[interface{}]interface{} structures for deeply nested objects or complex mappings in the OpenAPI specification, which are not allowed in JSON.
These structures cannot be properly converted to JSON by libopenapi and cannot be validated by jsonschema, resulting in ambiguous errors.
This flag allows pre-converting from YAML to JSON to bypass this limitation of the libopenapi.
When does this happen?
allOf, oneOf, or anyOf structures with multiple levelsEnabling this flag pre-converts the YAML document from YAML to JSON, ensuring a clean JSON structure before validation.
Example:
go run github.com/pb33f/libopenapi-validator/cmd/validate@latest --yaml2json <file>
libopenapi and libopenapi-validator are products of Princess Beef Heavy Industries, LLC
Overall
Maintained
Code review
Latest release
Releases this year
670 followers · starred May 2024
29 followers · starred Oct 2023
183 followers · starred Feb 2026
54 followers · starred Apr 2026