design

package
v0.0.0-...-c65c6a6 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccountData = MediaType("application/vnd.account+json", func() {
	Description("celler account")
	Attribute("id", Integer, "id", func() {
		Example(1)
	})
	Attribute("name", String, "名前", func() {
		Example("山田 太郎")
	})
	Attribute("email", String, "メールアドレス", func() {
		Example("example@gmail.com")
	})
	Required("id", "name", "email")
	View("default", func() {
		Attribute("id")
		Attribute("name")
		Attribute("email")
	})
})
View Source
var AccountMedia = MediaType("application/vnd.accountMedia+json", func() {
	Description("example")
	Attribute("data", ArrayOf(AccountData))
	Attribute("status", Integer, func() {
		Example(200)
	})
	Required("data", "status")
	View("default", func() {
		Attribute("data")
		Attribute("status")
	})
})
View Source
var ArticleData = Type("data", func() {
	Attribute("title", String)
	Attribute("body", String)
	Required("title", "body")
})
View Source
var ArticleMedia = MediaType("application/vnd.article+json", func() {
	Description("example")
	Attribute("data", ArrayOf(ArticleData))
	Attribute("response", OKMedia)
	Required("data", "response")
	View("default", func() {
		Attribute("data")
		Attribute("response")
	})
})
View Source
var BottleData = MediaType("application/vnd.bottle+json", func() {
	Description("celler bottles")
	Attribute("id", Integer, "id", func() {
		Example(1)
	})
	Attribute("name", String, "ボトル名", func() {
		Example("シャルドネ")
	})
	Attribute("quantity", Integer, "数量", func() {
		Example(4)
	})

	Attribute("account", AccountData)
	Attribute("categories", ArrayOf(CategoryData))
	Required("id", "name", "quantity", "account", "categories")
	View("default", func() {
		Attribute("id")
		Attribute("name")
		Attribute("quantity")
		Attribute("account")
	})
	View("relation", func() {
		Attribute("id")
		Attribute("name")
		Attribute("quantity")
		Attribute("account")
		Attribute("categories")
	})
})
View Source
var BottleMedia = MediaType("application/vnd.bottleMedia+json", func() {
	Description("example")
	Attribute("data", ArrayOf(BottleData))
	Attribute("status", Integer, func() {
		Example(200)
	})
	Required("data", "status")
	View("default", func() {
		Attribute("data")
		Attribute("status")
	})
})
View Source
var CategoryData = MediaType("application/vnd.category+json", func() {
	Description("celler account")
	Attribute("id", Integer, "id", func() {
		Example(1)
	})
	Attribute("name", String, "名前", func() {
		Example("ワイン")
	})
	Required("id", "name")
	View("default", func() {
		Attribute("id")
		Attribute("name")
	})
})
View Source
var CategoryMedia = MediaType("application/vnd.categoryMedia+json", func() {
	Description("example")
	Attribute("data", ArrayOf(CategoryData))
	Attribute("status", Integer, func() {
		Example(200)
	})
	Required("data", "status")
	View("default", func() {
		Attribute("data")
		Attribute("status")
	})
})
View Source
var CustomeErrorMedia = MediaType("application/vnd.error+json", func() {
	Attribute("response", ErrorValue)
	Required("response")
	View("default", func() {
		Attribute("response")
	})
})
View Source
var ErrorValue = Type("errorValue", func() {
	Attribute("status", Integer, func() {
		Example(400)
	})
	Attribute("code", String, func() {
		Example("bad_request")
	})
	Attribute("detail", String, func() {
		Example("xxx is nil")
	})
	Required("status", "code", "detail")
})
View Source
var IntegerMedia = MediaType("application/vnd.integer+json", func() {

	Description("example")

	Attributes(func() {

		Attribute("id", Integer, "id", func() {

			Example(1)
		})

		Required("id")
	})

	View("default", func() {
		Attribute("id")
	})
})

レスポンスデータの定義 MediaTypeに名前をつけます

View Source
var MessageMedia = MediaType("application/vnd.message+json", func() {
	Description("example")
	Attributes(func() {
		Attribute("message", String, "メッセージ", func() {
			Example("ok")
		})
		Required("message")
	})
	View("default", func() {
		Attribute("message")
	})
})
View Source
var OKMedia = Type("ok", func() {
	Attribute("status", Integer, func() {
		Example(200)
	})
	Required("status")
})
View Source
var UserAuth = APIKeySecurity("userToken", func() {
	Description("ユーザートークン")
	Header("X-Authorization")
})
View Source
var UserMedia = MediaType("application/vnd.user+json", func() {
	Description("example")
	Attributes(func() {
		Attribute("id", Integer, "id", func() {
			Example(1)
		})
		Attribute("name", String, "名前", func() {
			Example("hoge")
		})
		Attribute("email", String, "メールアドレス", func() {
			Example("satak47cpc@gmail.com")
		})
		Required("id", "name", "email")
	})

	View("default", func() {
		Attribute("id")
		Attribute("name")
		Attribute("email")
	})

	View("tiny", func() {
		Attribute("id")
		Attribute("name")
	})
})
View Source
var ValidationMedia = MediaType("application/vnd.validation+json", func() {
	Description("example")
	Attributes(func() {
		Attribute("id", Integer, "id", func() {
			Example(1)
		})
		Attribute("integerType", Integer, "数字(1〜10)", func() {
			Example(5)
		})
		Attribute("stringType", String, "文字(1~10文字)", func() {
			Example("あいうえお")
		})
		Attribute("email", String, "メールアドレス", func() {
			Example("example@gmail.com")
		})
		Attribute("enumType", String, "列挙型", func() {
			Example("A")
		})
		Attribute("defaultType", String, "デフォルト値", func() {
			Example("でふぉ")
		})
		Attribute("reg", String, "デフォルト値", func() {
			Example("12abc")
		})
	})
	Required("id", "integerType", "stringType", "email", "enumType", "defaultType", "reg")
	View("default", func() {
		Attribute("id")
		Attribute("integerType")
		Attribute("stringType")
		Attribute("email")
		Attribute("enumType")
		Attribute("defaultType")
		Attribute("reg")
	})
})

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