design

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Account = MediaType("application/vnd.account+json", func() {
	Description("A tenant account")
	Attributes(func() {
		Attribute("id", Integer, "ID of account", func() {
			Example(1)
		})
		Attribute("href", String, "API href of account", func() {
			Example("/accounts/1")
		})
		Attribute("name", String, "Name of account", func() {
			Example("test")
		})
		Attribute("created_at", DateTime, "Date of creation")
		Attribute("created_by", String, "Email of account owner", func() {
			Format("email")
			Example("me@goa.design")
		})

		Required("id", "href", "name", "created_at", "created_by")
	})

	View("default", func() {
		Attribute("id")
		Attribute("href")
		Attribute("name")
		Attribute("created_at")
		Attribute("created_by")
	})

	View("tiny", func() {
		Description("tiny is the view used to list accounts")
		Attribute("id")
		Attribute("href")
		Attribute("name")
	})

	View("link", func() {
		Attribute("id")
		Attribute("href")
	})
})

Account is the account resource media type.

View Source
var Bottle = MediaType("application/vnd.bottle+json", func() {
	Description("A bottle of wine")
	Reference(BottlePayload)
	Attributes(func() {
		Attribute("id", Integer, "ID of bottle", func() {
			Example(1)
		})
		Attribute("href", String, "API href of bottle", func() {
			Example("/accounts/1/bottles/1")
		})
		Attribute("rating", Integer, "Rating of bottle between 1 and 5", func() {
			Minimum(1)
			Maximum(5)
		})
		Attribute("account", Account, "Account that owns bottle")
		Attribute("created_at", DateTime, "Date of creation")
		Attribute("updated_at", DateTime, "Date of last update")

		Attribute("name")
		Attribute("vineyard")
		Attribute("varietal")
		Attribute("vintage")
		Attribute("color")
		Attribute("sweetness")
		Attribute("country")
		Attribute("region")
		Attribute("review")

		Required("id", "href", "name", "vineyard", "varietal", "vintage", "color")
		Required("created_at")
	})

	Links(func() {
		Link("account")
	})

	View("default", func() {
		Attribute("id")
		Attribute("href")
		Attribute("name")
		Attribute("rating")
		Attribute("vineyard")
		Attribute("varietal")
		Attribute("vintage")
		Attribute("account", func() {
			View("tiny")
		})
		Attribute("links")
	})

	View("tiny", func() {
		Attribute("id")
		Attribute("href")
		Attribute("name")
		Attribute("rating")
		Attribute("links")
	})

	View("full", func() {
		Attribute("id")
		Attribute("href")
		Attribute("name")
		Attribute("account")
		Attribute("rating")
		Attribute("vineyard")
		Attribute("varietal")
		Attribute("vintage")
		Attribute("color")
		Attribute("sweetness")
		Attribute("country")
		Attribute("region")
		Attribute("review")
		Attribute("created_at")
		Attribute("updated_at")
		Attribute("links")
	})
})

Bottle is the bottle resource media type.

View Source
var BottlePayload = Type("BottlePayload", func() {
	Attribute("name", func() {
		MinLength(2)
		Example("Number 8")
	})
	Attribute("vineyard", func() {
		MinLength(2)
		Example("Asti")
	})
	Attribute("varietal", func() {
		MinLength(4)
		Example("Merlot")
	})
	Attribute("vintage", Integer, func() {
		Minimum(1900)
		Maximum(2020)
		Example(2012)
	})
	Attribute("color", func() {
		Enum("red", "white", "rose", "yellow", "sparkling")
	})
	Attribute("sweetness", Integer, func() {
		Minimum(1)
		Maximum(5)
	})
	Attribute("country", func() {
		MinLength(2)
		Example("USA")
	})
	Attribute("region", func() {
		Example("Napa Valley")
	})
	Attribute("review", func() {
		MinLength(3)
		MaxLength(300)
		Example("Great and inexpensive")
	})
})

BottlePayload defines the data structure used in the create bottle request body. It is also the base type for the bottle media type used to render bottles.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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