gindocnic

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 7 Imported by: 0

README

Gindocnic

Go Report Card Go Reference release

A library for generating OpenAPI 3.1 documentation for the Gin Web Framework.

Contributing

Documentation

Overview

Package gindocnic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestContentType

func RequestContentType(contentType string) func(ro *requestOptions)

RequestContentType リクエストのContent-Typeを設定します。 AddRequestの可変長引数に渡してください。

func ResponseStatus

func ResponseStatus(status int) responseOption

Types

type Doc

type Doc struct {
	// contains filtered or unexported fields
}

Doc OpenAPI定義書の全体の情報をもちます。

func NewDoc

func NewDoc() *Doc

NewDoc Docを作り、そのポインタを返します。

func (*Doc) AssocRoutesInfo

func (d *Doc) AssocRoutesInfo(routes gin.RoutesInfo) error

AssocRoutesInfo リクエストハンドラをパスやHTTPメソッドと関連づけて、Open API仕様書に必要な情報をそろえます。

func (*Doc) MarshalYAML

func (d *Doc) MarshalYAML() ([]byte, error)

MarshalYAML yaml形式のOpen API定義をバイト列で返します。

func (*Doc) Operation

func (d *Doc) Operation(h gin.HandlerFunc, opts ...PathItemSpecFunc) gin.HandlerFunc

Operation

func (*Doc) WithLicense

func (d *Doc) WithLicense(name, url string) *Doc

WithSummary [info-object]のlicenseを登録します。 [info-object]: https://spec.openapis.org/oas/v3.1.0.html#info-object

func (*Doc) WithSecurity

func (d *Doc) WithSecurity(securities map[string][]string) *Doc

WithSecurity [Security Scheme Object]を登録します。 一部のAPIで求められる認証の形式を宣言します。Basic認証やOpen ID Connectなどを指定できます。 Open APIの仕様上必須のフィールドらしいです。 [Security Scheme Object]: https://spec.openapis.org/oas/v3.1.0.html#security-scheme-object

func (*Doc) WithServer

func (d *Doc) WithServer(url string) *Doc

WithServer [server]を登録します。 [server]: https://spec.openapis.org/oas/v3.1.0.html#server-object

func (*Doc) WithSummary

func (d *Doc) WithSummary(summary string) *Doc

WithSummary [info-object]のsummaryを登録します。 [info-object]: https://spec.openapis.org/oas/v3.1.0.html#info-object

type PathItemSpec

type PathItemSpec struct {
	// contains filtered or unexported fields
}

PathItemSpec [path-item-object]の生成に必要な情報をもちます。 もともとはOperationOptionsという名前でしたが、[コードレビューのコメント]とoperationより上位の path-itemのスキーマにあるhttp methodやpathを含む構造体なので、PathItemSpecに名前を変えました。 [コードレビューのコメント]: https://github.com/alpdr/data-platform/pull/481#discussion_r1804170012 [path-item-object]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-item-object

func (*PathItemSpec) AddRequest

func (o *PathItemSpec) AddRequest(body any, opts ...requestOption)

AddRequest Operationにリクエストを追加します。

func (*PathItemSpec) AddResponse

func (o *PathItemSpec) AddResponse(body any, opts ...responseOption)

func (*PathItemSpec) SetMethod

func (o *PathItemSpec) SetMethod(method string)

func (*PathItemSpec) SetPath

func (o *PathItemSpec) SetPath(path string)

func (*PathItemSpec) SetSummary

func (o *PathItemSpec) SetSummary(s string)

type PathItemSpecFunc

type PathItemSpecFunc func(o *PathItemSpec)

PathItemSpecFunc

func OperationMethod

func OperationMethod(method string) PathItemSpecFunc

OperationMethod

func OperationSummary

func OperationSummary(summary string) PathItemSpecFunc

OperationSummary

func PathItemSpecPath

func PathItemSpecPath(path string) PathItemSpecFunc

PathItemSpecPath

Directories

Path Synopsis
Package internal
Package internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL