openapi

package
v0.0.0-...-258337a Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StubItem = Item{
	Id:           "a619249d-8d5a-4b40-8b1f-ba4da2f8199b",
	LanguageId:   "20f329ac-123f-48f0-917d-a70497cfd22a",
	LanguageName: "Esperanto",
	Value:        "Saluton mondo",
}

StubItem is a sample item for this simple implementation

View Source
var StubLanguage = Language{
	Id:          "20f329ac-123f-48f0-917d-a70497cfd22a",
	Name:        "Esperanto",
	Description: "Esperanto is a constructed auxiliary language. Its creator was L. L. Zamenhof, a Polish eye doctor.",
}

StubLanguage is a sample language for this example

Functions

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

func ReadFormFilesToTempFiles

func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)

ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files

Types

type Error

type Error struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

type ImplResponse

type ImplResponse struct {
	Code int
	Body interface{}
}

Implementation response defines an error code with the associated body

func Response

func Response(code int, body interface{}) ImplResponse

Response return a ImplResponse struct filled

type Item

type Item struct {
	Id           string `json:"id,omitempty"`
	LanguageId   string `json:"languageId"`
	LanguageName string `json:"languageName,omitempty"`
	Value        string `json:"value"`
}

type ItemsApiController

type ItemsApiController struct {
	// contains filtered or unexported fields
}

A ItemsApiController binds http requests to an api service and writes the service results to the http response

func (*ItemsApiController) CreateItem

func (c *ItemsApiController) CreateItem(w http.ResponseWriter, r *http.Request)

CreateItem - Creates a new Hello World item.

func (*ItemsApiController) DeleteItem

func (c *ItemsApiController) DeleteItem(w http.ResponseWriter, r *http.Request)

DeleteItem - Deletes a Hello World item.

func (*ItemsApiController) GetItem

GetItem - Returns a Hello World item.

func (*ItemsApiController) GetItems

func (c *ItemsApiController) GetItems(w http.ResponseWriter, r *http.Request)

GetItems - Returns a list of Hello World items.

func (*ItemsApiController) Routes

func (c *ItemsApiController) Routes() Routes

Routes returns all of the api route for the ItemsApiController

func (*ItemsApiController) UpdateItem

func (c *ItemsApiController) UpdateItem(w http.ResponseWriter, r *http.Request)

UpdateItem - Updates a Hello World item.

type ItemsApiRouter

type ItemsApiRouter interface {
	CreateItem(http.ResponseWriter, *http.Request)
	DeleteItem(http.ResponseWriter, *http.Request)
	GetItem(http.ResponseWriter, *http.Request)
	GetItems(http.ResponseWriter, *http.Request)
	UpdateItem(http.ResponseWriter, *http.Request)
}

ItemsApiRouter defines the required methods for binding the api requests to a responses for the ItemsApi The ItemsApiRouter implementation should parse necessary information from the http request, pass the data to a ItemsApiServicer to perform the required actions, then write the service results to the http response.

type ItemsApiService

type ItemsApiService struct {
}

ItemsApiService is a service that implents the logic for the ItemsApiServicer This service should implement the business logic for every endpoint for the ItemsApi API. Include any external packages or services that will be required by this service.

func (*ItemsApiService) CreateItem

func (s *ItemsApiService) CreateItem(ctx context.Context, item Item) (ImplResponse, error)

CreateItem - Creates a new Hello World item.

func (*ItemsApiService) DeleteItem

func (s *ItemsApiService) DeleteItem(ctx context.Context, id string) (ImplResponse, error)

DeleteItem - Deletes a Hello World item.

func (*ItemsApiService) GetItem

func (s *ItemsApiService) GetItem(ctx context.Context, id string) (ImplResponse, error)

GetItem - Returns a Hello World item.

func (*ItemsApiService) GetItems

func (s *ItemsApiService) GetItems(ctx context.Context, languageId string) (ImplResponse, error)

GetItems - Returns a list of Hello World items.

func (*ItemsApiService) UpdateItem

func (s *ItemsApiService) UpdateItem(ctx context.Context, id string, item Item) (ImplResponse, error)

UpdateItem - Updates a Hello World item.

type ItemsApiServicer

type ItemsApiServicer interface {
	CreateItem(context.Context, Item) (ImplResponse, error)
	DeleteItem(context.Context, string) (ImplResponse, error)
	GetItem(context.Context, string) (ImplResponse, error)
	GetItems(context.Context, string) (ImplResponse, error)
	UpdateItem(context.Context, string, Item) (ImplResponse, error)
}

ItemsApiServicer defines the api actions for the ItemsApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

func NewItemsApiService

func NewItemsApiService() ItemsApiServicer

NewItemsApiService creates a default api service

type Language

type Language struct {
	Id          string `json:"id,omitempty"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

type LanguagesApiController

type LanguagesApiController struct {
	// contains filtered or unexported fields
}

A LanguagesApiController binds http requests to an api service and writes the service results to the http response

func (*LanguagesApiController) CreateLanguage

func (c *LanguagesApiController) CreateLanguage(w http.ResponseWriter, r *http.Request)

CreateLanguage - Creates a new langauge.

func (*LanguagesApiController) DeleteLanguage

func (c *LanguagesApiController) DeleteLanguage(w http.ResponseWriter, r *http.Request)

DeleteLanguage - Deletes a langauge.

func (*LanguagesApiController) GetLanguage

func (c *LanguagesApiController) GetLanguage(w http.ResponseWriter, r *http.Request)

GetLanguage - Returns a language.

func (*LanguagesApiController) GetLanguages

func (c *LanguagesApiController) GetLanguages(w http.ResponseWriter, r *http.Request)

GetLanguages - Returns a list of languages.

func (*LanguagesApiController) Routes

func (c *LanguagesApiController) Routes() Routes

Routes returns all of the api route for the LanguagesApiController

func (*LanguagesApiController) UpdateLanguage

func (c *LanguagesApiController) UpdateLanguage(w http.ResponseWriter, r *http.Request)

UpdateLanguage - Updates a langauge.

type LanguagesApiRouter

type LanguagesApiRouter interface {
	CreateLanguage(http.ResponseWriter, *http.Request)
	DeleteLanguage(http.ResponseWriter, *http.Request)
	GetLanguage(http.ResponseWriter, *http.Request)
	GetLanguages(http.ResponseWriter, *http.Request)
	UpdateLanguage(http.ResponseWriter, *http.Request)
}

LanguagesApiRouter defines the required methods for binding the api requests to a responses for the LanguagesApi The LanguagesApiRouter implementation should parse necessary information from the http request, pass the data to a LanguagesApiServicer to perform the required actions, then write the service results to the http response.

type LanguagesApiService

type LanguagesApiService struct {
}

LanguagesApiService is a service that implents the logic for the LanguagesApiServicer This service should implement the business logic for every endpoint for the LanguagesApi API. Include any external packages or services that will be required by this service.

func (*LanguagesApiService) CreateLanguage

func (s *LanguagesApiService) CreateLanguage(ctx context.Context, language Language) (ImplResponse, error)

CreateLanguage - Creates a new langauge.

func (*LanguagesApiService) DeleteLanguage

func (s *LanguagesApiService) DeleteLanguage(ctx context.Context, id string) (ImplResponse, error)

DeleteLanguage - Deletes a langauge.

func (*LanguagesApiService) GetLanguage

func (s *LanguagesApiService) GetLanguage(ctx context.Context, id string) (ImplResponse, error)

GetLanguage - Returns a language.

func (*LanguagesApiService) GetLanguages

func (s *LanguagesApiService) GetLanguages(ctx context.Context) (ImplResponse, error)

GetLanguages - Returns a list of languages.

func (*LanguagesApiService) UpdateLanguage

func (s *LanguagesApiService) UpdateLanguage(ctx context.Context, id string, language Language) (ImplResponse, error)

UpdateLanguage - Updates a langauge.

type LanguagesApiServicer

type LanguagesApiServicer interface {
	CreateLanguage(context.Context, Language) (ImplResponse, error)
	DeleteLanguage(context.Context, string) (ImplResponse, error)
	GetLanguage(context.Context, string) (ImplResponse, error)
	GetLanguages(context.Context) (ImplResponse, error)
	UpdateLanguage(context.Context, string, Language) (ImplResponse, error)
}

LanguagesApiServicer defines the api actions for the LanguagesApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

func NewLanguagesApiService

func NewLanguagesApiService() LanguagesApiServicer

NewLanguagesApiService creates a default api service

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

A Route defines the parameters for an api endpoint

type Router

type Router interface {
	Routes() Routes
}

Router defines the required methods for retrieving api routes

func NewItemsApiController

func NewItemsApiController(s ItemsApiServicer) Router

NewItemsApiController creates a default api controller

func NewLanguagesApiController

func NewLanguagesApiController(s LanguagesApiServicer) Router

NewLanguagesApiController creates a default api controller

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

Jump to

Keyboard shortcuts

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