Documentation ¶
Overview ¶
Package openapi2 outputs to OpenAPI 2.0
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md http://json-schema.org/
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Contact ¶
type Contact struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Email string `json:"email,omitempty"` }
Contact provides contact information for the exposed API.
type Info ¶
type Info struct { Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Version string `json:"version,omitempty"` Contact Contact `json:"contact,omitempty"` }
Info provides metadata about the API.
type OpenAPI ¶
type OpenAPI struct { Swagger string `json:"swagger"` Info Info `json:"info"` // TODO: hacked on :-/ SecurityDefinitions map[string]any `json:"securityDefinitions,omitempty"` Security []map[string]any `json:"security,omitempty"` // TODO: do we need this? will have to come from config Host string `json:"host,omitempty"` BasePath string `json:"basePath,omitempty"` Schemes []string `json:"schemes,omitempty"` Consumes []string `json:"consumes,omitempty"` Produces []string `json:"produces,omitempty"` Tags []Tag `json:"tags,omitempty"` Paths map[string]*Path `json:"paths"` Definitions map[string]docparse.Schema `json:"definitions"` }
OpenAPI output.
type Operation ¶
type Operation struct { OperationID string `json:"operationId"` Tags []string `json:"tags,omitempty"` Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` Consumes []string `json:"consumes,omitempty"` Produces []string `json:"produces,omitempty"` Parameters []Parameter `json:"parameters,omitempty"` Responses map[int]Response `json:"responses"` }
Operation describes a single API operation on a path.
func (*Operation) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type Parameter ¶
type Parameter struct { Name string `json:"name"` In string `json:"in"` // query, header, path, cookie Description string `json:"description,omitempty"` Type string `json:"type,omitempty"` Items *docparse.Schema `json:"items,omitempty"` Format string `json:"format,omitempty"` Required bool `json:"required,omitempty"` Readonly *bool `json:"readOnly,omitempty"` Enum []string `json:"enum,omitempty"` Default string `json:"default,omitempty"` Minimum int `json:"minimum,omitempty"` Maximum int `json:"maximum,omitempty"` Schema *docparse.Schema `json:"schema,omitempty"` }
Parameter describes a single operation parameter.
type Path ¶
type Path struct { Ref string `json:"ref,omitempty"` Get *Operation `json:"get,omitempty"` Post *Operation `json:"post,omitempty"` Put *Operation `json:"put,omitempty"` Patch *Operation `json:"patch,omitempty"` Delete *Operation `json:"delete,omitempty"` Head *Operation `json:"head,omitempty"` }
Path describes the operations available on a single path.
type Reference ¶
type Reference struct {
Ref string `json:"$ref"`
}
Reference other components in the specification, internally and externally.
Click to show internal directories.
Click to hide internal directories.