api

package
v0.0.0-...-25cfcb1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 12 Imported by: 0

README

Go API Server for api

This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about Swagger at http://swagger.io. In the third iteration of the pet store, we've switched to the design first approach! You can now help us improve the API whether it's by making changes to the definition itself or to the code. That way, with time, we can improve the API in general, and expose some of the new features in OAS3.

Some useful links:

Overview

This server was generated by the [openapi-generator] (https://openapi-generator.tech) project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.

To see how to make this your own, look here:

README

  • API version: 1.0.17
  • Build date: 2024-02-11T15:02:25.984335-08:00[America/Los_Angeles]
Running the server

To run the server, follow these simple steps:

go run main.go

To run the server in a docker container

docker build --network=host -t api .

Once the image is built, just run

docker run --rm -it api
Known Issue

Endpoints sharing a common path may result in issues. For example, /v2/pet/findByTags and /v2/pet/:petId will result in an issue with the Gin framework. For more information about this known limitation, please refer to gin-gonic/gin#388 for more information.

A workaround is to manually update the path and handler. Please refer to gin-gonic/gin/issues/205#issuecomment-296155497 for more information.

Documentation

Index

Constants

View Source
const PATH_PARAM_USERNAME = "username"

Variables

This section is empty.

Functions

func DefaultHandleFunc

func DefaultHandleFunc(c *gin.Context)

Default handler for not yet implemented routes

func Index

func Index(c *gin.Context)

Index is the index handler.

func NewRouter

func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine

NewRouter returns a new router.

func NewRouterWithGinEngine

func NewRouterWithGinEngine(router *gin.Engine, handleFunctions ApiHandleFunctions) *gin.Engine

NewRouter add routes to existing gin engine.

func Version

func Version(c *gin.Context)

Types

type Address

type Address struct {
	Street string `json:"street,omitempty"`

	City string `json:"city,omitempty"`

	State string `json:"state,omitempty"`

	Zip string `json:"zip,omitempty"`
}

type ApiHandleFunctions

type ApiHandleFunctions struct {

	// Routes for the PetAPI part of the API
	PetAPI PetAPI
	// Routes for the StoreAPI part of the API
	StoreAPI StoreAPI
	// Routes for the UserAPI part of the API
	UserAPI UserAPI
}

type ApiResponse

type ApiResponse struct {
	Code int32 `json:"code,omitempty"`

	Type string `json:"type,omitempty"`

	Message string `json:"message,omitempty"`
}

type Category

type Category struct {
	Id int64 `json:"id,omitempty"`

	Name string `json:"name,omitempty"`
}

type Customer

type Customer struct {
	Id string `json:"id,omitempty"`

	Username string `json:"username,omitempty"`

	Address []Address `json:"address,omitempty"`
}

type Order

type Order struct {
	Id string `json:"id,omitempty"`

	PetId int64 `json:"petId,omitempty"`

	Quantity int32 `json:"quantity,omitempty"`

	ShipDate time.Time `json:"shipDate,omitempty"`

	// Order Status
	Status string `json:"status,omitempty"`

	Complete bool `json:"complete,omitempty"`
}

type Pet

type Pet struct {
	Id string `json:"id,omitempty"`

	Name string `json:"name"`

	Category Category `json:"category,omitempty"`

	PhotoUrls []string `json:"photoUrls"`

	Tags []Tag `json:"tags,omitempty"`

	// pet status in the store
	Status string `json:"status,omitempty"`
}

type PetAPI

type PetAPI struct {
}

func (*PetAPI) AddPet

func (api *PetAPI) AddPet(c *gin.Context)

Post /api/v3/pet Add a new pet to the store

func (*PetAPI) DeletePet

func (api *PetAPI) DeletePet(c *gin.Context)

Delete /api/v3/pet/:petId Deletes a pet

func (*PetAPI) FindPetsByStatus

func (api *PetAPI) FindPetsByStatus(c *gin.Context)

Get /api/v3/pet/findByStatus Finds Pets by status

func (*PetAPI) FindPetsByTags

func (api *PetAPI) FindPetsByTags(c *gin.Context)

Get /api/v3/pet/findByTags Finds Pets by tags

func (*PetAPI) GetPetById

func (api *PetAPI) GetPetById(c *gin.Context)

Get /api/v3/pet/:petId Find pet by ID

func (*PetAPI) UpdatePet

func (api *PetAPI) UpdatePet(c *gin.Context)

Put /api/v3/pet Update an existing pet

func (*PetAPI) UpdatePetWithForm

func (api *PetAPI) UpdatePetWithForm(c *gin.Context)

Post /api/v3/pet/:petId Updates a pet in the store with form data

func (*PetAPI) UploadFile

func (api *PetAPI) UploadFile(c *gin.Context)

Post /api/v3/pet/:petId/uploadImage uploads an image

type Route

type Route struct {
	// Name is the name of this Route.
	Name string
	// Method is the string for the HTTP method. ex) GET, POST etc..
	Method string
	// Pattern is the pattern of the URI.
	Pattern string
	// HandlerFunc is the handler function of this route.
	HandlerFunc gin.HandlerFunc
}

Route is the information for every URI.

type StoreAPI

type StoreAPI struct {
}

func (*StoreAPI) DeleteOrder

func (api *StoreAPI) DeleteOrder(c *gin.Context)

Delete /api/v3/store/order/:orderId Delete purchase order by ID

func (*StoreAPI) GetInventory

func (api *StoreAPI) GetInventory(c *gin.Context)

Get /api/v3/store/inventory Returns pet inventories by status

func (*StoreAPI) GetOrderById

func (api *StoreAPI) GetOrderById(c *gin.Context)

Get /api/v3/store/order/:orderId Find purchase order by ID

func (*StoreAPI) PlaceOrder

func (api *StoreAPI) PlaceOrder(c *gin.Context)

Post /api/v3/store/order Place an order for a pet

type Tag

type Tag struct {
	Id string `json:"id,omitempty"`

	Name string `json:"name,omitempty"`
}

type User

type User struct {
	Id string `json:"id,omitempty"`

	Username string `json:"username,omitempty"`

	FirstName string `json:"firstName,omitempty"`

	LastName string `json:"lastName,omitempty"`

	Email string `json:"email,omitempty"`

	Password string `json:"password,omitempty"`

	Phone string `json:"phone,omitempty"`

	// User Status
	UserStatus int32 `json:"userStatus,omitempty"`
}

type UserAPI

type UserAPI struct {
}

func (*UserAPI) CreateUser

func (api *UserAPI) CreateUser(c *gin.Context)

Post /api/v3/user Create user

func (*UserAPI) CreateUsersWithListInput

func (api *UserAPI) CreateUsersWithListInput(c *gin.Context)

Post /api/v3/user/createWithList Creates list of users with given input array

func (*UserAPI) DeleteUser

func (api *UserAPI) DeleteUser(c *gin.Context)

Delete /api/v3/user/:username Delete user

func (*UserAPI) GetUserByName

func (api *UserAPI) GetUserByName(c *gin.Context)

Get /api/v3/user/:username Get user by user name

func (*UserAPI) LoginUser

func (api *UserAPI) LoginUser(c *gin.Context)

Get /api/v3/user/login Logs user into the system

func (*UserAPI) LogoutUser

func (api *UserAPI) LogoutUser(c *gin.Context)

Get /api/v3/user/logout Logs out current logged in user session

func (*UserAPI) UpdateUser

func (api *UserAPI) UpdateUser(c *gin.Context)

Put /api/v3/user/:username Update user

Jump to

Keyboard shortcuts

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