petstore

package
v0.0.0-...-337ae54 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: 0BSD Imports: 4 Imported by: 0

Documentation

Overview

Package petstore serves as an example for how to represent a REST API specification.

Index

Constants

This section is empty.

Variables

View Source
var StatusValues = xyz.AccessorFor(Status.Values)

Functions

This section is empty.

Types

type API

type API struct {
	api.Specification `` /* 165-byte string literal not displayed */

	UploadImageForPet func(context.Context, PetID, string, fs.File) error `rest:"POST(multipart/form-data) /pet/{petId=%v}/uploadImage (additionalMetadata,file)"
		uploads an image.`
	AddPet func(context.Context, Pet) error `rest:"POST /pet"
        adds a new pet to the store.`
	SetPet func(context.Context, Pet) error `rest:"PUT /pet"
		update an existing pet.`
	FindByStatus func(context.Context, ...Status) ([]Pet, error) `rest:"GET /pet/findByStatus?status=%v"
		(multiple status values can be provided with comma separated strings)`
	FindByTags func(context.Context, ...string) ([]Pet, error) `` /* 149-byte string literal not displayed */

	GetPet func(context.Context, PetID) (Pet, error) `rest:"GET /pet/{petId=%v}"
		returns a single pet.`
	ModPet func(context.Context, Pet) error `rest:"POST(multipart/form-data) /pet/{petId}"
		updates a pet in the store with form data.`
	DeletePet func(context.Context, PetID) error `rest:"DELETE /pet/{petId=%v}"`
}

API specification, named this way, as it is the runtime.link convention. Typically this will be placed in a file called api.go and will be at the top of the file, so that it can act as a table of contents for the API.

type Category

type Category struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Pet

type Pet struct {
	ID   PetID  `json:"id,omitempty" rest:"petId"`
	Name string `json:"name"
		of the pet.`
	PhotoURLs []string            `json:"photoUrls"`
	Tags      xyz.Maybe[[]Tag]    `json:"tags,omitempty"`     // optional
	Category  xyz.Maybe[Category] `json:"category,omitempty"` // optional
}

type PetID

type PetID int64

type Status

type Status xyz.Switch[string, struct {
	Available Status `json:"available"`
	Pending   Status `json:"pending"`
	Sold      Status `json:"sold"`
}]

type Tag

type Tag struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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