Documentation
¶
Overview ¶
Package ir loads OpenAPI documents into the canonical, operation-oriented intermediate representation shared by TRex generators.
Index ¶
- func SafeJoin(outputRoot string, elements ...string) (string, error)
- func ValidateComponentName(value string) error
- func ValidateIdentifier(value string) error
- func ValidateRouteLiteral(value string) error
- type Capabilities
- type Capability
- type Diagnostic
- type Discriminator
- type Document
- type ExtensionValue
- type LoadOptions
- type MediaType
- type Operation
- type OperationLink
- type OperationSecurity
- type Parameter
- type ParameterMapping
- type Property
- type Relationship
- type RelationshipProvenance
- type RequestBody
- type ResourceView
- type ResourceViewKind
- type Response
- type RouteSegment
- type Schema
- type SchemaReference
- type SchemaRole
- type SchemaUse
- type SecurityRequirement
- type SecurityScheme
- type SecuritySchemeUse
- type SecurityState
- type Server
- type ServerVariable
- type SourceLocation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateComponentName ¶
func ValidateIdentifier ¶
func ValidateRouteLiteral ¶
Types ¶
type Capabilities ¶
type Capabilities []Capability
func (Capabilities) Has ¶
func (capabilities Capabilities) Has(want Capability) bool
type Capability ¶
type Capability string
const ( CapabilityList Capability = "list" CapabilityGet Capability = "get" CapabilityCreate Capability = "create" CapabilityUpdate Capability = "update" CapabilityDelete Capability = "delete" CapabilityAction Capability = "action" CapabilityStream Capability = "stream" )
type Diagnostic ¶
type Diagnostic struct {
Source SourceLocation
Context string
Message string
}
func (*Diagnostic) Error ¶
func (diagnostic *Diagnostic) Error() string
type Discriminator ¶
type Document ¶
type Document struct {
OpenAPI string `json:"openapi"`
Title string `json:"title"`
Version string `json:"version"`
Source SourceLocation `json:"source"`
Servers []*Server `json:"servers,omitempty"`
Security []SecurityRequirement `json:"security,omitempty"`
SecuritySchemes []*SecurityScheme `json:"securitySchemes,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Operations []*Operation `json:"operations"`
Schemas []*Schema `json:"schemas"`
SchemaUses []*SchemaUse `json:"schemaUses,omitempty"`
ResourceViews []*ResourceView `json:"resourceViews,omitempty"`
Relationships []*Relationship `json:"relationships,omitempty"`
}
func (*Document) EffectiveProperties ¶
func (*Document) ValidateProjectionNames ¶
type ExtensionValue ¶
type ExtensionValue struct {
Value any `json:"value"`
Source SourceLocation `json:"source"`
}
type LoadOptions ¶
type MediaType ¶
type MediaType struct {
ContentType string `json:"contentType"`
Schema *SchemaReference `json:"schema,omitempty"`
Example any `json:"example,omitempty"`
}
type Operation ¶
type Operation struct {
ID string `json:"id"`
Method string `json:"method"`
Path string `json:"path"`
Segments []*RouteSegment `json:"segments"`
Parameters []*Parameter `json:"parameters,omitempty"`
PathParameters []*Parameter `json:"pathParameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
Responses []*Response `json:"responses"`
Servers []*Server `json:"servers,omitempty"`
Security OperationSecurity `json:"security"`
Tags []string `json:"tags,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Capabilities Capabilities `json:"capabilities,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
PathExtensions map[string]ExtensionValue `json:"pathExtensions,omitempty"`
Source SourceLocation `json:"source"`
}
type OperationLink ¶
type OperationLink struct {
Name string `json:"name"`
TargetOperationID string `json:"targetOperationId,omitempty"`
TargetOperationRef string `json:"targetOperationRef,omitempty"`
Parameters []ParameterMapping `json:"parameters,omitempty"`
Description string `json:"description,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Source SourceLocation `json:"source"`
}
type OperationSecurity ¶
type OperationSecurity struct {
State SecurityState `json:"state"`
Requirements []SecurityRequirement `json:"requirements,omitempty"`
}
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
In string `json:"in"`
Description string `json:"description,omitempty"`
Required bool `json:"required"`
Deprecated bool `json:"deprecated,omitempty"`
Style string `json:"style"`
Explode bool `json:"explode"`
AllowReserved bool `json:"allowReserved,omitempty"`
Schema *SchemaReference `json:"schema,omitempty"`
Example any `json:"example,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Source SourceLocation `json:"source"`
}
type ParameterMapping ¶
type Property ¶
type Property struct {
Name string `json:"name"`
Schema *SchemaReference `json:"schema"`
Required bool `json:"required"`
ReadOnly bool `json:"readOnly,omitempty"`
WriteOnly bool `json:"writeOnly,omitempty"`
Nullable bool `json:"nullable,omitempty"`
Description string `json:"description,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Source SourceLocation `json:"source"`
}
type Relationship ¶
type Relationship struct {
Name string `json:"name"`
SourceOperationID string `json:"sourceOperationId,omitempty"`
TargetOperationID string `json:"targetOperationId,omitempty"`
SourceViewID string `json:"sourceViewId,omitempty"`
TargetViewID string `json:"targetViewId,omitempty"`
ParameterMappings []ParameterMapping `json:"parameterMappings,omitempty"`
Provenance RelationshipProvenance `json:"provenance"`
Source SourceLocation `json:"source"`
}
type RelationshipProvenance ¶
type RelationshipProvenance string
const ( RelationshipExplicit RelationshipProvenance = "explicit-link" RelationshipInferred RelationshipProvenance = "inferred-path" )
type RequestBody ¶
type RequestBody struct {
Description string `json:"description,omitempty"`
Required bool `json:"required"`
Content []*MediaType `json:"content"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Source SourceLocation `json:"source"`
}
type ResourceView ¶
type ResourceView struct {
ID string `json:"id"`
Kind ResourceViewKind `json:"kind"`
Path string `json:"path"`
SchemaRef string `json:"schemaRef"`
ScopeParameters []string `json:"scopeParameters,omitempty"`
OperationIDs []string `json:"operationIds"`
Capabilities Capabilities `json:"capabilities,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
}
type ResourceViewKind ¶
type ResourceViewKind string
const ( ResourceCollection ResourceViewKind = "collection" ResourceItem ResourceViewKind = "item" )
type Response ¶
type Response struct {
Status string `json:"status"`
Description string `json:"description,omitempty"`
Content []*MediaType `json:"content,omitempty"`
Links []*OperationLink `json:"links,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Source SourceLocation `json:"source"`
}
type RouteSegment ¶
type Schema ¶
type Schema struct {
Ref string `json:"ref"`
Name string `json:"name,omitempty"`
Types []string `json:"types,omitempty"`
Title string `json:"title,omitempty"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Required []string `json:"required,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
Items *SchemaReference `json:"items,omitempty"`
AdditionalProperties *SchemaReference `json:"additionalProperties,omitempty"`
AdditionalAllowed *bool `json:"additionalAllowed,omitempty"`
AllOf []*SchemaReference `json:"allOf,omitempty"`
OneOf []*SchemaReference `json:"oneOf,omitempty"`
AnyOf []*SchemaReference `json:"anyOf,omitempty"`
Not *SchemaReference `json:"not,omitempty"`
Nullable bool `json:"nullable,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
WriteOnly bool `json:"writeOnly,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Enum []any `json:"enum,omitempty"`
Default any `json:"default,omitempty"`
Example any `json:"example,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
Maximum *float64 `json:"maximum,omitempty"`
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
MultipleOf *float64 `json:"multipleOf,omitempty"`
MinLength uint64 `json:"minLength,omitempty"`
MaxLength *uint64 `json:"maxLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
MinItems uint64 `json:"minItems,omitempty"`
MaxItems *uint64 `json:"maxItems,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty"`
MinProperties uint64 `json:"minProperties,omitempty"`
MaxProperties *uint64 `json:"maxProperties,omitempty"`
Discriminator *Discriminator `json:"discriminator,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Source SourceLocation `json:"source"`
}
type SchemaReference ¶
type SchemaReference struct {
Ref string `json:"ref"`
}
type SchemaRole ¶
type SchemaRole string
const ( SchemaRoleRequest SchemaRole = "request" SchemaRoleResponse SchemaRole = "response" SchemaRoleListItem SchemaRole = "list-item" SchemaRoleError SchemaRole = "error" SchemaRoleParameter SchemaRole = "parameter" SchemaRoleEvent SchemaRole = "event" )
type SchemaUse ¶
type SchemaUse struct {
OperationID string `json:"operationId"`
SchemaRef string `json:"schemaRef"`
Role SchemaRole `json:"role"`
Context string `json:"context,omitempty"`
}
type SecurityRequirement ¶
type SecurityRequirement struct {
Schemes []SecuritySchemeUse `json:"schemes"`
}
type SecurityScheme ¶
type SecurityScheme struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
ParameterName string `json:"parameterName,omitempty"`
In string `json:"in,omitempty"`
Scheme string `json:"scheme,omitempty"`
BearerFormat string `json:"bearerFormat,omitempty"`
OpenIDConnectURL string `json:"openIdConnectUrl,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Source SourceLocation `json:"source"`
}
type SecuritySchemeUse ¶
type SecurityState ¶
type SecurityState string
const ( SecurityInherited SecurityState = "inherited" SecurityNone SecurityState = "none" SecurityOverride SecurityState = "override" )
type Server ¶
type Server struct {
URL string `json:"url"`
Description string `json:"description,omitempty"`
Variables map[string]ServerVariable `json:"variables,omitempty"`
Extensions map[string]ExtensionValue `json:"extensions,omitempty"`
Source SourceLocation `json:"source"`
}
type ServerVariable ¶
Click to show internal directories.
Click to hide internal directories.