Documentation
¶
Index ¶
- Constants
- func AddImplicitFieldsAndValidate(api *API) error
- func CollectionName(r *Resource) string
- func ConvertToOpenAPI(api *API) (*openapi.OpenAPI, error)
- func OperationSchema() openapi.Schema
- type API
- type ApplyMethod
- type Contact
- type CreateMethod
- type CustomMethod
- type DeleteMethod
- type GetMethod
- type ListMethod
- type Methods
- type PathWithParams
- type PatternInfo
- type Resource
- type UpdateMethod
Constants ¶
View Source
const (
AEP_OPERATION_REF = "https://aep.dev/json-schema/type/operation.json"
)
Variables ¶
This section is empty.
Functions ¶
func AddImplicitFieldsAndValidate ¶
addImplicitFieldsAndValidate adds implicit fields to the API object, such as the "path" variable in the resource.
func CollectionName ¶
return the collection name of the resource, but deduplicate the name of the previous parent e.g: - book-editions becomes editions under the parent resource book.
func OperationSchema ¶
Types ¶
type API ¶
type API struct {
ServerURL string `json:"server_url"`
Name string
Contact *Contact
Schemas map[string]*openapi.Schema
// A list of the resources that are exposed by the API.
//
// The key "operation" carries a special meaning, and must
// map to an aep.dev/151 Operation resource.
Resources map[string]*Resource
}
func ExampleAPI ¶
func ExampleAPI() *API
func LoadAPIFromJson ¶
func (*API) ConvertToOpenAPIBytes ¶
type ApplyMethod ¶
type ApplyMethod struct {
IsLongRunning bool `json:"is_long_running"`
}
type CreateMethod ¶
type CustomMethod ¶
type DeleteMethod ¶
type DeleteMethod struct {
IsLongRunning bool `json:"is_long_running"`
}
type ListMethod ¶
type Methods ¶
type Methods struct {
Get *GetMethod `json:"get,omitempty"`
List *ListMethod `json:"list,omitempty"`
Apply *ApplyMethod `json:"apply,omitempty"`
Create *CreateMethod `json:"create,omitempty"`
Update *UpdateMethod `json:"update,omitempty"`
Delete *DeleteMethod `json:"delete,omitempty"`
}
type PathWithParams ¶
PathWithParams passes an http path with the OpenAPI parameters it contains. helpful to bundle them both when iterating.
type PatternInfo ¶
type Resource ¶
type Resource struct {
// the resource singular name is the name of the resource
// in the API. It is used to generate the pattern for the resource.
// e.g: book-edition -> book-editions
//
// The singular name is also used to generate the schema name.
// e.g: book-edition -> BookEdition
//
// the resource singular **must** be in kebab-case.
Singular string `json:"singular"`
Plural string `json:"plural"`
Parents []string `json:"parents,omitempty"`
// Children is populated on load
Children []*Resource `json:"-"`
// the API reference is used to retrieve things like the parent resources.
API *API `json:"-"`
Schema *openapi.Schema `json:"schema,omitempty"`
Methods Methods `json:"methods,omitempty"`
CustomMethods []*CustomMethod `json:"custom_methods,omitempty"`
// contains filtered or unexported fields
}
func OperationResource ¶
func OperationResource(m Methods, cm []*CustomMethod) *Resource
Return a longrunningoperation resource
func OperationResourceWithDefaults ¶
func OperationResourceWithDefaults() *Resource
func (*Resource) GetPattern ¶
func (*Resource) ParentResources ¶
return the parent resources of the resource.
This function should only be called until after the API has been validated.
func (*Resource) PatternElems ¶
GeneratePatternStrings generates the pattern strings for a resource TODO(yft): support multiple parents
type UpdateMethod ¶
type UpdateMethod struct {
IsLongRunning bool `json:"is_long_running"`
}
Click to show internal directories.
Click to hide internal directories.