app

package module
v0.0.0-...-786563c Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 10 Imported by: 0

README

oapi-sample

OpenAPI and sqlc sample project

Requirements

  • Go 1.17
  • oapi-codegen
  • sqlc
  • postgresql 13

Setup

cd .devcontainer
docker compose up -d

go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.8.2
go install github.com/kyleconroy/sqlc/cmd/sqlc@latest

Build

go build cmd/server/main.go

Run

go run cmd/server/main.go

Generate

Updates docs/openapi.yaml or sql//**.sql. generate.

go generate

or

for docs/openapi.yaml

oapi-codegen --config=types.cfg.yaml docs/openapi.yaml
oapi-codegen --config=server.cfg.yaml docs/openapi.yaml

for sql//**.sql

sqlc generate -f sqlc.yaml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(conn *sql.DB) (*db.Queries, error)

Types

type ItemStore

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

func NewItemStore

func NewItemStore(queries *db.Queries, ctx context.Context) *ItemStore

func (*ItemStore) DeleteItem

func (i *ItemStore) DeleteItem(w http.ResponseWriter, r *http.Request, itemId openapi.ItemId)

func (*ItemStore) GetItemById

func (i *ItemStore) GetItemById(w http.ResponseWriter, r *http.Request, itemId openapi.ItemId)

func (*ItemStore) GetItems

func (i *ItemStore) GetItems(w http.ResponseWriter, r *http.Request, params openapi.GetItemsParams)

func (*ItemStore) PatchItem

func (i *ItemStore) PatchItem(w http.ResponseWriter, r *http.Request, itemId openapi.ItemId)

func (*ItemStore) PostItems

func (i *ItemStore) PostItems(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
cmd
server command
gen
db
openapi
Package openapi provides primitives to interact with the openapi HTTP API.
Package openapi provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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