Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alpdr/gindocnic
An OpenAPI 3.1 specification generator for Gin Web Framework
https://github.com/alpdr/gindocnic
gin gin-gonic go golang openapi openapi-specification openapi3
Last synced: 3 days ago
JSON representation
An OpenAPI 3.1 specification generator for Gin Web Framework
- Host: GitHub
- URL: https://github.com/alpdr/gindocnic
- Owner: alpdr
- License: mit
- Created: 2024-11-05T02:27:43.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-20T06:51:43.000Z (6 days ago)
- Last Synced: 2024-12-20T07:33:36.026Z (6 days ago)
- Topics: gin, gin-gonic, go, golang, openapi, openapi-specification, openapi3
- Language: Go
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gindocnic
[![Go Report Card](https://goreportcard.com/badge/github.com/alpdr/gindocnic)](https://goreportcard.com/report/github.com/alpdr/gindocnic)
[![Go Reference](https://pkg.go.dev/badge/github.com/alpdr/gindocnic.svg)](https://pkg.go.dev/github.com/alpdr/gindocnic)
[![release](https://img.shields.io/github/v/release/alpdr/gindocnic.svg?style=flat-square)](https://github.com/alpdr/gindocnic/releases)A library for generating OpenAPI 3.1 documentation for the Gin Web Framework.
## Usage
A basic example:
```go
doc := NewDoc()
r := gin.Default()request := struct {
Id int `json:"id" binding:"required"`
}{}
spec := func(p *PathItemSpec) {
p.AddRequest(request)
}
r.POST("/pets", doc.Operation(func(c *gin.Context) {}, spec))
if err := doc.AssocRoutesInfo(r.Routes()); err != nil {
log.Fatalf("%#v", err)
}
yml, err := doc.MarshalYAML()
if err != nil {
log.Fatalf("%#v", err)
}
fmt.Println(string(yml))
```Output:
```
openapi: 3.1.0
info:
title: ""
version: ""
paths:
/pets:
post:
operationId: pets0
requestBody:
content:
application/json:
schema:
properties:
id:
type: integer
required:
- id
type: object
responses:
"204":
description: No Content
summary: ""
```Further examples are available in the [API documentation on go.dev](https://pkg.go.dev/github.com/alpdr/gindocnic).
## Contributing
- The layout of this module loosely follows [a basic layout for Go application projects](https://github.com/golang-standards/project-layout).