Documentation
¶
Index ¶
- func BuildExampleURL(server, path string, params []Parameter) string
- func DiscoverAPIs(rootDir string) []string
- func GenerateExampleObject(schema *Schema) string
- func GenerateExampleValue(schema *Schema, name string) interface{}
- func GetRequiredHeaders(params []Parameter) map[string]string
- type APIDoc
- type Components
- type Endpoint
- type ExampleObject
- type Info
- type MediaType
- type Operation
- type Parameter
- type PathItem
- type RequestBody
- type Response
- type Schema
- type SecurityReq
- type Server
- type Spec
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildExampleURL ¶ added in v1.1.2
func DiscoverAPIs ¶
DiscoverAPIs scans the apis/ directory in rootDir for OpenAPI spec files (.yaml, .yml, .json).
func GenerateExampleObject ¶ added in v1.1.2
GenerateExampleObject renders a pretty-printed JSON example for a schema.
func GenerateExampleValue ¶ added in v1.1.2
GenerateExampleValue builds an example value for a schema. An explicit `example` on the schema always wins; otherwise it composes from properties / items / enum, falling back to type-based placeholders.
func GetRequiredHeaders ¶ added in v1.1.2
Types ¶
type APIDoc ¶
type Components ¶
type Components struct {
Schemas map[string]*Schema `json:"schemas,omitempty" yaml:"schemas,omitempty"`
Parameters map[string]*Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
RequestBodies map[string]*RequestBody `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"`
Responses map[string]*Response `json:"responses,omitempty" yaml:"responses,omitempty"`
}
type ExampleObject ¶ added in v1.1.4
type ExampleObject struct {
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Value interface{} `json:"value,omitempty" yaml:"value,omitempty"`
}
ExampleObject is an OpenAPI Example Object (the `value` is what we render).
type MediaType ¶
type MediaType struct {
Schema *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
Example interface{} `json:"example,omitempty" yaml:"example,omitempty"`
Examples map[string]ExampleObject `json:"examples,omitempty" yaml:"examples,omitempty"`
}
type Operation ¶
type Operation struct {
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"`
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
Responses map[string]Response `json:"responses,omitempty" yaml:"responses,omitempty"`
Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
Security []SecurityReq `json:"security,omitempty" yaml:"security,omitempty"`
}
type Parameter ¶
type Parameter struct {
Name string `json:"name" yaml:"name"`
In string `json:"in" yaml:"in"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
Schema *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
}
type PathItem ¶
type PathItem struct {
Get *Operation `json:"get,omitempty" yaml:"get,omitempty"`
Post *Operation `json:"post,omitempty" yaml:"post,omitempty"`
Put *Operation `json:"put,omitempty" yaml:"put,omitempty"`
Delete *Operation `json:"delete,omitempty" yaml:"delete,omitempty"`
Patch *Operation `json:"patch,omitempty" yaml:"patch,omitempty"`
Options *Operation `json:"options,omitempty" yaml:"options,omitempty"`
Head *Operation `json:"head,omitempty" yaml:"head,omitempty"`
}
type RequestBody ¶
type Schema ¶
type Schema struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Format string `json:"format,omitempty" yaml:"format,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Properties map[string]*Schema `json:"properties,omitempty" yaml:"properties,omitempty"`
Items *Schema `json:"items,omitempty" yaml:"items,omitempty"`
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
Required []string `json:"required,omitempty" yaml:"required,omitempty"`
Enum []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"`
Example interface{} `json:"example,omitempty" yaml:"example,omitempty"`
AllOf []*Schema `json:"allOf,omitempty" yaml:"allOf,omitempty"`
OneOf []*Schema `json:"oneOf,omitempty" yaml:"oneOf,omitempty"`
AnyOf []*Schema `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`
RefName string `json:"-" yaml:"-"`
}
func (*Schema) TypeString ¶
type SecurityReq ¶
type Spec ¶
type Spec struct {
OpenAPI string `json:"openapi" yaml:"openapi"`
Info Info `json:"info" yaml:"info"`
Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"`
Paths map[string]*PathItem `json:"paths" yaml:"paths"`
Tags []Tag `json:"tags,omitempty" yaml:"tags,omitempty"`
Components *Components `json:"components,omitempty" yaml:"components,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.