Пример #1
0
	})
	a.Attribute("body", d.String, "The comment body", func() {
		a.Example("This is really interesting")
	})
	a.Attribute("body.rendered", d.String, "The comment body rendered in HTML", func() {
		a.Example("<p>This is really interesting</p>\n")
	})
	a.Attribute("markup", d.String, "The comment markup associated with the body", func() {
		a.Example("Markdown")
	})
})

var createCommentAttributes = a.Type("CreateCommentAttributes", func() {
	a.Description(`JSONAPI store for all the "attributes" for creating a comment. +See also see http://jsonapi.org/format/#document-resource-object-attributes`)
	a.Attribute("body", d.String, "The comment body", func() {
		a.MinLength(1) // Empty comment not allowed
		a.Example("This is really interesting")
	})
	a.Attribute("markup", d.String, "The comment markup associated with the body", func() {
		a.Example("Markdown")
	})
	a.Required("body")
})

var commentRelationships = a.Type("CommentRelations", func() {
	a.Attribute("created-by", commentCreatedBy, "This defines the created by relation")
	a.Attribute("parent", relationGeneric, "This defines the owning resource of the comment")
})

var commentCreatedBy = a.Type("CommentCreatedBy", func() {
	a.Attribute("data", identityRelationData)
Пример #2
0
package design

import (
	d "github.com/goadesign/goa/design"
	a "github.com/goadesign/goa/design/apidsl"
)

// CreateWorkItemPayload defines the structure of work item payload
var CreateWorkItemPayload = a.Type("CreateWorkItemPayload", func() {
	a.Attribute("type", d.String, "The type of the newly created work item", func() {
		a.Example("userstory")
		a.MinLength(1)
		a.Pattern("^[\\p{L}.]+$")
	})
	a.Attribute("fields", a.HashOf(d.String, d.Any), "The field values, must conform to the type", func() {
		a.Example(map[string]interface{}{"system.creator": "user-ref", "system.state": "new", "system.title": "Example story"})
		a.MinLength(1)
	})
	a.Required("type", "fields")
})

// UpdateWorkItemPayload has been added because the design.WorkItem could
// not be used since it mandated the presence of the ID in the payload
// which ideally should be optional. The ID should be passed on to REST URL.
var UpdateWorkItemPayload = a.Type("UpdateWorkItemPayload", func() {
	a.Attribute("type", d.String, "The type of the newly created work item", func() {
		a.Example("userstory")
		a.MinLength(1)
		a.Pattern("^[\\p{L}.]+$")
	})
	a.Attribute("fields", a.HashOf(d.String, d.Any), "The field values, must conform to the type", func() {