https://github.com/pb33f/libopenapi
libopenapi is a fully featured, high performance OpenAPI 3.2, 3.1, 3.0 and Swagger parser, library, validator and toolkit for golang applications.
https://github.com/pb33f/libopenapi
diff go golang library oas oasv3 openapi openapi-spec openapi-specification openapi3 openapi3-1 openapi3-validation openapi31 parser swagger swagger-api swagger2
Last synced: 1 day ago
JSON representation
libopenapi is a fully featured, high performance OpenAPI 3.2, 3.1, 3.0 and Swagger parser, library, validator and toolkit for golang applications.
- Host: GitHub
- URL: https://github.com/pb33f/libopenapi
- Owner: pb33f
- License: mit
- Created: 2022-07-17T19:41:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-02-02T23:04:33.000Z (2 days ago)
- Last Synced: 2026-02-03T11:44:56.855Z (2 days ago)
- Topics: diff, go, golang, library, oas, oasv3, openapi, openapi-spec, openapi-specification, openapi3, openapi3-1, openapi3-validation, openapi31, parser, swagger, swagger-api, swagger2
- Language: Go
- Homepage: https://pb33f.io/libopenapi/
- Size: 8.68 MB
- Stars: 778
- Watchers: 7
- Forks: 96
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# libopenapi - enterprise grade OpenAPI tools for golang.

[](https://goreportcard.com/report/github.com/pb33f/libopenapi)
[](https://codecov.io/gh/pb33f/libopenapi)
[](https://discord.gg/x7VACVuEGP)
[](https://pkg.go.dev/github.com/pb33f/libopenapi)
libopenapi has full support for OpenAPI 3, 3.1 and 3.2. It can handle the largest and most
complex specifications you can think of.
---
## Sponsors & users
If your company is using `libopenapi`, please considering [supporting this project](https://github.com/sponsors/daveshanley),
like our _very kind_ sponsors:

[Speakeasy](https://speakeasy.com/editor?utm_source=libopenapi+repo&utm_medium=github+sponsorship)

[scalar](https://scalar.com)

[apideck](https://apideck.com)
---
## Come chat with us
Need help? Have a question? Want to share your work? [Join our discord](https://discord.gg/x7VACVuEGP) and
come say hi!
## Check out the `libopenapi-validator`
Need to validate requests, responses, parameters or schemas? Use the new
[libopenapi-validator](https://github.com/pb33f/libopenapi-validator) module.
## Documentation
See all the documentation at https://pb33f.io/libopenapi/
- [Installing libopenapi](https://pb33f.io/libopenapi/installing/)
- [Using OpenAPI](https://pb33f.io/libopenapi/openapi/)
- [Using Swagger](https://pb33f.io/libopenapi/swagger/)
- [The Data Model](https://pb33f.io/libopenapi/model/)
- [Validation](https://pb33f.io/libopenapi/validation/)
- [Modifying / Mutating the OpenAPI Model](https://pb33f.io/libopenapi/modifying/)
- [Mocking / Creating Examples](https://pb33f.io/libopenapi/mocks/)
- [Using Vendor Extensions](https://pb33f.io/libopenapi/extensions/)
- [The Index](https://pb33f.io/libopenapi/index/)
- [The Resolver](https://pb33f.io/libopenapi/resolver/)
- [The Rolodex](https://pb33f.io/libopenapi/rolodex/)
- [Circular References](https://pb33f.io/libopenapi/circular-references/)
- [Bundling Specs](https://pb33f.io/libopenapi/bundling/)
- [What Changed / Diff Engine](https://pb33f.io/libopenapi/what-changed/)
- [Overlays](https://pb33f.io/libopenapi/overlays/)
- [FAQ](https://pb33f.io/libopenapi/faq/)
- [About libopenapi](https://pb33f.io/libopenapi/about/)
---
### Quick-start tutorial
👀 **Get rolling fast using `libopenapi` with the
[Parsing OpenAPI files using go](https://quobix.com/articles/parsing-openapi-using-go/)** guide 👀
Or, follow these steps and see something in a few seconds.
#### Step 1: Grab the petstore
```bash
curl https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/_archive_/schemas/v3.0/pass/petstore.yaml > petstorev3.json
```
#### Step 2: Grab libopenapi
```bash
go get github.com/pb33f/libopenapi
```
#### Step 3: Parse the petstore using libopenapi
Copy and paste this code into a `main.go` file.
```go
package main
import (
"fmt"
"os"
"github.com/pb33f/libopenapi"
)
func main() {
petstore, _ := os.ReadFile("petstorev3.json")
document, err := libopenapi.NewDocument(petstore)
if err != nil {
panic(fmt.Sprintf("cannot create new document: %e", err))
}
docModel, err := document.BuildV3Model()
if err != nil {
panic(fmt.Sprintf("cannot create v3 model from document: %e", err))
}
// The following fails after the first iteration
for schemaName, schema := range docModel.Model.Components.Schemas.FromOldest() {
if schema.Schema().Properties != nil {
fmt.Printf("Schema '%s' has %d properties\n", schemaName, schema.Schema().Properties.Len())
}
}
}
```
Run it, which should print out:
```bash
Schema 'Pet' has 3 properties
Schema 'Error' has 2 properties
```
> Read the full docs at [https://pb33f.io/libopenapi/](https://pb33f.io/libopenapi/)
---
Logo gopher is modified, originally from [egonelbre](https://github.com/egonelbre/gophers)