openapi

package
v0.0.0-...-9862088 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OAS2             = "2.0"
	OAS3             = "3.0"
	APPLICATION_JSON = "application/json"
	JSON_MERGE_PATCH = "application/merge-patch+json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Components

type Components struct {
	Schemas map[string]Schema `json:"schemas"`
}

type Contact

type Contact struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
	URL   string `json:"url,omitempty"`
}

type Info

type Info struct {
	Title       string  `json:"title"`
	Description string  `json:"description"`
	Version     string  `json:"version"`
	Contact     Contact `json:"contact,omitempty"`
}

type MediaType

type MediaType struct {
	Schema *Schema `json:"schema,omitempty"`
}

type OpenAPI

type OpenAPI struct {
	// oas 2.0 has swagger in the root.
	Swagger    string               `json:"swagger,omitempty"`
	Info       Info                 `json:"info"`
	OpenAPI    string               `json:"openapi,omitempty"`
	Servers    []Server             `json:"servers,omitempty"`
	Paths      map[string]*PathItem `json:"paths"`
	Components Components           `json:"components,omitempty"`
	// oas 2.0 has definitions in the root.
	Definitions map[string]Schema `json:"definitions,omitempty"`
}

func FetchOpenAPI

func FetchOpenAPI(pathOrURL string) (*OpenAPI, error)

func (*OpenAPI) DereferenceSchema

func (o *OpenAPI) DereferenceSchema(schema Schema) (*Schema, error)

func (*OpenAPI) GetSchemaFromRequestBody

func (o *OpenAPI) GetSchemaFromRequestBody(r RequestBody, contentType string) *Schema

func (*OpenAPI) GetSchemaFromResponse

func (o *OpenAPI) GetSchemaFromResponse(r Response, contentType string) *Schema

func (*OpenAPI) OASVersion

func (o *OpenAPI) OASVersion() string

type Operation

type Operation struct {
	Summary                  string                    `json:"summary,omitempty"`
	Description              string                    `json:"description,omitempty"`
	OperationID              string                    `json:"operationId,omitempty"`
	Parameters               []Parameter               `json:"parameters,omitempty"`
	Responses                map[string]Response       `json:"responses,omitempty"`
	RequestBody              *RequestBody              `json:"requestBody,omitempty"`
	XAEPLongRunningOperation *XAEPLongRunningOperation `json:"x-aep-long-running-operation,omitempty"`
}

type Parameter

type Parameter struct {
	Name        string     `json:"name,omitempty"`
	In          string     `json:"in,omitempty"`
	Description string     `json:"description,omitempty"`
	Required    bool       `json:"required,omitempty"`
	Schema      *Schema    `json:"schema,omitempty"`
	Type        string     `json:"type,omitempty"`
	XAEPField   *XAEPField `json:"x-aep-field,omitempty"`
}

type PathItem

type PathItem struct {
	Get    *Operation `json:"get,omitempty"`
	Patch  *Operation `json:"patch,omitempty"`
	Post   *Operation `json:"post,omitempty"`
	Put    *Operation `json:"put,omitempty"`
	Delete *Operation `json:"delete,omitempty"`
}

type Properties

type Properties map[string]Schema

type RequestBody

type RequestBody struct {
	Description string               `json:"description,omitempty"`
	Content     map[string]MediaType `json:"content"`
	Required    bool                 `json:"required"`
	// oas 2.0 has the schema in the request body.
	Schema *Schema `json:"schema,omitempty"`
}

type Response

type Response struct {
	Description string               `json:"description,omitempty"`
	Content     map[string]MediaType `json:"content,omitempty"`
	// oas 2.0 has the schema in the response.
	Schema *Schema `json:"schema,omitempty"`
}

type Schema

type Schema struct {
	Type         string        `json:"type,omitempty"`
	Format       string        `json:"format,omitempty"`
	Items        *Schema       `json:"items,omitempty"`
	Properties   Properties    `json:"properties,omitempty"`
	Ref          string        `json:"$ref,omitempty"`
	XAEPResource *XAEPResource `json:"x-aep-resource,omitempty"`
	XAEPField    *XAEPField    `json:"x-aep-field,omitempty"`
	/// Documents the name of the proto message to use for generation.
	/// If unset, proto generation will not create a proto message for this schema.
	XAEPProtoMessageName string   `json:"x-aep-proto-message-name,omitempty"`
	ReadOnly             bool     `json:"readOnly,omitempty"`
	Required             []string `json:"required,omitempty"`
	Description          string   `json:"description,omitempty"`
	// AdditionalProperties can be a bool and an object - this allows
	// handling for both.
	AdditionalProperties json.RawMessage `json:"additionalProperties,omitempty"`
}

type Server

type Server struct {
	URL         string                    `json:"url"`
	Description string                    `json:"description,omitempty"`
	Variables   map[string]ServerVariable `json:"variables,omitempty"`
}

type ServerVariable

type ServerVariable struct {
	Enum        []string `json:"enum,omitempty"`
	Default     string   `json:"default"`
	Description string   `json:"description,omitempty"`
}

type XAEPField

type XAEPField struct {
	Behavior                   []string `json:"behavior,omitempty"`
	ResourceReference          []string `json:"resource_reference,omitempty"`
	ResourceReferenceChildType []string `json:"resource_reference_child_type,omitempty"`
	FieldNumber                int      `json:"field_number,omitempty"`
}

type XAEPLongRunningOperation

type XAEPLongRunningOperation struct {
	Response XAEPLongRunningOperationResponse `json:"response,omitempty"`
}

type XAEPLongRunningOperationResponse

type XAEPLongRunningOperationResponse struct {
	Schema *Schema `json:"schema,omitempty"`
}

type XAEPResource

type XAEPResource struct {
	Singular string   `json:"singular,omitempty"`
	Plural   string   `json:"plural,omitempty"`
	Patterns []string `json:"patterns,omitempty"`
	Parents  []string `json:"parents,omitempty"`
	Type     string   `json:"type,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL