Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateProto ¶
func GenerateProto(api *APIDefinition, annotate bool) ([]byte, error)
GenerateProto will attempt to generate an protobuf version 3 schema from the given OpenAPI definition.
func PathMethodToName ¶
Types ¶
type APIDefinition ¶
type APIDefinition struct { FileName string // internal use to pass file path Swagger string `yaml:"swagger" json:"swagger"` Info struct { Title string `yaml:"title" json:"title"` Description string `yaml:"description" json:"description"` Version string `yaml:"version" json:"version"` } `yaml:"info" json:"info"` Host string `yaml:"host" json:"host"` Schemes []string `yaml:"schemes" json:"schemes"` BasePath string `yaml:"basePath" json:"basePath"` Produces []string `yaml:"produces" json:"produces"` Paths map[string]*Path `yaml:"paths" json:"paths"` Definitions map[string]*Items `yaml:"definitions" json:"definitions"` Parameters map[string]*Items `yaml:"parameters" json:"parameters"` }
APIDefinition is the base struct for containing OpenAPI spec declarations.
func LoadDefinition ¶
func LoadDefinition(pth string) (*APIDefinition, error)
type Endpoint ¶
type Endpoint struct { Summary string `yaml:"summary" json:"summary"` Description string `yaml:"description" json:"description"` Parameters Parameters `yaml:"parameters" json:"parameters"` Tags []string `yaml:"tags" json:"tags"` Responses map[string]*Response `yaml:"responses" json:"responses"` }
Endpoint represents an endpoint for a path in an OpenAPI spec.
type Items ¶
type Items struct { Description string `yaml:"description,omitempty" json:"description,omitempty"` // scalar Type interface{} `yaml:"type" json:"type"` Format interface{} `yaml:"format,omitempty" json:"format,omitempty"` Enum []string `yaml:"enum,omitempty" json:"enum,omitempty"` ProtoTag int `yaml:"x-proto-tag" json:"x-proto-tag"` // Map type AdditionalProperties *Items `yaml:"additionalProperties" json:"additionalProperties"` // ref another Model Ref string `yaml:"$ref"json:"$ref"` // is an array Items *Items `yaml:"items" json:"items"` // for request parameters In string `yaml:"in" json:"in"` Schema *Items `yaml:"schema" json:"schema"` // is an other Model Model `yaml:",inline"` }
Items represent Model properties in an OpenAPI spec.
func (Items) HasComment ¶
type Model ¶
type Model struct { Properties map[string]*Items `yaml:"properties" json:"properties"` Name string Depth int }
Model represents a model definition from an OpenAPI spec.
type Parameters ¶
type Parameters []*Items
Parameters is a slice of request parameters for a single endpoint.
func (Parameters) ProtoMessage ¶
func (p Parameters) ProtoMessage(parent Parameters, endpointName string, defs map[string]*Items) string
ProtoMessage will return a protobuf v3 message that represents the request Parameters.
type Path ¶
type Path struct { Get *Endpoint `yaml:"get" json:"get"` Put *Endpoint `yaml:"put" json:"put"` Post *Endpoint `yaml:"post" json:"post"` Delete *Endpoint `yaml:"delete" json:"delete"` Parameters Parameters `yaml:"parameters" json:"parameters"` }
Path represents all of the endpoints and parameters available for a single path.
func (*Path) ProtoEndpoints ¶
ProtoEndpoints will return any protobuf v3 endpoints for gRPC service declarations.
type Response ¶
type Response struct { Description string `yaml:"description" json:"description"` Schema *Items `yaml:"schema" json:"schema"` }
Response represents the response object in an OpenAPI spec.
func (*Response) ProtoMessage ¶
ProtoMessage will return a protobuf message declaration based on the response schema. If the response is an array type, it will get wrapped in a generic message with a single 'items' field to contain the array.