Documentation ¶
Overview ¶
This package generates an OpenAPI document from comments in your code annotated with the @openapi keyword. It currently supports only the openapi 3.x schema and not the older swagger 2 schema.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateOpenApiDoc ¶
func GenerateOpenApiDoc(definition OpenAPIDefinition, validate bool) ([]byte, error)
GenerateOpenApiDoc parses all struct and func comments decorated with the @openapi keyword as well as any static definitions added directly to the OpenAPIDefinition object and generates an OpenAPI document that conforms to the OpenAPI 3 specification
func ValidateOpenApiDoc ¶
ValidateOpenApiDoc validates a document conforms to the OpenAPI 3 specification
Types ¶
type Components ¶
type Components struct { Schemas map[string]interface{} `json:"schemas,omitempty" yaml:"schemas,omitempty"` Parameters map[string]interface{} `json:"parameters,omitempty" yaml:"parameters,omitempty"` SecuritySchemes map[string]interface{} `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"` RequestBodies map[string]interface{} `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"` Responses map[string]interface{} `json:"responses,omitempty" yaml:"responses,omitempty"` Headers map[string]interface{} `json:"headers,omitempty" yaml:"headers,omitempty"` Examples map[string]interface{} `json:"examples,omitempty" yaml:"examples,omitempty"` Links map[string]interface{} `json:"links,omitempty" yaml:"links,omitempty"` Callbacks map[string]interface{} `json:"callbacks,omitempty" yaml:"callbacks,omitempty"` }
Components is used to add additional static definitions to the OpenAPIDefinition object which are then combined with structs and funcs decorated with @openapi comments
type ExternalDocs ¶
type ExternalDocs openapi3.ExternalDocs
ExternalDocs is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#external-documentation-object
type Info ¶
Info is specified by OpenAPI standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#info-object
type OpenAPIDefinition ¶
type OpenAPIDefinition struct { OpenAPI string `json:"openapi" yaml:"openapi"` Info Info `json:"info" yaml:"info"` Security Security `json:"security,omitempty" yaml:"security,omitempty"` Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"` Tags []Tag `json:"tags,omitempty" yaml:"tags,omitempty"` ExternalDocs ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` Components Components `json:"components,omitempty" yaml:"components,omitempty"` }
OpenAPIDefinition is used to define general properties of an API which is then combined with other definitions to generate an OpenAPI document
type Security ¶
type Security openapi3.SecurityRequirements
Security https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-scheme-object
type Server ¶
Server is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#server-object
type Tag ¶
Tag is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#tag-object