Documentation ¶
Overview ¶
Package chioas - Go package for building OAS (OpenApi Specs) for Chi APIs
Index ¶
- Variables
- type Additional
- type Components
- type Contact
- type Definition
- type DocOptions
- type ExternalDocs
- type Info
- type License
- type Method
- type Methods
- type Path
- type PathParam
- type PathParams
- type Paths
- type Property
- type QueryParam
- type QueryParams
- type Request
- type Response
- type Responses
- type Schema
- type Schemas
- type Server
- type Servers
- type Tag
- type Tags
Constants ¶
This section is empty.
Variables ¶
View Source
var MethodsOrder = []string{ http.MethodGet, http.MethodHead, http.MethodOptions, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete, }
View Source
var OasVersion = "3.0.3"
Functions ¶
This section is empty.
Types ¶
type Additional ¶
Additional is an interface that can be supplied to many parts of the definition to write additional yaml to the OAS
type Components ¶
type Components struct { Schemas Schemas Additional Additional }
type Definition ¶
type Definition struct { DocOptions DocOptions //Context string Info Info Servers Servers Tags Tags Methods Methods // methods on api root Middlewares chi.Middlewares // chi middlewares for api root Paths Paths // descendant paths Components *Components Additional Additional }
Definition is the overall definition of an api
func (*Definition) AsYaml ¶
func (d *Definition) AsYaml() ([]byte, error)
func (*Definition) SetupRoutes ¶
func (d *Definition) SetupRoutes(router chi.Router, thisApi any) error
SetupRoutes sets up the API routes on the supplied chi.Router
Pass the thisApi arg if any of the methods use method by name
type DocOptions ¶
type DocOptions struct { // ServeDocs whether to serve api docs ServeDocs bool // Context is the optional path prefix for all paths in OAS spec Context string // NoCache if set to true, docs page and spec aren't cached (and built on each call) NoCache bool // Path the path on which to serve api docs page and spec (defaults to "/docs") Path string // DocIndexPage the name of the docs index page (defaults to "index.htm") DocIndexPage string // Title the title in the docs index page (defaults to "API Documentation") Title string // RedocOptions redoc options to be used (see https://github.com/Redocly/redoc#redoc-options-object) RedocOptions map[string]any // SpecName the name of the OAS spec (defaults to "spec.yaml") SpecName string // DocTemplate template for the docs page (defaults to internal template if an empty string) DocTemplate string // StylesOverride css styling overrides (injected into docs index page) StylesOverride string // DefaultResponses is the default responses for methods that don't have any responses defined // // is a map of http status code and response DefaultResponses Responses }
DocOptions determines whether/how the api will serve interactive docs page
type ExternalDocs ¶
type Info ¶
type Info struct { Title string Description string Version string TermsOfService string Contact *Contact License *License Additional Additional ExternalDocs *ExternalDocs }
type Method ¶
type Method struct { Description string Summary string Handler any // can be a http.HandlerFunc or a string method name OperationId string Tag string QueryParams QueryParams Request *Request Responses Responses Additional Additional }
type Path ¶
type Path struct { Methods Methods Paths Paths Middlewares chi.Middlewares // chi middlewares for path Tag string PathParams PathParams }
type PathParam ¶
type PathParam struct { Description string Example any Additional Additional }
type PathParams ¶
type QueryParam ¶
type QueryParams ¶
type QueryParams []QueryParam
type Server ¶
type Server struct { Description string Additional Additional }
type Tag ¶
type Tag struct { Name string Description string ExternalDocs *ExternalDocs Additional Additional }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.