Example #1
0
// JSONResourceObject creates a single resource object
func JSONResourceObject(name string, attributes *d.UserTypeDefinition, relationships *d.UserTypeDefinition) *d.UserTypeDefinition {
	return a.Type(name, func() {
		a.Attribute("type", d.String, func() {
			a.Enum(strings.ToLower(name) + "s")
		})
		a.Attribute("id", d.String, "ID of the "+name, func() {
			a.Example("42")
		})
		a.Attribute("attributes", attributes)
		if relationships != nil {
			a.Attribute("relationships", relationships)
		}
		a.Required("type", "id", "attributes")
	})
}
package design

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

// workItemLinkCategoryLinks has `self` as of now according to http://jsonapi.org/format/#fetching-resources
var workItemLinkCategoryLinks = a.Type("WorkItemLinkCategoryLinks", func() {
	a.Attribute("self", d.String, func() {
		a.Example("http://api.almighty.io/api/workitemlinkcategories/2d98c73d-6969-4ea6-958a-812c832b6c18")
	})
	a.Required("self")
})

// createWorkItemLinkCategoryPayload defines the structure of work item link category payload in JSONAPI format during creation
var createWorkItemLinkCategoryPayload = a.Type("CreateWorkItemLinkCategoryPayload", func() {
	a.Attribute("data", workItemLinkCategoryData)
	a.Required("data")
})

// updateWorkItemLinkCategoryPayload defines the structure of work item link category payload in JSONAPI format during update
var updateWorkItemLinkCategoryPayload = a.Type("UpdateWorkItemLinkCategoryPayload", func() {
	a.Attribute("data", workItemLinkCategoryData)
	a.Required("data")
})

// workItemLinkCategoryListMeta holds meta information for a work item link category array response
var workItemLinkCategoryListMeta = a.Type("WorkItemLinkCategoryListMeta", func() {
	a.Attribute("totalCount", d.Integer, func() {
		a.Minimum(0)
Example #3
0
package design

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

var comment = a.Type("Comment", func() {
	a.Description(`JSONAPI store for the data of a comment.  See also http://jsonapi.org/format/#document-resource-object`)
	a.Attribute("type", d.String, func() {
		a.Enum("comments")
	})
	a.Attribute("id", d.UUID, "ID of comment", func() {
		a.Example("40bbdd3d-8b5d-4fd6-ac90-7236b669af04")
	})
	a.Attribute("attributes", commentAttributes)
	a.Attribute("relationships", commentRelationships)
	a.Attribute("links", genericLinks)
	a.Required("type")
})

var createComment = a.Type("CreateComment", func() {
	a.Description(`JSONAPI store for the data of a comment.  See also http://jsonapi.org/format/#document-resource-object`)
	a.Attribute("type", d.String, func() {
		a.Enum("comments")
	})
	a.Attribute("attributes", createCommentAttributes)
	a.Required("type", "attributes")
})

var commentAttributes = a.Type("CommentAttributes", func() {
Example #4
0
package design

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

var iteration = a.Type("Iteration", func() {
	a.Description(`JSONAPI store for the data of a iteration.  See also http://jsonapi.org/format/#document-resource-object`)
	a.Attribute("type", d.String, func() {
		a.Enum("iterations")
	})
	a.Attribute("id", d.UUID, "ID of iteration", func() {
		a.Example("40bbdd3d-8b5d-4fd6-ac90-7236b669af04")
	})
	a.Attribute("attributes", iterationAttributes)
	a.Attribute("relationships", iterationRelationships)
	a.Attribute("links", genericLinks)
	a.Required("type", "attributes")
})

var iterationAttributes = a.Type("IterationAttributes", func() {
	a.Description(`JSONAPI store for all the "attributes" of a iteration. +See also see http://jsonapi.org/format/#document-resource-object-attributes`)
	a.Attribute("name", d.String, "The iteration name", func() {
		a.Example("Sprint #24")
	})
	a.Attribute("description", d.String, "Description of the iteration ", func() {
		a.Example("Sprint #42 focusing on UI and build process improvements")
	})
	a.Attribute("startAt", d.DateTime, "When the iteration starts", func() {
		a.Example("2016-11-29T23:18:14Z")
Example #5
0
package design

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

var area = a.Type("Area", func() {
	a.Description(`JSONAPI store for the data of a Area.  See also http://jsonapi.org/format/#document-resource-object`)
	a.Attribute("type", d.String, func() {
		a.Enum("areas")
	})
	a.Attribute("id", d.UUID, "ID of area", func() {
		a.Example("40bbdd3d-8b5d-4fd6-ac90-7236b669af04")
	})
	a.Attribute("attributes", areaAttributes)
	a.Attribute("relationships", areaRelationships)
	a.Attribute("links", genericLinks)
	a.Required("type", "attributes")
})

var areaAttributes = a.Type("AreaAttributes", func() {
	a.Description(`JSONAPI store for all the "attributes" of a Area. +See also see http://jsonapi.org/format/#document-resource-object-attributes`)
	a.Attribute("name", d.String, "The Area name", func() {
		a.Example("Area for Build related stuff")
	})
	a.Attribute("created-at", d.DateTime, "When the area was created", func() {
		a.Example("2016-11-29T23:18:14Z")
	})
	a.Attribute("version", d.Integer, "Version for optimistic concurrency control (optional during creating)", func() {
		a.Example(23)
Example #6
0
package design

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

var space = a.Type("Space", func() {
	a.Attribute("type", d.String, "The type of the related resource", func() {
		a.Enum("spaces")
	})
	a.Attribute("id", d.UUID, "ID of the space", func() {
		a.Example("40bbdd3d-8b5d-4fd6-ac90-7236b669af04")
	})
	a.Attribute("attributes", spaceAttributes)
	a.Attribute("links", genericLinks)
	a.Required("type", "attributes")
	a.Attribute("relationships", spaceRelationships)
})

var spaceRelationships = a.Type("SpaceRelationships", func() {
	a.Attribute("iterations", relationGeneric, "Space can have one or many iterations")
	a.Attribute("areas", relationGeneric, "Space can have one or many areas")
})

var spaceAttributes = a.Type("SpaceAttributes", func() {
	a.Attribute("name", d.String, "Name of the space", func() {
		a.Example("foobar")
	})
	a.Attribute("description", d.String, "Description for the space", func() {
		a.Example("This is the foobar collaboration space")
var workItemLinkTypeListMeta = a.Type("WorkItemLinkTypeListMeta", func() {
	a.Attribute("totalCount", d.Integer, func() {
		a.Minimum(0)
	})
	a.Required("totalCount")
})

// workItemLinkTypeData is the JSONAPI store for the data of a work item link type.
var workItemLinkTypeData = a.Type("WorkItemLinkTypeData", func() {
	a.Description(`JSONAPI store for the data of a work item link type.
See also http://jsonapi.org/format/#document-resource-object`)
	a.Attribute("type", d.String, func() {
		a.Enum("workitemlinktypes")
	})
	a.Attribute("id", d.String, "ID of work item link type (optional during creation)", func() {
		a.Example("40bbdd3d-8b5d-4fd6-ac90-7236b669af04")
	})
	a.Attribute("attributes", workItemLinkTypeAttributes)
	a.Attribute("relationships", workItemLinkTypeRelationships)
	a.Attribute("links", genericLinks)
	a.Required("type", "attributes")
})

// workItemLinkTypeAttributes is the JSONAPI store for all the "attributes" of a work item link type.
var workItemLinkTypeAttributes = a.Type("WorkItemLinkTypeAttributes", func() {
	a.Description(`JSONAPI store for all the "attributes" of a work item link type.
See also see http://jsonapi.org/format/#document-resource-object-attributes`)
	a.Attribute("name", d.String, "Name of the work item link type (required on creation, optional on update)", func() {
		a.Example("tested-by-link-type")
	})
	a.Attribute("description", d.String, "Description of the work item link type (optional)", func() {
Example #8
0
	a.Attribute("self", d.String)
	a.Attribute("related", d.String)
	a.Attribute("sourceLinkTypes", d.String, `URL to those work item link types
in which the current work item can be used in the source part of the link`)
	a.Attribute("targetLinkTypes", d.String, `URL to those work item link types
in which the current work item can be used in the target part of the link`)
	a.Attribute("meta", a.HashOf(d.String, d.Any))
})

// workItem2 defines how an update payload will look like
var workItem2 = a.Type("WorkItem2", func() {
	a.Attribute("type", d.String, func() {
		a.Enum("workitems")
	})
	a.Attribute("id", d.String, "ID of the work item which is being updated", func() {
		a.Example("42")
	})
	a.Attribute("attributes", a.HashOf(d.String, d.Any), func() {
		a.Example(map[string]interface{}{"version": "1", "system.state": "new", "system.title": "Example story"})
	})
	a.Attribute("relationships", workItemRelationships)
	a.Attribute("links", genericLinksForWorkItem)
	a.Required("type", "attributes")
})

// WorkItemRelationships defines only `assignee` as of now. To be updated
var workItemRelationships = a.Type("WorkItemRelationships", func() {
	a.Attribute("assignees", relationGenericList, "This defines assignees of the Work Item")
	a.Attribute("creator", relationGeneric, "This defines creator of the Work Item")
	a.Attribute("baseType", relationBaseType, "This defines type of Work Item")
	a.Attribute("comments", relationGeneric, "This defines comments on the Work Item")
Example #9
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() {
Example #10
0
package design

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

// workItemLinkLinks has `self` as of now according to http://jsonapi.org/format/#fetching-resources
var workItemLinkLinks = a.Type("WorkItemLinkLinks", func() {
	a.Attribute("self", d.String, func() {
		a.Example("http://api.almighty.io/api/workitemlinks/2d98c73d-6969-4ea6-958a-812c832b6c18")
	})
	a.Required("self")
})

// createWorkItemLinkPayload defines the structure of work item link payload in JSONAPI format during creation
var createWorkItemLinkPayload = a.Type("CreateWorkItemLinkPayload", func() {
	a.Attribute("data", workItemLinkData)
	a.Required("data")
})

// updateWorkItemLinkPayload defines the structure of work item link payload in JSONAPI format during update
var updateWorkItemLinkPayload = a.Type("UpdateWorkItemLinkPayload", func() {
	a.Attribute("data", workItemLinkData)
	a.Required("data")
})

// workItemLinkListMeta holds meta information for a work item link array response
var workItemLinkListMeta = a.Type("WorkItemLinkListMeta", func() {
	a.Attribute("totalCount", d.Integer, func() {
		a.Minimum(0)
Example #11
0
	d "github.com/goadesign/goa/design"
	a "github.com/goadesign/goa/design/apidsl"
)

//#############################################################################
//
// 			JSONAPI common
//
//#############################################################################

// JSONAPILink represents a JSONAPI link object (see http://jsonapi.org/format/#document-links)
var JSONAPILink = a.Type("JSONAPILink", func() {
	a.Description(`See also http://jsonapi.org/format/#document-links.`)
	a.Attribute("href", d.String, "a string containing the link's URL.", func() {
		a.Example("http://example.com/articles/1/comments")
	})
	a.Attribute("meta", a.HashOf(d.String, d.Any), "a meta object containing non-standard meta-information about the link.")
})

// JSONAPIError represents a JSONAPI error object (see http://jsonapi.org/format/#error-objects)
var JSONAPIError = a.Type("JSONAPIError", func() {
	a.Description(`Error objects provide additional information about problems encountered while
performing an operation. Error objects MUST be returned as an array keyed by errors in the
top level of a JSON API document.

See. also http://jsonapi.org/format/#error-objects.`)

	a.Attribute("id", d.String, "a unique identifier for this particular occurrence of the problem.")
	a.Attribute("links", a.HashOf(d.String, JSONAPILink), `a links object containing the following members:
* about: a link that leads to further details about this particular occurrence of the problem.`)
Example #12
0
})

// MarkupRenderingPayloadData is the media type representing a rendering input.
var markupRenderingPayloadData = a.Type("MarkupRenderingPayloadData", func() {
	a.Attribute("type", d.String, func() {
		a.Enum("rendering")
	})
	a.Attribute("attributes", markupRenderingPayloadDataAttributes)
	a.Required("type")
	a.Required("attributes")
})

// MarkupRenderingPayloadData is the media type representing a rendering input.
var markupRenderingPayloadDataAttributes = a.Type("MarkupRenderingPayloadDataAttributes", func() {
	a.Attribute("content", d.String, "The content to render", func() {
		a.Example("# foo")
	})
	a.Attribute("markup", d.String, "The markup language associated with the content to render", func() {
		a.Example("Markdown")
	})
	a.Required("content")
	a.Required("markup")
})

// MarkupRenderingMediaType is the media type for rendering result
var markupRenderingMediaType = JSONSingle(
	"MarkupRendering",
	`MarkupRenderingMediaType contains the  
		rendering of the 'content' provided in the request, using
		the markup language specified by the 'markup' value.`,
	markupRenderingMediaTypeData,