Пример #1
0
// JSONList creates a UserTypeDefinition
func JSONList(name, description string, data *d.UserTypeDefinition, links *d.UserTypeDefinition, meta *d.UserTypeDefinition) *d.MediaTypeDefinition {
	return a.MediaType("application/vnd."+strings.ToLower(name)+"list+json", func() {
		a.UseTrait("jsonapi-media-type")
		a.TypeName(name + "List")
		a.Description(description)
		if links != nil {
			a.Attribute("links", links)
		}
		if meta != nil {
			a.Attribute("meta", meta)
		}
		a.Attribute("data", a.ArrayOf(data))
		a.Attribute("included", a.ArrayOf(d.Any), "An array of mixed types")
		a.Required("data")

		a.View("default", func() {
			if links != nil {
				a.Attribute("links")
			}
			if meta != nil {
				a.Attribute("meta")
			}
			a.Attribute("data")
			a.Attribute("included")
			a.Required("data")
		})
	})

}
Пример #2
0
// JSONSingle creates a Single
func JSONSingle(name, description string, data *d.UserTypeDefinition, links *d.UserTypeDefinition) *d.MediaTypeDefinition {
	// WorkItemSingle is the media type for work items
	return a.MediaType("application/vnd."+strings.ToLower(name)+"+json", func() {
		a.UseTrait("jsonapi-media-type")
		a.TypeName(name + "Single")
		a.Description(description)
		if links != nil {
			a.Attribute("links", links)
		}
		a.Attribute("data", data)
		a.Attribute("included", a.ArrayOf(d.Any), "An array of mixed types")
		a.Required("data")
		a.View("default", func() {
			if links != nil {
				a.Attribute("links")
			}
			a.Attribute("data")
			a.Attribute("included")
			a.Required("data")
		})
	})
}
Пример #3
0
	d "github.com/goadesign/goa/design"
	a "github.com/goadesign/goa/design/apidsl"
)

// identity represents an identified user object
var identity = a.MediaType("application/vnd.identity+json", func() {
	a.UseTrait("jsonapi-media-type")
	a.TypeName("Identity")
	a.Description("ALM User Identity")
	a.Attributes(func() {
		a.Attribute("data", identityData)
		a.Required("data")

	})
	a.View("default", func() {
		a.Attribute("data")
		a.Required("data")
	})
})

// identityArray represents an array of identified user objects
var identityArray = a.MediaType("application/vnd.identity-array+json", func() {
	a.UseTrait("jsonapi-media-type")
	a.TypeName("IdentityArray")
	a.Description("ALM User Identity Array")
	a.Attributes(func() {
		a.Attribute("data", a.ArrayOf(identityData))
		a.Required("data")

	})
	a.View("default", func() {
		a.Attribute("data")
Пример #4
0
		a.Response(d.BadRequest, JSONAPIErrors)
		a.Response(d.InternalServerError, JSONAPIErrors)
	})
})

var refreshToken = a.Type("RefreshToken", func() {
	a.Attribute("refresh_token", d.String, "Refresh token")
})

// AuthToken represents an authentication JWT Token
var AuthToken = a.MediaType("application/vnd.authtoken+json", func() {
	a.TypeName("AuthToken")
	a.Description("JWT Token")
	a.Attributes(func() {
		a.Attribute("token", tokenData)
		a.Required("token")
	})
	a.View("default", func() {
		a.Attribute("token")
	})
})

var tokenData = a.Type("TokenData", func() {
	a.Attribute("access_token", d.String, "Access token")
	a.Attribute("expires_in", d.Integer, "Access token expires in seconds")
	a.Attribute("refresh_expires_in", d.Integer, "Refresh token expires in seconds")
	a.Attribute("refresh_token", d.String, "Refresh token")
	a.Attribute("token_type", d.String, "Token type")
	a.Attribute("not-before-policy", d.Integer, "Token is not valid if issued before this date")
})
Пример #5
0
	a "github.com/goadesign/goa/design/apidsl"
)

// ALMStatus defines the status of the current running ALM instance
var ALMStatus = a.MediaType("application/vnd.status+json", func() {
	a.Description("The status of the current running instance")
	a.Attributes(func() {
		a.Attribute("commit", d.String, "Commit SHA this build is based on")
		a.Attribute("buildTime", d.String, "The time when built")
		a.Attribute("startTime", d.String, "The time when started")
		a.Attribute("error", d.String, "The error if any")
		a.Required("commit", "buildTime", "startTime")
	})
	a.View("default", func() {
		a.Attribute("commit")
		a.Attribute("buildTime")
		a.Attribute("startTime")
		a.Attribute("error")
	})
})

// workItem is the media type for work items
// Deprecated, but kept around as internal model for now.
var workItem = a.MediaType("application/vnd.workitem+json", func() {
	a.TypeName("WorkItem")
	a.Description("A work item hold field values according to a given field type")
	a.Attribute("id", d.String, "unique id per installation")
	a.Attribute("version", d.Integer, "Version for optimistic concurrency control")
	a.Attribute("type", d.String, "Name of the type of this work item")
	a.Attribute("fields", a.HashOf(d.String, d.Any), "The field values, according to the field type")

	a.Required("id")
Пример #6
0
	a.Attribute("meta", a.HashOf(d.String, d.Any), "a meta object containing non-standard meta-information about the error")

	a.Required("detail")
})

// JSONAPIErrors is an array of JSONAPI error objects
var JSONAPIErrors = a.MediaType("application/vnd.jsonapierrors+json", func() {
	a.UseTrait("jsonapi-media-type")
	a.TypeName("JSONAPIErrors")
	a.Description(``)
	a.Attributes(func() {
		a.Attribute("errors", a.ArrayOf(JSONAPIError))
		a.Required("errors")
	})
	a.View("default", func() {
		a.Attribute("errors")
		a.Required("errors")
	})
})

// relationGeneric is a top level structure for 'other' relationships
var relationGeneric = a.Type("RelationGeneric", func() {
	a.Attribute("data", genericData)
	a.Attribute("links", genericLinks)
	a.Attribute("meta", a.HashOf(d.String, d.Any))
})

// relationGeneric is a top level structure for 'other' relationships
var relationGenericList = a.Type("RelationGenericList", func() {
	a.Attribute("data", a.ArrayOf(genericData))
	a.Attribute("links", genericLinks)
	a.Attribute("meta", a.HashOf(d.String, d.Any))