Documentation ¶
Overview ¶
Package ogen implements OpenAPI v3 code generation.
Index ¶
- type AdditionalProperties
- type Components
- type Contact
- type Discriminator
- type Example
- type Info
- type License
- 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
- 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
- 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
- type Paths
- type PatternProperties
- type PatternProperty
- type Properties
- 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
- 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) SetHeader(h map[string]interface{}) *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
- 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 json.RawMessage, values ...json.RawMessage) *Schema
- func (s *Schema) SetAllOf(a []*Schema) *Schema
- func (s *Schema) SetAnyOf(a []*Schema) *Schema
- func (s *Schema) SetDefault(d json.RawMessage) *Schema
- func (s *Schema) SetDescription(d string) *Schema
- func (s *Schema) SetDiscriminator(d *Discriminator) *Schema
- func (s *Schema) SetEnum(e []json.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
- type SecurityRequirements
- type SecuritySchema
- type Server
- 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(bytes []byte) 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 represent JSON Schema additionalProperties validator description.
func (AdditionalProperties) MarshalJSON ¶ added in v0.9.0
func (p AdditionalProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
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.Unmarshaler.
type Components ¶
type Components struct { Schemas map[string]*Schema `json:"schemas,omitempty"` Responses map[string]*Response `json:"responses,omitempty"` Parameters map[string]*Parameter `json:"parameters,omitempty"` Examples map[string]*Example `json:"examples,omitempty"` RequestBodies map[string]*RequestBody `json:"requestBodies,omitempty"` SecuritySchemes map[string]*SecuritySchema `json:"securitySchemes,omitempty"` }
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.
type Contact ¶
type Contact struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Email string `json:"email,omitempty"` }
Contact information for the exposed API.
type Discriminator ¶
type Discriminator struct { PropertyName string `json:"propertyName"` Mapping map[string]string `json:"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 Example ¶
type Example struct { Ref string `json:"$ref,omitempty"` // ref object Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` Value json.RawMessage `json:"value,omitempty"` ExternalValue string `json:"externalValue,omitempty"` }
Example object.
type Info ¶
type Info struct { // REQUIRED. The title of the API. Title string `json:"title"` // A short description of the API. // CommonMark syntax MAY be used for rich text representation. Description string `json:"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"` // The contact information for the exposed API. Contact *Contact `json:"contact,omitempty"` // The license information for the exposed API. License *License `json:"license,omitempty"` // REQUIRED. The version of the OpenAPI document. Version string `json:"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 ¶
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,omitempty"` Example json.RawMessage `json:"example,omitempty"` Examples map[string]*Example `json:"examples,omitempty"` }
Media provides schema and examples for the media type identified by its key.
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"` }
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"` }
OAuthFlows allows configuration of the supported OAuth Flows.
type Operation ¶
type Operation struct { // 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"` Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` OperationID string `json:"operationId,omitempty"` Parameters []*Parameter `json:"parameters,omitempty"` RequestBody *RequestBody `json:"requestBody,omitempty"` Responses Responses `json:"responses,omitempty"` Security SecurityRequirements `json:"security,omitempty"` Deprecated bool `json:"deprecated,omitempty"` }
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.
type Parameter ¶
type Parameter struct { Ref string `json:"$ref,omitempty"` Name string `json:"name"` // The location of the parameter. Possible values are "query", "header", "path" or "cookie". In string `json:"in"` Description string `json:"description,omitempty"` Schema *Schema `json:"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"` // Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. // Default value is false. Deprecated bool `json:"deprecated,omitempty"` // TODO: implement // 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"` // TODO: implement // Describes how the parameter value will be serialized // depending on the type of the parameter value. Style string `json:"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"` Example json.RawMessage `json:"example,omitempty"` Examples map[string]*Example `json:"examples,omitempty"` }
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.
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"` Description string `json:"description,omitempty"` Get *Operation `json:"get,omitempty"` Put *Operation `json:"put,omitempty"` Post *Operation `json:"post,omitempty"` Delete *Operation `json:"delete,omitempty"` Options *Operation `json:"options,omitempty"` Head *Operation `json:"head,omitempty"` Patch *Operation `json:"patch,omitempty"` Trace *Operation `json:"trace,omitempty"` Servers []Server `json:"servers,omitempty"` Parameters []*Parameter `json:"parameters,omitempty"` }
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.
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 represent JSON Schema patternProperties validator description.
func (PatternProperties) MarshalJSON ¶ added in v0.23.0
func (r PatternProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (PatternProperties) ToJSONSchema ¶ added in v0.23.0
func (r PatternProperties) ToJSONSchema() (result jsonschema.RawPatternProperties)
ToJSONSchema converts PatternProperties to jsonschema.RawPatternProperties.
func (*PatternProperties) UnmarshalJSON ¶ added in v0.23.0
func (r *PatternProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
type PatternProperty ¶ added in v0.23.0
PatternProperty is item of PatternProperties.
type Properties ¶
type Properties []Property
Properties represent JSON Schema properties validator description.
func (Properties) MarshalJSON ¶
func (p Properties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
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.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"` Description string `json:"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"` // Determines if the request body is required in the request. Defaults to false. Required bool `json:"required,omitempty"` }
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.
type Response ¶
type Response struct { Ref string `json:"$ref,omitempty"` Description string `json:"description,omitempty"` Header map[string]interface{} `json:"header,omitempty"` // TODO: implement Content map[string]Media `json:"content,omitempty"` Links map[string]interface{} `json:"links,omitempty"` // TODO: implement }
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) 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.
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"` // ref object Description string `json:"description,omitempty"` // Value MUST be a string. Multiple types via an array are not supported. Type string `json:"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"` // Property definitions MUST be a Schema Object and not a standard JSON Schema // (inline or referenced). Properties Properties `json:"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"` // 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"` // 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"` // 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"` // 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"` // 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"` // TODO: implement. // OneOf validates the value against exactly one of the subschemas OneOf []*Schema `json:"oneOf,omitempty"` // TODO: implement. // AnyOf validates the value against any (one or more) of the subschemas AnyOf []*Schema `json:"anyOf,omitempty"` // TODO: implement. // Discriminator for subschemas. Discriminator *Discriminator `json:"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 []json.RawMessage `json:"enum,omitempty"` // TODO: Nullable. // 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"` // 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"` // 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"` // 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"` // 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"` // 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"` // 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"` // 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"` // 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"` // 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"` // 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"` // 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"` // 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"` // Default value. Default json.RawMessage `json:"default,omitempty"` // TODO: support // 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 json.RawMessage `json:"example,omitempty"` // Specifies that a schema is deprecated and SHOULD be transitioned out // of usage. Deprecated bool `json:"deprecated,omitempty"` }
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 json.RawMessage, values ...json.RawMessage) *Schema
AsEnum returns a new "enum" Schema wrapping the receiver.
func (*Schema) SetDefault ¶
func (s *Schema) SetDefault(d json.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 []json.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.
type SecurityRequirements ¶ added in v0.19.0
SecurityRequirements lists the required security schemes to execute this operation.
type SecuritySchema ¶ added in v0.19.0
type SecuritySchema 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"` // 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"` }
SecuritySchema defines a security scheme that can be used by the operations.
type Server ¶
Server represents a Server.
func (*Server) SetDescription ¶
SetDescription sets the Description of the Server.
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"` Info Info `json:"info"` Servers []Server `json:"servers,omitempty"` Paths Paths `json:"paths,omitempty"` Components *Components `json:"components,omitempty"` Security SecurityRequirements `json:"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"` // Raw JSON value. Used by JSON Schema resolver. Raw []byte `json:"-"` }
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.Unmarshaler.
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. |
internal
|
|
capitalize
Package capitalize contains capitalize function.
|
Package capitalize contains capitalize function. |
sample_api
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_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. |