Documentation ¶
Overview ¶
Package ogen implements OpenAPI v3 code generation.
Index ¶
- type AdditionalProperties
- func (p *AdditionalProperties) MarshalJSON() ([]byte, error)
- func (p AdditionalProperties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
- func (p *AdditionalProperties) ToJSONSchema() *jsonschema.AdditionalProperties
- func (p *AdditionalProperties) UnmarshalJSON(data []byte) error
- func (p *AdditionalProperties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
- func (p *AdditionalProperties) UnmarshalYAML(node *yaml.Node) error
- type Components
- type Contact
- type Default
- type Discriminator
- type Encoding
- type Enum
- type Example
- type ExampleValue
- type ExternalDocumentation
- type Header
- type Info
- type License
- type Locator
- type Media
- type NamedParameter
- type NamedPathItem
- type NamedRequestBody
- type NamedResponse
- type NamedSchema
- type Num
- type OAuthFlow
- type OAuthFlows
- type Operation
- func (o *Operation) AddNamedResponses(ps ...*NamedResponse) *Operation
- func (o *Operation) AddParameters(ps ...*Parameter) *Operation
- func (o *Operation) AddResponse(n string, p *Response) *Operation
- func (o *Operation) AddTags(ts ...string) *Operation
- func (o *Operation) SetDescription(d string) *Operation
- func (o *Operation) SetOperationID(id string) *Operation
- func (o *Operation) SetParameters(ps []*Parameter) *Operation
- func (o *Operation) SetRequestBody(r *RequestBody) *Operation
- func (o *Operation) SetResponses(r Responses) *Operation
- func (o *Operation) SetSummary(s string) *Operation
- func (o *Operation) SetTags(ts []string) *Operation
- func (o *Operation) UnmarshalYAML(n *yaml.Node) error
- type Parameter
- func (p *Parameter) InCookie() *Parameter
- func (p *Parameter) InHeader() *Parameter
- func (p *Parameter) InPath() *Parameter
- func (p *Parameter) InQuery() *Parameter
- func (p *Parameter) SetContent(c map[string]Media) *Parameter
- func (p *Parameter) SetDeprecated(d bool) *Parameter
- func (p *Parameter) SetDescription(d string) *Parameter
- func (p *Parameter) SetExplode(e bool) *Parameter
- func (p *Parameter) SetIn(i string) *Parameter
- func (p *Parameter) SetName(n string) *Parameter
- func (p *Parameter) SetRef(r string) *Parameter
- func (p *Parameter) SetRequired(r bool) *Parameter
- func (p *Parameter) SetSchema(s *Schema) *Parameter
- func (p *Parameter) SetStyle(s string) *Parameter
- func (p *Parameter) ToNamed(n string) *NamedParameter
- func (p *Parameter) UnmarshalYAML(n *yaml.Node) error
- type PathItem
- func (p *PathItem) AddParameters(ps ...*Parameter) *PathItem
- func (p *PathItem) AddServers(srvs ...*Server) *PathItem
- func (p *PathItem) SetDelete(o *Operation) *PathItem
- func (p *PathItem) SetDescription(d string) *PathItem
- func (p *PathItem) SetGet(o *Operation) *PathItem
- func (p *PathItem) SetHead(o *Operation) *PathItem
- func (p *PathItem) SetOptions(o *Operation) *PathItem
- func (p *PathItem) SetParameters(ps []*Parameter) *PathItem
- func (p *PathItem) SetPatch(o *Operation) *PathItem
- func (p *PathItem) SetPost(o *Operation) *PathItem
- func (p *PathItem) SetPut(o *Operation) *PathItem
- func (p *PathItem) SetRef(r string) *PathItem
- func (p *PathItem) SetServers(srvs []Server) *PathItem
- func (p *PathItem) SetTrace(o *Operation) *PathItem
- func (p *PathItem) ToNamed(n string) *NamedPathItem
- func (p *PathItem) UnmarshalYAML(n *yaml.Node) error
- type Paths
- type PatternProperties
- func (p *PatternProperties) MarshalJSON() ([]byte, error)
- func (p PatternProperties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
- func (p PatternProperties) ToJSONSchema() (result jsonschema.RawPatternProperties)
- func (p *PatternProperties) UnmarshalJSON(data []byte) error
- func (p *PatternProperties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
- func (p *PatternProperties) UnmarshalYAML(node *yaml.Node) error
- type PatternProperty
- type Properties
- func (p *Properties) MarshalJSON() ([]byte, error)
- func (p Properties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
- func (p Properties) ToJSONSchema() jsonschema.RawProperties
- func (p *Properties) UnmarshalJSON(data []byte) error
- func (p *Properties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
- func (p *Properties) UnmarshalYAML(node *yaml.Node) error
- type Property
- type RequestBody
- func (r *RequestBody) AddContent(mt string, s *Schema) *RequestBody
- func (r *RequestBody) SetContent(c map[string]Media) *RequestBody
- func (r *RequestBody) SetDescription(d string) *RequestBody
- func (r *RequestBody) SetJSONContent(s *Schema) *RequestBody
- func (r *RequestBody) SetRef(ref string) *RequestBody
- func (r *RequestBody) SetRequired(req bool) *RequestBody
- func (r *RequestBody) ToNamed(n string) *NamedRequestBody
- func (r *RequestBody) UnmarshalYAML(n *yaml.Node) error
- type Response
- func (r *Response) AddContent(mt string, s *Schema) *Response
- func (r *Response) SetContent(c map[string]Media) *Response
- func (r *Response) SetDescription(d string) *Response
- func (r *Response) SetHeaders(h map[string]*Header) *Response
- func (r *Response) SetJSONContent(s *Schema) *Response
- func (r *Response) SetLinks(l map[string]interface{}) *Response
- func (r *Response) SetRef(ref string) *Response
- func (r *Response) ToNamed(n string) *NamedResponse
- func (r *Response) UnmarshalYAML(n *yaml.Node) error
- type Responses
- type Schema
- func Binary() *Schema
- func Bool() *Schema
- func Bytes() *Schema
- func Date() *Schema
- func DateTime() *Schema
- func Double() *Schema
- func Float() *Schema
- func Int() *Schema
- func Int32() *Schema
- func Int64() *Schema
- func NewSchema() *Schema
- func Password() *Schema
- func String() *Schema
- func UUID() *Schema
- func (s *Schema) AddOptionalProperties(ps ...*Property) *Schema
- func (s *Schema) AddRequiredProperties(ps ...*Property) *Schema
- func (s *Schema) AsArray() *Schema
- func (s *Schema) AsEnum(def jsonv1.RawMessage, values ...jsonv1.RawMessage) *Schema
- func (s *Schema) SetAllOf(a []*Schema) *Schema
- func (s *Schema) SetAnyOf(a []*Schema) *Schema
- func (s *Schema) SetDefault(d jsonv1.RawMessage) *Schema
- func (s *Schema) SetDescription(d string) *Schema
- func (s *Schema) SetDiscriminator(d *Discriminator) *Schema
- func (s *Schema) SetEnum(e []jsonv1.RawMessage) *Schema
- func (s *Schema) SetExclusiveMaximum(e bool) *Schema
- func (s *Schema) SetExclusiveMinimum(e bool) *Schema
- func (s *Schema) SetFormat(f string) *Schema
- func (s *Schema) SetItems(i *Schema) *Schema
- func (s *Schema) SetMaxItems(m *uint64) *Schema
- func (s *Schema) SetMaxLength(m *uint64) *Schema
- func (s *Schema) SetMaxProperties(m *uint64) *Schema
- func (s *Schema) SetMaximum(m *int64) *Schema
- func (s *Schema) SetMinItems(m *uint64) *Schema
- func (s *Schema) SetMinLength(m *uint64) *Schema
- func (s *Schema) SetMinProperties(m *uint64) *Schema
- func (s *Schema) SetMinimum(m *int64) *Schema
- func (s *Schema) SetMultipleOf(m *uint64) *Schema
- func (s *Schema) SetNullable(n bool) *Schema
- func (s *Schema) SetOneOf(o []*Schema) *Schema
- func (s *Schema) SetPattern(p string) *Schema
- func (s *Schema) SetProperties(p *Properties) *Schema
- func (s *Schema) SetRef(r string) *Schema
- func (s *Schema) SetRequired(r []string) *Schema
- func (s *Schema) SetType(t string) *Schema
- func (s *Schema) SetUniqueItems(u bool) *Schema
- func (s *Schema) ToJSONSchema() *jsonschema.RawSchema
- func (s *Schema) ToNamed(n string) *NamedSchema
- func (s *Schema) ToProperty(n string) *Property
- func (s *Schema) UnmarshalYAML(n *yaml.Node) error
- type SecurityRequirements
- type SecurityScheme
- type Server
- type ServerVariable
- type Spec
- func (s *Spec) AddNamedParameters(ps ...*NamedParameter) *Spec
- func (s *Spec) AddNamedPathItems(ps ...*NamedPathItem) *Spec
- func (s *Spec) AddNamedRequestBodies(scs ...*NamedRequestBody) *Spec
- func (s *Spec) AddNamedResponses(scs ...*NamedResponse) *Spec
- func (s *Spec) AddNamedSchemas(scs ...*NamedSchema) *Spec
- func (s *Spec) AddParameter(n string, p *Parameter) *Spec
- func (s *Spec) AddPathItem(n string, p *PathItem) *Spec
- func (s *Spec) AddRequestBody(n string, sc *RequestBody) *Spec
- func (s *Spec) AddResponse(n string, sc *Response) *Spec
- func (s *Spec) AddSchema(n string, sc *Schema) *Spec
- func (s *Spec) AddServers(srvs ...*Server) *Spec
- func (s *Spec) Init()
- func (s *Spec) RefRequestBody(n string) *NamedRequestBody
- func (s *Spec) RefResponse(n string) *NamedResponse
- func (s *Spec) RefSchema(n string) *NamedSchema
- func (s *Spec) SetComponents(c *Components) *Spec
- func (s *Spec) SetInfo(i *Info) *Spec
- func (s *Spec) SetOpenAPI(v string) *Spec
- func (s *Spec) SetPaths(p Paths) *Spec
- func (s *Spec) SetServers(srvs []Server) *Spec
- func (s *Spec) UnmarshalJSON(data []byte) error
- func (s *Spec) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdditionalProperties ¶ added in v0.9.0
AdditionalProperties is JSON Schema additionalProperties validator description.
func (*AdditionalProperties) MarshalJSON ¶ added in v0.9.0
func (p *AdditionalProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.MarshalerV1.
func (AdditionalProperties) MarshalNextJSON ¶ added in v0.42.0
func (p AdditionalProperties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
MarshalNextJSON implements json.MarshalerV2.
func (*AdditionalProperties) ToJSONSchema ¶ added in v0.13.0
func (p *AdditionalProperties) ToJSONSchema() *jsonschema.AdditionalProperties
ToJSONSchema converts AdditionalProperties to jsonschema.AdditionalProperties.
func (*AdditionalProperties) UnmarshalJSON ¶ added in v0.9.0
func (p *AdditionalProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.UnmarshalerV1.
func (*AdditionalProperties) UnmarshalNextJSON ¶ added in v0.42.0
func (p *AdditionalProperties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
UnmarshalNextJSON implements json.UnmarshalerV2.
func (*AdditionalProperties) UnmarshalYAML ¶ added in v0.43.0
func (p *AdditionalProperties) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type Components ¶
type Components struct { Schemas map[string]*Schema `json:"schemas,omitempty,omitzero" yaml:"schemas,omitempty"` Responses map[string]*Response `json:"responses,omitempty,omitzero" yaml:"responses,omitempty"` Parameters map[string]*Parameter `json:"parameters,omitempty,omitzero" yaml:"parameters,omitempty"` Examples map[string]*Example `json:"examples,omitempty,omitzero" yaml:"examples,omitempty"` RequestBodies map[string]*RequestBody `json:"requestBodies,omitempty,omitzero" yaml:"requestBodies,omitempty"` Headers map[string]*Header `json:"headers,omitempty,omitzero" yaml:"headers,omitempty"` SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes,omitempty,omitzero" yaml:"securitySchemes,omitempty"` Locator `json:"-" yaml:"-"` }
Components hold a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.
func (*Components) UnmarshalYAML ¶ added in v0.43.0
func (c *Components) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type Contact ¶
type Contact struct { Name string `json:"name,omitempty,omitzero" yaml:"name,omitempty"` URL string `json:"url,omitempty,omitzero" yaml:"url,omitempty"` Email string `json:"email,omitempty,omitzero" yaml:"email,omitempty"` }
Contact information for the exposed API.
type Discriminator ¶
type Discriminator struct { PropertyName string `json:"propertyName" yaml:"propertyName"` Mapping map[string]string `json:"mapping,omitempty,omitzero" yaml:"mapping,omitempty"` }
Discriminator discriminates types for OneOf, AllOf, AnyOf.
func (*Discriminator) ToJSONSchema ¶ added in v0.13.0
func (d *Discriminator) ToJSONSchema() *jsonschema.Discriminator
ToJSONSchema converts Discriminator to jsonschema.Discriminator.
type Encoding ¶ added in v0.33.0
type Encoding struct { // The Content-Type for encoding a specific property. ContentType string `json:"contentType,omitempty,omitzero" yaml:"contentType,omitempty"` // A map allowing additional information to be provided as headers, for example Content-Disposition. // Content-Type is described separately and SHALL be ignored in this section. This property SHALL be // ignored if the request body media type is not a multipart. Headers map[string]*Header `json:"headers,omitempty,omitzero" yaml:"headers,omitempty"` // Describes how the parameter value will be serialized // depending on the type of the parameter value. Style string `json:"style,omitempty,omitzero" yaml:"style,omitempty"` // When this is true, parameter values of type array or object // generate separate parameters for each value of the array // or key-value pair of the map. // For other types of parameters this property has no effect. Explode *bool `json:"explode,omitempty,omitzero" yaml:"explode,omitempty"` // Determines whether the parameter value SHOULD allow reserved characters, as defined by // RFC3986 :/?#[]@!$&'()*+,;= to be included without percent-encoding. // The default value is false. This property SHALL be ignored if the request body media type // is not application/x-www-form-urlencoded. AllowReserved bool `json:"allowReserved,omitempty,omitzero" yaml:"allowReserved,omitempty"` Locator `json:"-" yaml:"-"` }
Encoding describes single encoding definition applied to a single schema property.
func (*Encoding) UnmarshalYAML ¶ added in v0.43.0
UnmarshalYAML implements yaml.Unmarshaler.
type Enum ¶ added in v0.38.0
type Enum = jsonschema.Enum
Enum is JSON Schema enum validator description.
type Example ¶
type Example struct { Ref string `json:"$ref,omitempty,omitzero"` // ref objec yaml:"$ref,omitempty"` // ref object Summary string `json:"summary,omitempty,omitzero" yaml:"summary,omitempty"` Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` Value json.RawValue `json:"value,omitempty,omitzero" yaml:"value,omitempty"` ExternalValue string `json:"externalValue,omitempty,omitzero" yaml:"externalValue,omitempty"` Locator `json:"-" yaml:"-"` }
Example object.
https://swagger.io/specification/#example-object
func (*Example) UnmarshalYAML ¶ added in v0.43.0
UnmarshalYAML implements yaml.Unmarshaler.
type ExampleValue ¶ added in v0.43.0
type ExampleValue = jsonschema.Example
ExampleValue is an example value.
type ExternalDocumentation ¶ added in v0.40.0
type ExternalDocumentation struct { // A description of the target documentation. CommonMark syntax MAY be used for rich text representation. Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` // REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. URL string `json:"url" yaml:"url"` }
ExternalDocumentation describes a reference to external resource for extended documentation.
type Header ¶ added in v0.33.0
type Header = Parameter
Header describes header response.
Header Object follows the structure of the Parameter Object with the following changes:
- `name` MUST NOT be specified, it is given in the corresponding headers map.
- `in` MUST NOT be specified, it is implicitly in header.
- All traits that are affected by the location MUST be applicable to a location of header.
type Info ¶
type Info struct { // REQUIRED. The title of the API. Title string `json:"title" yaml:"title"` // A short summary of the API. Summary string `json:"summary,omitempty,omitzero" yaml:"summary,omitempty"` // A short description of the API. // CommonMark syntax MAY be used for rich text representation. Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` // A URL to the Terms of Service for the API. MUST be in the format of a URL. TermsOfService string `json:"termsOfService,omitempty,omitzero" yaml:"termsOfService,omitempty"` // The contact information for the exposed API. Contact *Contact `json:"contact,omitempty,omitzero" yaml:"contact,omitempty"` // The license information for the exposed API. License *License `json:"license,omitempty,omitzero" yaml:"license,omitempty"` // REQUIRED. The version of the OpenAPI document. Version string `json:"version" yaml:"version"` }
Info provides metadata about the API.
The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.
func (*Info) SetContact ¶
SetContact sets the Contact of the Info.
func (*Info) SetDescription ¶
SetDescription sets the description of the Info.
func (*Info) SetLicense ¶
SetLicense sets the License of the Info.
func (*Info) SetTermsOfService ¶
SetTermsOfService sets the terms of service of the Info.
func (*Info) SetVersion ¶
SetVersion sets the version of the Info.
type License ¶
type License struct { Name string `json:"name,omitempty,omitzero" yaml:"name,omitempty"` URL string `json:"url,omitempty,omitzero" yaml:"url,omitempty"` }
License information for the exposed API.
type Media ¶
type Media struct { // The schema defining the content of the request, response, or parameter. Schema *Schema `json:"schema,omitzero" yaml:"schema,omitempty"` Example json.RawValue `json:"example,omitempty,omitzero" yaml:"example,omitempty"` Examples map[string]*Example `json:"examples,omitempty,omitzero" yaml:"examples,omitempty"` // A map between a property name and its encoding information. The key, being the property name, MUST exist in // the schema as a property. The encoding object SHALL only apply to requestBody objects when the media // type is multipart or application/x-www-form-urlencoded. Encoding map[string]Encoding `json:"encoding,omitempty,omitzero" yaml:"encoding,omitempty"` Locator `json:"-" yaml:"-"` }
Media provides schema and examples for the media type identified by its key.
func (*Media) UnmarshalYAML ¶ added in v0.43.0
UnmarshalYAML implements yaml.Unmarshaler.
type NamedParameter ¶
NamedParameter can be used to construct a reference to the wrapped Parameter.
func NewNamedParameter ¶
func NewNamedParameter(n string, p *Parameter) *NamedParameter
NewNamedParameter returns a new NamedParameter.
func (*NamedParameter) AsLocalRef ¶
func (p *NamedParameter) AsLocalRef() *Parameter
AsLocalRef returns a new Parameter referencing the wrapped Parameter in the local document.
type NamedPathItem ¶
NamedPathItem can be used to construct a reference to the wrapped PathItem.
func NewNamedPathItem ¶
func NewNamedPathItem(n string, p *PathItem) *NamedPathItem
NewNamedPathItem returns a new NamedPathItem.
func (*NamedPathItem) AsLocalRef ¶
func (p *NamedPathItem) AsLocalRef() *PathItem
AsLocalRef returns a new PathItem referencing the wrapped PathItem in the local document.
type NamedRequestBody ¶
type NamedRequestBody struct { RequestBody *RequestBody Name string }
NamedRequestBody can be used to construct a reference to the wrapped RequestBody.
func NewNamedRequestBody ¶
func NewNamedRequestBody(n string, p *RequestBody) *NamedRequestBody
NewNamedRequestBody returns a new NamedRequestBody.
func (*NamedRequestBody) AsLocalRef ¶
func (p *NamedRequestBody) AsLocalRef() *RequestBody
AsLocalRef returns a new RequestBody referencing the wrapped RequestBody in the local document.
type NamedResponse ¶
NamedResponse can be used to construct a reference to the wrapped Response.
func NewNamedResponse ¶
func NewNamedResponse(n string, p *Response) *NamedResponse
NewNamedResponse returns a new NamedResponse.
func (*NamedResponse) AsLocalRef ¶
func (p *NamedResponse) AsLocalRef() *Response
AsLocalRef returns a new Response referencing the wrapped Response in the local document.
type NamedSchema ¶
NamedSchema can be used to construct a reference to the wrapped Schema.
func NewNamedSchema ¶
func NewNamedSchema(n string, p *Schema) *NamedSchema
NewNamedSchema returns a new NamedSchema.
func (*NamedSchema) AsLocalRef ¶
func (p *NamedSchema) AsLocalRef() *Schema
AsLocalRef returns a new Schema referencing the wrapped Schema in the local document.
type OAuthFlow ¶ added in v0.19.0
type OAuthFlow struct { // The authorization URL to be used for this flow. // This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. AuthorizationURL string `json:"authorizationUrl"` // The token URL to be used for this flow. // This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. TokenURL string `json:"tokenUrl"` // The URL to be used for obtaining refresh tokens. // This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS. RefreshURL string `json:"refreshUrl,omitempty"` // The available scopes for the OAuth2 security scheme. // A map between the scope name and a short description for it. The map MAY be empty. Scopes map[string]string `json:"scopes"` Locator `json:"-"` }
OAuthFlow is configuration details for a supported OAuth Flow.
type OAuthFlows ¶ added in v0.19.0
type OAuthFlows struct { // Configuration for the OAuth Implicit flow. Implicit *OAuthFlow `json:"implicit"` // Configuration for the OAuth Resource Owner Password flow. Password *OAuthFlow `json:"password"` // Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. ClientCredentials *OAuthFlow `json:"clientCredentials"` // Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0. AuthorizationCode *OAuthFlow `json:"authorizationCode"` Locator `json:"-"` }
OAuthFlows allows configuration of the supported OAuth Flows.
type Operation ¶
type Operation struct { OperationID string `json:"operationId,omitempty,omitzero" yaml:"operationId,omitempty"` Security SecurityRequirements `json:"security,omitempty,omitzero" yaml:"security,omitempty"` Parameters []*Parameter `json:"parameters,omitempty,omitzero" yaml:"parameters,omitempty"` RequestBody *RequestBody `json:"requestBody,omitempty,omitzero" yaml:"requestBody,omitempty"` Responses Responses `json:"responses,omitempty,omitzero" yaml:"responses,omitempty"` // A list of tags for API documentation control. // Tags can be used for logical grouping of operations by resources or any other qualifier. Tags []string `json:"tags,omitempty,omitzero" yaml:"tags,omitempty"` Summary string `json:"summary,omitempty,omitzero" yaml:"summary,omitempty"` Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty,omitzero" yaml:"externalDocs,omitempty"` Deprecated bool `json:"deprecated,omitempty,omitzero" yaml:"deprecated,omitempty"` Locator `json:"-" yaml:"-"` }
Operation describes a single API operation on a path.
func (*Operation) AddNamedResponses ¶
func (o *Operation) AddNamedResponses(ps ...*NamedResponse) *Operation
AddNamedResponses adds the given namedResponses to the Responses of the Operation.
func (*Operation) AddParameters ¶
AddParameters adds Parameters to the Parameters of the Operation.
func (*Operation) AddResponse ¶
AddResponse adds the given Response under the given Name to the Responses of the Operation.
func (*Operation) SetDescription ¶
SetDescription sets the Description of the Operation.
func (*Operation) SetOperationID ¶
SetOperationID sets the OperationID of the Operation.
func (*Operation) SetParameters ¶
SetParameters sets the Parameters of the Operation.
func (*Operation) SetRequestBody ¶
func (o *Operation) SetRequestBody(r *RequestBody) *Operation
SetRequestBody sets the RequestBody of the Operation.
func (*Operation) SetResponses ¶
SetResponses sets the Responses of the Operation.
func (*Operation) SetSummary ¶
SetSummary sets the Summary of the Operation.
func (*Operation) UnmarshalYAML ¶ added in v0.43.0
UnmarshalYAML implements yaml.Unmarshaler.
type Parameter ¶
type Parameter struct { Ref string `json:"$ref,omitempty,omitzero" yaml:"$ref,omitempty"` Name string `json:"name" yaml:"name"` // The location of the parameter. Possible values are "query", "header", "path" or "cookie". In string `json:"in" yaml:"in"` Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` Schema *Schema `json:"schema,omitempty,omitzero" yaml:"schema,omitempty"` // Determines whether this parameter is mandatory. // If the parameter location is "path", this property is REQUIRED // and its value MUST be true. // Otherwise, the property MAY be included and its default value is false. Required bool `json:"required,omitempty,omitzero" yaml:"required,omitempty"` // Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. // Default value is false. Deprecated bool `json:"deprecated,omitempty,omitzero" yaml:"deprecated,omitempty"` // For more complex scenarios, the content property can define the media type and schema of the parameter. // A parameter MUST contain either a schema property, or a content property, but not both. // When example or examples are provided in conjunction with the schema object, // the example MUST follow the prescribed serialization strategy for the parameter. // // A map containing the representations for the parameter. // The key is the media type and the value describes it. // The map MUST only contain one entry. Content map[string]Media `json:"content,omitempty,omitzero" yaml:"content,omitempty"` // Describes how the parameter value will be serialized // depending on the type of the parameter value. Style string `json:"style,omitempty,omitzero" yaml:"style,omitempty"` // When this is true, parameter values of type array or object // generate separate parameters for each value of the array // or key-value pair of the map. // For other types of parameters this property has no effect. Explode *bool `json:"explode,omitempty,omitzero" yaml:"explode,omitempty"` Example json.RawValue `json:"example,omitempty,omitzero" yaml:"example,omitempty"` Examples map[string]*Example `json:"examples,omitempty,omitzero" yaml:"examples,omitempty"` Locator `json:"-" yaml:"-"` }
Parameter describes a single operation parameter. A unique parameter is defined by a combination of a name and location.
func (*Parameter) SetContent ¶
SetContent sets the Content of the Parameter.
func (*Parameter) SetDeprecated ¶
SetDeprecated sets the Deprecated of the Parameter.
func (*Parameter) SetDescription ¶
SetDescription sets the Description of the Parameter.
func (*Parameter) SetExplode ¶
SetExplode sets the Explode of the Parameter.
func (*Parameter) SetRequired ¶
SetRequired sets the Required of the Parameter.
func (*Parameter) ToNamed ¶
func (p *Parameter) ToNamed(n string) *NamedParameter
ToNamed returns a NamedParameter wrapping the receiver.
func (*Parameter) UnmarshalYAML ¶ added in v0.43.0
UnmarshalYAML implements yaml.Unmarshaler.
type PathItem ¶
type PathItem struct { // Allows for an external definition of this path item. // The referenced structure MUST be in the format of a Path Item Object. // In case a Path Item Object field appears both // in the defined object and the referenced object, the behavior is undefined. Ref string `json:"$ref,omitempty,omitzero" yaml:"$ref,omitempty"` Summary string `json:"summary,omitempty,omitzero" yaml:"summary,omitempty"` Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` Get *Operation `json:"get,omitempty,omitzero" yaml:"get,omitempty"` Put *Operation `json:"put,omitempty,omitzero" yaml:"put,omitempty"` Post *Operation `json:"post,omitempty,omitzero" yaml:"post,omitempty"` Delete *Operation `json:"delete,omitempty,omitzero" yaml:"delete,omitempty"` Options *Operation `json:"options,omitempty,omitzero" yaml:"options,omitempty"` Head *Operation `json:"head,omitempty,omitzero" yaml:"head,omitempty"` Patch *Operation `json:"patch,omitempty,omitzero" yaml:"patch,omitempty"` Trace *Operation `json:"trace,omitempty,omitzero" yaml:"trace,omitempty"` Servers []Server `json:"servers,omitempty,omitzero" yaml:"servers,omitempty"` Parameters []*Parameter `json:"parameters,omitempty,omitzero" yaml:"parameters,omitempty"` Locator `json:"-" yaml:"-"` }
PathItem describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer, but they will not know which operations and parameters are available.
func (*PathItem) AddParameters ¶
AddParameters adds Parameters to the Parameters of the PathItem.
func (*PathItem) AddServers ¶
AddServers adds Servers to the Servers of the PathItem.
func (*PathItem) SetDescription ¶
SetDescription sets the Description of the PathItem.
func (*PathItem) SetOptions ¶
SetOptions sets the Options of the PathItem.
func (*PathItem) SetParameters ¶
SetParameters sets the Parameters of the PathItem.
func (*PathItem) SetServers ¶
SetServers sets the Servers of the PathItem.
func (*PathItem) ToNamed ¶
func (p *PathItem) ToNamed(n string) *NamedPathItem
ToNamed returns a NamedPathItem wrapping the receiver.
func (*PathItem) UnmarshalYAML ¶ added in v0.43.0
UnmarshalYAML implements yaml.Unmarshaler.
type Paths ¶
Paths holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the Server Object in order to construct the full URL. The Paths MAY be empty, due to ACL constraints.
type PatternProperties ¶ added in v0.23.0
type PatternProperties []PatternProperty
PatternProperties is unparsed JSON Schema patternProperties validator description.
func (*PatternProperties) MarshalJSON ¶ added in v0.23.0
func (p *PatternProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.MarshalerV1.
func (PatternProperties) MarshalNextJSON ¶ added in v0.42.0
func (p PatternProperties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
MarshalNextJSON implements json.MarshalerV2.
func (PatternProperties) ToJSONSchema ¶ added in v0.23.0
func (p PatternProperties) ToJSONSchema() (result jsonschema.RawPatternProperties)
ToJSONSchema converts PatternProperties to jsonschema.RawPatternProperties.
func (*PatternProperties) UnmarshalJSON ¶ added in v0.23.0
func (p *PatternProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.UnmarshalerV1.
func (*PatternProperties) UnmarshalNextJSON ¶ added in v0.42.0
func (p *PatternProperties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
UnmarshalNextJSON implements json.UnmarshalerV2.
func (*PatternProperties) UnmarshalYAML ¶ added in v0.43.0
func (p *PatternProperties) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type PatternProperty ¶ added in v0.23.0
PatternProperty is item of PatternProperties.
type Properties ¶
type Properties []Property
Properties is unparsed JSON Schema properties validator description.
func (*Properties) MarshalJSON ¶
func (p *Properties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.MarshalerV1.
func (Properties) MarshalNextJSON ¶ added in v0.42.0
func (p Properties) MarshalNextJSON(opts json.MarshalOptions, e *json.Encoder) error
MarshalNextJSON implements json.MarshalerV2.
func (Properties) ToJSONSchema ¶ added in v0.13.0
func (p Properties) ToJSONSchema() jsonschema.RawProperties
ToJSONSchema converts Properties to jsonschema.RawProperties.
func (*Properties) UnmarshalJSON ¶
func (p *Properties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.UnmarshalerV1.
func (*Properties) UnmarshalNextJSON ¶ added in v0.42.0
func (p *Properties) UnmarshalNextJSON(opts json.UnmarshalOptions, d *json.Decoder) error
UnmarshalNextJSON implements json.UnmarshalerV2.
func (*Properties) UnmarshalYAML ¶ added in v0.43.0
func (p *Properties) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type Property ¶
Property is item of Properties.
func (Property) ToJSONSchema ¶ added in v0.13.0
func (p Property) ToJSONSchema() jsonschema.RawProperty
ToJSONSchema converts Property to jsonschema.Property.
type RequestBody ¶
type RequestBody struct { Ref string `json:"$ref,omitempty,omitzero" yaml:"$ref,omitempty"` Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` // The content of the request body. // The key is a media type or media type range and the value describes it. // For requests that match multiple keys, only the most specific key is applicable. // e.g. text/plain overrides text/* Content map[string]Media `json:"content,omitempty,omitzero" yaml:"content,omitempty"` // Determines if the request body is required in the request. Defaults to false. Required bool `json:"required,omitempty,omitzero" yaml:"required,omitempty"` Locator `json:"-" yaml:"-"` }
RequestBody describes a single request body.
func (*RequestBody) AddContent ¶
func (r *RequestBody) AddContent(mt string, s *Schema) *RequestBody
AddContent adds the given Schema under the MediaType to the Content of the Response.
func (*RequestBody) SetContent ¶
func (r *RequestBody) SetContent(c map[string]Media) *RequestBody
SetContent sets the Content of the RequestBody.
func (*RequestBody) SetDescription ¶
func (r *RequestBody) SetDescription(d string) *RequestBody
SetDescription sets the Description of the RequestBody.
func (*RequestBody) SetJSONContent ¶
func (r *RequestBody) SetJSONContent(s *Schema) *RequestBody
SetJSONContent sets the given Schema under the JSON MediaType to the Content of the Response.
func (*RequestBody) SetRef ¶
func (r *RequestBody) SetRef(ref string) *RequestBody
SetRef sets the Ref of the RequestBody.
func (*RequestBody) SetRequired ¶
func (r *RequestBody) SetRequired(req bool) *RequestBody
SetRequired sets the Required of the RequestBody.
func (*RequestBody) ToNamed ¶
func (r *RequestBody) ToNamed(n string) *NamedRequestBody
ToNamed returns a NamedRequestBody wrapping the receiver.
func (*RequestBody) UnmarshalYAML ¶ added in v0.43.0
func (r *RequestBody) UnmarshalYAML(n *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type Response ¶
type Response struct { Ref string `json:"$ref,omitempty,omitzero" yaml:"$ref,omitempty"` Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` Headers map[string]*Header `json:"headers,omitempty,omitzero" yaml:"headers,omitempty"` Content map[string]Media `json:"content,omitempty,omitzero" yaml:"content,omitempty"` Links map[string]interface{} `json:"links,omitempty,omitzero" yaml:"links,omitempty"` // TODO: implement Locator `json:"-" yaml:"-"` }
Response describes a single response from an API Operation, including design-time, static links to operations based on the response.
func (*Response) AddContent ¶
AddContent adds the given Schema under the MediaType to the Content of the Response.
func (*Response) SetContent ¶
SetContent sets the Content of the Response.
func (*Response) SetDescription ¶
SetDescription sets the Description of the Response.
func (*Response) SetHeaders ¶ added in v0.33.0
SetHeaders sets the Headers of the Response.
func (*Response) SetJSONContent ¶
SetJSONContent sets the given Schema under the JSON MediaType to the Content of the Response.
func (*Response) ToNamed ¶
func (r *Response) ToNamed(n string) *NamedResponse
ToNamed returns a NamedResponse wrapping the receiver.
func (*Response) UnmarshalYAML ¶ added in v0.43.0
UnmarshalYAML implements yaml.Unmarshaler.
type Responses ¶
Responses is a container for the expected responses of an operation. The container maps the HTTP response code to the expected response
type Schema ¶
type Schema struct { Ref string `json:"$ref,omitempty,omitzero" yaml:"$ref,omitempty"` // ref object Summary string `json:"summary,omitempty,omitzero" yaml:"summary,omitempty"` Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` // Additional external documentation for this schema. ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty,omitzero" yaml:"externalDocs,omitempty"` // Value MUST be a string. Multiple types via an array are not supported. Type string `json:"type,omitempty,omitzero" yaml:"type,omitempty"` // See Data Type Formats for further details (https://swagger.io/specification/#data-type-format). // While relying on JSON Schema's defined formats, // the OAS offers a few additional predefined formats. Format string `json:"format,omitempty,omitzero" yaml:"format,omitempty"` // Property definitions MUST be a Schema Object and not a standard JSON Schema // (inline or referenced). Properties Properties `json:"properties,omitempty,omitzero" yaml:"properties,omitempty"` // Value can be boolean or object. Inline or referenced schema MUST be of a Schema Object // and not a standard JSON Schema. Consistent with JSON Schema, additionalProperties defaults to true. AdditionalProperties *AdditionalProperties `json:"additionalProperties,omitempty,omitzero" yaml:"additionalProperties,omitempty"` // The value of "patternProperties" MUST be an object. Each property // name of this object SHOULD be a valid regular expression, according // to the ECMA-262 regular expression dialect. Each property value of // this object MUST be a valid JSON Schema. PatternProperties PatternProperties `json:"patternProperties,omitempty,omitzero" yaml:"patternProperties,omitempty"` // The value of this keyword MUST be an array. // This array MUST have at least one element. // Elements of this array MUST be strings, and MUST be unique. Required []string `json:"required,omitempty,omitzero" yaml:"required,omitempty"` // Value MUST be an object and not an array. // Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. // MUST be present if the Type is "array". Items *Schema `json:"items,omitempty,omitzero" yaml:"items,omitempty"` // A true value adds "null" to the allowed type specified by the type keyword, // only if type is explicitly defined within the same Schema Object. // Other Schema Object constraints retain their defined behavior, // and therefore may disallow the use of null as a value. // A false value leaves the specified or default type unmodified. // The default value is false. Nullable bool `json:"nullable,omitempty,omitzero" yaml:"nullable,omitempty"` // AllOf takes an array of object definitions that are used // for independent validation but together compose a single object. // Still, it does not imply a hierarchy between the models. // For that purpose, you should include the discriminator. AllOf []*Schema `json:"allOf,omitempty,omitzero" yaml:"allOf,omitempty"` // OneOf validates the value against exactly one of the subschemas OneOf []*Schema `json:"oneOf,omitempty,omitzero" yaml:"oneOf,omitempty"` // AnyOf validates the value against any (one or more) of the subschemas AnyOf []*Schema `json:"anyOf,omitempty,omitzero" yaml:"anyOf,omitempty"` // Discriminator for subschemas. Discriminator *Discriminator `json:"discriminator,omitempty,omitzero" yaml:"discriminator,omitempty"` // The value of this keyword MUST be an array. // This array SHOULD have at least one element. // Elements in the array SHOULD be unique. Enum Enum `json:"enum,omitempty,omitzero" yaml:"enum,omitempty"` // The value of "multipleOf" MUST be a number, strictly greater than 0. // // A numeric instance is only valid if division by this keyword's value // results in an integer. MultipleOf Num `json:"multipleOf,omitempty,omitzero" yaml:"multipleOf,omitempty"` // The value of "maximum" MUST be a number, representing an upper limit // for a numeric instance. // // If the instance is a number, then this keyword validates if // "exclusiveMaximum" is true and instance is less than the provided // value, or else if the instance is less than or exactly equal to the // provided value. Maximum Num `json:"maximum,omitempty,omitzero" yaml:"maximum,omitempty"` // The value of "exclusiveMaximum" MUST be a boolean, representing // whether the limit in "maximum" is exclusive or not. An undefined // value is the same as false. // // If "exclusiveMaximum" is true, then a numeric instance SHOULD NOT be // equal to the value specified in "maximum". If "exclusiveMaximum" is // false (or not specified), then a numeric instance MAY be equal to the // value of "maximum". ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty,omitzero" yaml:"exclusiveMaximum,omitempty"` // The value of "minimum" MUST be a number, representing a lower limit // for a numeric instance. // // If the instance is a number, then this keyword validates if // "exclusiveMinimum" is true and instance is greater than the provided // value, or else if the instance is greater than or exactly equal to // the provided value. Minimum Num `json:"minimum,omitempty,omitzero" yaml:"minimum,omitempty"` // The value of "exclusiveMinimum" MUST be a boolean, representing // whether the limit in "minimum" is exclusive or not. An undefined // value is the same as false. // // If "exclusiveMinimum" is true, then a numeric instance SHOULD NOT be // equal to the value specified in "minimum". If "exclusiveMinimum" is // false (or not specified), then a numeric instance MAY be equal to the // value of "minimum". ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty,omitzero" yaml:"exclusiveMinimum,omitempty"` // The value of this keyword MUST be a non-negative integer. // // The value of this keyword MUST be an integer. This integer MUST be // greater than, or equal to, 0. // // A string instance is valid against this keyword if its length is less // than, or equal to, the value of this keyword. // // The length of a string instance is defined as the number of its // characters as defined by RFC 7159 [RFC7159]. MaxLength *uint64 `json:"maxLength,omitempty,omitzero" yaml:"maxLength,omitempty"` // A string instance is valid against this keyword if its length is // greater than, or equal to, the value of this keyword. // // The length of a string instance is defined as the number of its // characters as defined by RFC 7159 [RFC7159]. // // The value of this keyword MUST be an integer. This integer MUST be // greater than, or equal to, 0. // // "minLength", if absent, may be considered as being present with // integer value 0. MinLength *uint64 `json:"minLength,omitempty,omitzero" yaml:"minLength,omitempty"` // The value of this keyword MUST be a string. This string SHOULD be a // valid regular expression, according to the ECMA 262 regular // expression dialect. // // A string instance is considered valid if the regular expression // matches the instance successfully. Recall: regular expressions are // not implicitly anchored. Pattern string `json:"pattern,omitempty,omitzero" yaml:"pattern,omitempty"` // The value of this keyword MUST be an integer. This integer MUST be // greater than, or equal to, 0. // // An array instance is valid against "maxItems" if its size is less // than, or equal to, the value of this keyword. MaxItems *uint64 `json:"maxItems,omitempty,omitzero" yaml:"maxItems,omitempty"` // The value of this keyword MUST be an integer. This integer MUST be // greater than, or equal to, 0. // // An array instance is valid against "minItems" if its size is greater // than, or equal to, the value of this keyword. // // If this keyword is not present, it may be considered present with a // value of 0. MinItems *uint64 `json:"minItems,omitempty,omitzero" yaml:"minItems,omitempty"` // The value of this keyword MUST be a boolean. // // If this keyword has boolean value false, the instance validates // successfully. If it has boolean value true, the instance validates // successfully if all of its elements are unique. // // If not present, this keyword may be considered present with boolean // value false. UniqueItems bool `json:"uniqueItems,omitempty,omitzero" yaml:"uniqueItems,omitempty"` // The value of this keyword MUST be an integer. This integer MUST be // greater than, or equal to, 0. // // An object instance is valid against "maxProperties" if its number of // properties is less than, or equal to, the value of this keyword. MaxProperties *uint64 `json:"maxProperties,omitempty,omitzero" yaml:"maxProperties,omitempty"` // The value of this keyword MUST be an integer. This integer MUST be // greater than, or equal to, 0. // // An object instance is valid against "minProperties" if its number of // properties is greater than, or equal to, the value of this keyword. // // If this keyword is not present, it may be considered present with a // value of 0. MinProperties *uint64 `json:"minProperties,omitempty,omitzero" yaml:"minProperties,omitempty"` // Default value. Default Default `json:"default,omitempty,omitzero" yaml:"default,omitempty"` // A free-form property to include an example of an instance for this schema. // To represent examples that cannot be naturally represented in JSON or YAML, // a string value can be used to contain the example with escaping where necessary. Example ExampleValue `json:"example,omitempty,omitzero" yaml:"example,omitempty"` // Specifies that a schema is deprecated and SHOULD be transitioned out // of usage. Deprecated bool `json:"deprecated,omitempty,omitzero" yaml:"deprecated,omitempty"` // If the instance value is a string, this property defines that the // string SHOULD be interpreted as binary data and decoded using the // encoding named by this property. RFC 2045, Section 6.1 lists // the possible values for this property. // // The value of this property MUST be a string. // // The value of this property SHOULD be ignored if the instance // described is not a string. ContentEncoding string `json:"contentEncoding,omitempty,omitzero" yaml:"contentEncoding,omitempty"` // The value of this property must be a media type, as defined by RFC // 2046. This property defines the media type of instances // which this schema defines. // // The value of this property MUST be a string. // // The value of this property SHOULD be ignored if the instance // described is not a string. ContentMediaType string `json:"contentMediaType,omitempty,omitzero" yaml:"contentMediaType,omitempty"` Locator `json:"-" yaml:"-"` }
The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays.
func Date ¶
func Date() *Schema
Date returns a date as defined by full-date - RFC3339 OAS data type (Schema).
func DateTime ¶
func DateTime() *Schema
DateTime returns a date as defined by date-time - RFC3339 OAS data type (Schema).
func (*Schema) AddOptionalProperties ¶
AddOptionalProperties adds the Properties to the Properties of the Schema.
func (*Schema) AddRequiredProperties ¶
AddRequiredProperties adds the Properties to the Properties of the Schema and marks them as required.
func (*Schema) AsEnum ¶
func (s *Schema) AsEnum(def jsonv1.RawMessage, values ...jsonv1.RawMessage) *Schema
AsEnum returns a new "enum" Schema wrapping the receiver.
func (*Schema) SetDefault ¶
func (s *Schema) SetDefault(d jsonv1.RawMessage) *Schema
SetDefault sets the Default of the Schema.
func (*Schema) SetDescription ¶
SetDescription sets the Description of the Schema.
func (*Schema) SetDiscriminator ¶
func (s *Schema) SetDiscriminator(d *Discriminator) *Schema
SetDiscriminator sets the Discriminator of the Schema.
func (*Schema) SetEnum ¶
func (s *Schema) SetEnum(e []jsonv1.RawMessage) *Schema
SetEnum sets the Enum of the Schema.
func (*Schema) SetExclusiveMaximum ¶
SetExclusiveMaximum sets the ExclusiveMaximum of the Schema.
func (*Schema) SetExclusiveMinimum ¶
SetExclusiveMinimum sets the ExclusiveMinimum of the Schema.
func (*Schema) SetMaxItems ¶
SetMaxItems sets the MaxItems of the Schema.
func (*Schema) SetMaxLength ¶
SetMaxLength sets the MaxLength of the Schema.
func (*Schema) SetMaxProperties ¶
SetMaxProperties sets the MaxProperties of the Schema.
func (*Schema) SetMaximum ¶
SetMaximum sets the Maximum of the Schema.
func (*Schema) SetMinItems ¶
SetMinItems sets the MinItems of the Schema.
func (*Schema) SetMinLength ¶
SetMinLength sets the MinLength of the Schema.
func (*Schema) SetMinProperties ¶
SetMinProperties sets the MinProperties of the Schema.
func (*Schema) SetMinimum ¶
SetMinimum sets the Minimum of the Schema.
func (*Schema) SetMultipleOf ¶
SetMultipleOf sets the MultipleOf of the Schema.
func (*Schema) SetNullable ¶
SetNullable sets the Nullable of the Schema.
func (*Schema) SetPattern ¶
SetPattern sets the Pattern of the Schema.
func (*Schema) SetProperties ¶
func (s *Schema) SetProperties(p *Properties) *Schema
SetProperties sets the Properties of the Schema.
func (*Schema) SetRequired ¶
SetRequired sets the Required of the Schema.
func (*Schema) SetUniqueItems ¶
SetUniqueItems sets the UniqueItems of the Schema.
func (*Schema) ToJSONSchema ¶ added in v0.13.0
func (s *Schema) ToJSONSchema() *jsonschema.RawSchema
ToJSONSchema converts Schema to jsonschema.Schema.
func (*Schema) ToNamed ¶
func (s *Schema) ToNamed(n string) *NamedSchema
ToNamed returns a NamedSchema wrapping the receiver.
func (*Schema) ToProperty ¶
ToProperty returns a Property with the given name and with this Schema.
func (*Schema) UnmarshalYAML ¶ added in v0.43.0
UnmarshalYAML implements yaml.Unmarshaler.
type SecurityRequirements ¶ added in v0.19.0
SecurityRequirements lists the required security schemes to execute this operation.
type SecurityScheme ¶ added in v0.42.0
type SecurityScheme struct { Ref string `json:"ref,omitempty"` // The type of the security scheme. Valid values are "apiKey", "http", "mutualTLS", "oauth2", "openIdConnect". Type string `json:"type"` // A description for security scheme. CommonMark syntax MAY be used for rich text representation. Description string `json:"description,omitempty"` // The name of the header, query or cookie parameter to be used. Name string `json:"name,omitempty"` // The location of the API key. Valid values are "query", "header" or "cookie". In string `json:"in,omitempty"` // The name of the HTTP Authorization scheme to be used in the Authorization header as defined in RFC7235. // The values used SHOULD be registered in the IANA Authentication Scheme registry. Scheme string `json:"scheme,omitempty"` // A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated // by an authorization server, so this information is primarily for documentation purposes. BearerFormat string `json:"bearerFormat,omitempty"` // An object containing configuration information for the flow types supported. Flows *OAuthFlows `json:"flows,omitempty"` // OpenId Connect URL to discover OAuth2 configuration values. // This MUST be in the form of a URL. The OpenID Connect standard requires the use of TLS. OpenIDConnectURL string `json:"openIdConnectUrl,omitempty"` Locator `json:"-"` }
SecurityScheme defines a security scheme that can be used by the operations.
type Server ¶
type Server struct { // REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, // to indicate that the host location is relative to the location where the OpenAPI document is being served. // Variable substitutions will be made when a variable is named in {brackets}. URL string `json:"url" yaml:"url"` // An optional string describing the host designated by the URL. // CommonMark syntax MAY be used for rich text representation. Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` // A map between a variable name and its value. The value is used for substitution in the server's URL template. Variables map[string]ServerVariable `json:"variables,omitempty,omitzero" yaml:"variables,omitempty"` }
Server represents a Server.
func (*Server) SetDescription ¶
SetDescription sets the Description of the Server.
type ServerVariable ¶ added in v0.40.0
type ServerVariable struct { // An enumeration of string values to be used if the substitution options are from a limited set. // // The array MUST NOT be empty. Enum []string `json:"enum,omitempty,omitzero" yaml:"enum,omitempty"` // REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied. // Note this behavior is different than the Schema Object’s treatment of default values, because in those // cases parameter values are optional. If the enum is defined, the value MUST exist in the enum’s values. Default string `json:"default" yaml:"default"` // An optional description for the server variable. CommonMark syntax MAY be used for rich text representation. Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` }
ServerVariable describes an object representing a Server Variable for server URL template substitution.
type Spec ¶
type Spec struct { // This string MUST be the semantic version number // of the OpenAPI Specification version that the OpenAPI document uses. OpenAPI string `json:"openapi" yaml:"openapi"` Info Info `json:"info" yaml:"info"` Servers []Server `json:"servers,omitempty,omitzero" yaml:"servers,omitempty"` Paths Paths `json:"paths,omitempty,omitzero" yaml:"paths,omitempty"` Components *Components `json:"components,omitempty,omitzero" yaml:"components,omitempty"` Security SecurityRequirements `json:"security,omitempty,omitzero" yaml:"security,omitempty"` // A list of tags used by the specification with additional metadata. // The order of the tags can be used to reflect on their order by the parsing // tools. Not all tags that are used by the Operation Object must be declared. // The tags that are not declared MAY be organized randomly or based on the tools' logic. // Each tag name in the list MUST be unique. Tags []Tag `json:"tags,omitempty,omitzero" yaml:"tags,omitempty"` // Additional external documentation. ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty,omitzero" yaml:"externalDocs,omitempty"` // Raw JSON value. Used by JSON Schema resolver. Raw json.RawValue `json:"-" yaml:"-"` }
Spec is the root document object of the OpenAPI document.
func (*Spec) AddNamedParameters ¶
func (s *Spec) AddNamedParameters(ps ...*NamedParameter) *Spec
AddNamedParameters adds the given namedParameters to the Components of the Spec.
func (*Spec) AddNamedPathItems ¶
func (s *Spec) AddNamedPathItems(ps ...*NamedPathItem) *Spec
AddNamedPathItems adds the given namedPaths to the Paths of the Spec.
func (*Spec) AddNamedRequestBodies ¶
func (s *Spec) AddNamedRequestBodies(scs ...*NamedRequestBody) *Spec
AddNamedRequestBodies adds the given namedRequestBodies to the Components of the Spec.
func (*Spec) AddNamedResponses ¶
func (s *Spec) AddNamedResponses(scs ...*NamedResponse) *Spec
AddNamedResponses adds the given namedResponses to the Components of the Spec.
func (*Spec) AddNamedSchemas ¶
func (s *Spec) AddNamedSchemas(scs ...*NamedSchema) *Spec
AddNamedSchemas adds the given namedSchemas to the Components of the Spec.
func (*Spec) AddParameter ¶
AddParameter adds the given Parameter under the given Name to the Components of the Spec.
func (*Spec) AddPathItem ¶
AddPathItem adds the given PathItem under the given Name to the Paths of the Spec.
func (*Spec) AddRequestBody ¶
func (s *Spec) AddRequestBody(n string, sc *RequestBody) *Spec
AddRequestBody adds the given RequestBody under the given Name to the Components of the Spec.
func (*Spec) AddResponse ¶
AddResponse adds the given Response under the given Name to the Components of the Spec.
func (*Spec) AddSchema ¶
AddSchema adds the given Schema under the given Name to the Components of the Spec.
func (*Spec) AddServers ¶
AddServers adds Servers to the Servers of the Spec.
func (*Spec) RefRequestBody ¶
func (s *Spec) RefRequestBody(n string) *NamedRequestBody
RefRequestBody returns a new RequestBody referencing the given name.
func (*Spec) RefResponse ¶
func (s *Spec) RefResponse(n string) *NamedResponse
RefResponse returns a new Response referencing the given name.
func (*Spec) RefSchema ¶
func (s *Spec) RefSchema(n string) *NamedSchema
RefSchema returns a new Schema referencing the given name.
func (*Spec) SetComponents ¶
func (s *Spec) SetComponents(c *Components) *Spec
SetComponents sets the Components of the Spec.
func (*Spec) SetOpenAPI ¶
SetOpenAPI sets the OpenAPI Specification version of the document.
func (*Spec) SetServers ¶
SetServers sets the Servers of the Spec.
func (*Spec) UnmarshalJSON ¶ added in v0.22.0
UnmarshalJSON implements json.UnmarshalerV1.
func (*Spec) UnmarshalNextJSON ¶ added in v0.42.0
UnmarshalNextJSON implements json.UnmarshalerV2.
type Tag ¶
type Tag struct { Name string `json:"name" yaml:"name"` Description string `json:"description,omitempty,omitzero" yaml:"description,omitempty"` ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty,omitzero" yaml:"externalDocs,omitempty"` }
Tag object.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
ogen
Binary ogen generates go source code from OAS.
|
Binary ogen generates go source code from OAS. |
examples
module
|
|
genfs
Package genfs contains gen.FileSystem implementations.
|
Package genfs contains gen.FileSystem implementations. |
Package http implements crazy ideas for http optimizations that should be mostly std compatible.
|
Package http implements crazy ideas for http optimizations that should be mostly std compatible. |
capitalize
Package capitalize contains capitalize function.
|
Package capitalize contains capitalize function. |
ogenzap
Package ogenzap contains ogen logging utilities.
|
Package ogenzap contains ogen logging utilities. |
sample_api
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
sample_api_nc
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
sample_api_ns
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
sample_err
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
techempower
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
test_allof
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
test_form
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
test_http_requests
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
test_http_responses
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
test_single_endpoint
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
Package jsonpointer contains RFC 6901 JSON Pointer implementation.
|
Package jsonpointer contains RFC 6901 JSON Pointer implementation. |
Package ogenerrors contains ogen errors type definitions and helpers.
|
Package ogenerrors contains ogen errors type definitions and helpers. |
Package openapi represents OpenAPI v3 Specification in Go.
|
Package openapi represents OpenAPI v3 Specification in Go. |
Package otelogen provides OpenTelemetry tracing for ogen.
|
Package otelogen provides OpenTelemetry tracing for ogen. |
tools
|
|
Package uri implements OpenAPI path/query parameter encoding.
|
Package uri implements OpenAPI path/query parameter encoding. |