package openapi2
import "zgo.at/kommentaar/openapi2"
Package openapi2 outputs to OpenAPI 2.0
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md http://json-schema.org/
Index ¶
- func WriteJSON(w io.Writer, prog *docparse.Program) error
- func WriteJSONIndent(w io.Writer, prog *docparse.Program) error
- type Contact
- type Info
- type OpenAPI
- type Operation
- type Parameter
- type Path
- type Reference
- type Response
- type Tag
Functions ¶
func WriteJSON ¶
WriteJSON writes to w as JSON.
func WriteJSONIndent ¶
WriteJSONIndent writes to w as indented JSON.
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.
type Response ¶
type Response struct { Description string `json:"description,omitempty"` Schema *docparse.Schema `json:"schema,omitempty"` }
Response describes a single response from an API Operation.
type Tag ¶
type Tag struct { Name string `json:"name"` }
Tag adds metadata to a single tag that is used by the Operation type.
Source Files ¶
openapi2.go
- Version
- v0.0.0-20230517222226-0b90222c1cce (latest)
- Published
- May 17, 2023
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 1 week ago –
Tools for package owners.