Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sv-tools/openapi
OpenAPI v3.1 Spec implementation in Go with generics
https://github.com/sv-tools/openapi
generics-in-golang golang openapi openapi-validation openapi3 openapi31 swagger
Last synced: 4 days ago
JSON representation
OpenAPI v3.1 Spec implementation in Go with generics
- Host: GitHub
- URL: https://github.com/sv-tools/openapi
- Owner: sv-tools
- License: mit
- Created: 2021-12-19T03:11:04.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-15T18:53:17.000Z (12 days ago)
- Last Synced: 2024-12-15T19:10:34.560Z (12 days ago)
- Topics: generics-in-golang, golang, openapi, openapi-validation, openapi3, openapi31, swagger
- Language: Go
- Homepage:
- Size: 270 KB
- Stars: 48
- Watchers: 2
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: security-requirement.go
Awesome Lists containing this project
README
# OpenAPI v3.1 Specification
[![Code Analysis](https://github.com/sv-tools/openapi/actions/workflows/checks.yaml/badge.svg)](https://github.com/sv-tools/openapi/actions/workflows/code.yaml)
[![Go Reference](https://pkg.go.dev/badge/github.com/sv-tools/openapi.svg)](https://pkg.go.dev/github.com/sv-tools/openapi)
[![codecov](https://codecov.io/gh/sv-tools/openapi/branch/main/graph/badge.svg?token=0XVOTDR1CW)](https://codecov.io/gh/sv-tools/openapi)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/sv-tools/openapi?style=flat)](https://github.com/sv-tools/openapi/releases)The implementation of OpenAPI v3.1 Specification for Go using generics.
## Supported Go versions:
* v1.23
* v1.22
* v1.21## Versions:
* v0 - **Deprecated**. The initial version with the full implementation of the v3.1 Specification using generics. See `v0` branch.
* v1 - The current version with the in-place validation of the specification.
* The minimal version of Go is `v1.21`.
* Everything have been moved to root folder. So, the import path is `github.com/sv-tools/openapi`.
* Added `Validator` struct for validation of the specification and the data.
* `Validator.ValidateSpec()` method validates the specification.
* `Validator.ValidateData()` method validates the data.
* `Validator.ValidateDataAsJSON()` method validates the data by converting it into `map[string]any` type first using `json.Marshal` and `json.Unmarshal`.
**WARNING**: the function is slow due to double conversion.
* Use OpenAPI `v3.1.1` by default.## Features
* The official v3.0 and v3.1 [examples](https://github.com/OAI/OpenAPI-Specification/tree/main/examples) are tested.
In most cases v3.0 specification can be converted to v3.1 by changing the version's parameter only.
```diff
@@ -1,4 +1,4 @@
-openapi: "3.0.0"
+openapi: "3.1.0"
```**NOTE**: The descriptions of most structures and their fields are taken from the official documentations.
## Links
* OpenAPI Specification: and
* JSON Schema: and
* The list of most popular alternatives:## License
MIT licensed. See the bundled [LICENSE](LICENSE) file for more details.