Libopenapi
libopenapi is a fully featured, high performance OpenAPI 3.2, 3.1, 3.0, Overlays and Arazzo parser, library, validator and toolkit for go applications.
Install / Use
/learn @pb33f/LibopenapiREADME
libopenapi - enterprise grade OpenAPI tools for golang.
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.
Overlays and Arazzo are also fully supported.
Sponsors & users
If your company is using libopenapi, please considering supporting this project,
like our very kind sponsors:
Come chat with us
Need help? Have a question? Want to share your work? Join our discord and come say hi!
Check out the libopenapi-validator
Need to validate requests, responses, parameters or schemas? Use the new libopenapi-validator module.
Documentation
See all the documentation at https://pb33f.io/libopenapi/
- Installing libopenapi
- Using OpenAPI
- Using Swagger
- The Data Model
- Validation
- Modifying / Mutating the OpenAPI Model
- Mocking / Creating Examples
- Using Vendor Extensions
- The Index
- The Resolver
- The Rolodex
- Circular References
- Bundling Specs
- What Changed / Diff Engine
- Overlays
- Arazzo
- FAQ
- About libopenapi
Quick-start tutorial
👀 Get rolling fast using libopenapi with the
Parsing OpenAPI files using go guide 👀
Or, follow these steps and see something in a few seconds.
Step 1: Grab the petstore
curl https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/_archive_/schemas/v3.0/pass/petstore.yaml > petstorev3.json
Step 2: Grab libopenapi
go get github.com/pb33f/libopenapi
Step 3: Parse the petstore using libopenapi
Copy and paste this code into a main.go file.
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:
Schema 'Pet' has 3 properties
Schema 'Error' has 2 properties
Read the full docs at https://pb33f.io/libopenapi/
Logo gopher is modified, originally from egonelbre
Related Skills
xurl
335.9kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
kubeshark
11.8kCluster-wide network observability for Kubernetes. Captures L4 packets, L7 API calls, and decrypted TLS traffic using eBPF, with full Kubernetes context. Available to AI agents via MCP and human operators via dashboard.
gin-vue-admin
24.5k🚀Vite+Vue3+Gin拥有AI辅助的基础开发平台,企业级业务AI+开发解决方案,内置mcp辅助服务,内置skills管理,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器、表单生成器和可配置的导入导出等开发必备功能。
kratos
25.6kYour ultimate Go microservices framework for the cloud-native era.
