}) a.Response(d.BadRequest, JSONAPIErrors) a.Response(d.InternalServerError, JSONAPIErrors) a.Response(d.Unauthorized, JSONAPIErrors) }) a.Action("list", func() { a.Routing( a.GET(""), ) a.Description("List work item types.") a.Params(func() { a.Param("page", d.String, "Paging in the format <start>,<limit>") }) a.Response(d.OK, func() { a.Media(a.CollectionOf(workItemType)) }) a.Response(d.BadRequest, JSONAPIErrors) a.Response(d.InternalServerError, JSONAPIErrors) }) a.Action("list-source-link-types", func() { a.Routing( a.GET("/:name/source-link-types"), ) a.Params(func() { a.Param("name", d.String, "name") }) a.Description(`Retrieve work item link types where the given work item type can be used in the source of the link.`) a.Response(d.OK, func() {
a.Action("authorize", func() { a.Routing( a.GET("authorize"), ) a.Description("Authorize with the ALM") a.Response(d.Unauthorized, JSONAPIErrors) a.Response(d.TemporaryRedirect) }) a.Action("generate", func() { a.Routing( a.GET("generate"), ) a.Description("Generates a set of Tokens for different Auth levels. NOT FOR PRODUCTION. Only available if server is running in dev mode") a.Response(d.OK, func() { a.Media(a.CollectionOf(AuthToken)) }) a.Response(d.Unauthorized, JSONAPIErrors) a.Response(d.InternalServerError, JSONAPIErrors) }) a.Action("refresh", func() { a.Routing( a.POST("refresh"), ) a.Payload(refreshToken) a.Description("Refreshes access token") a.Response(d.OK, func() { a.Media(AuthToken) }) a.Response(d.Unauthorized, JSONAPIErrors)
}, }, Identifier: "application/vnd.goa.test", } defView := &design.ViewDefinition{ AttributeDefinition: elemType.AttributeDefinition, Name: "default", Parent: elemType, } elemType.Views = map[string]*design.ViewDefinition{"default": defView} design.Design = new(design.APIDefinition) design.Design.MediaTypes = map[string]*design.MediaTypeDefinition{ design.CanonicalIdentifier(elemType.Identifier): elemType, } design.ProjectedMediaTypes = make(map[string]*design.MediaTypeDefinition) mediaType := apidsl.CollectionOf(elemType) dslengine.Execute(mediaType.DSL(), mediaType) responses = map[string]*design.ResponseDefinition{"OK": { Name: "OK", Status: 200, Type: mediaType, }} }) It("the generated code sets the response to an empty collection if value is nil", func() { err := writer.Execute(data) Ω(err).ShouldNot(HaveOccurred()) b, err := ioutil.ReadFile(filename) Ω(err).ShouldNot(HaveOccurred()) written := string(b) Ω(written).ShouldNot(BeEmpty())