Created
July 2, 2019 09:32
-
-
Save johnmanjiro13/91ced09ba87ee7a21739d21d216d9be7 to your computer and use it in GitHub Desktop.
An example design for goa v3 does not generate Validation function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package design | |
import . "goa.design/goa/v3/dsl" | |
var _ = API("api", func() { | |
Title("sample api") | |
Server("api", func() { | |
Host("localhost", func() { URI("http://localhost:8088") }) | |
}) | |
}) | |
var _ = Service("calc", func() { | |
Description("The calc service performs operations on numbers") | |
Method("add", func() { | |
Payload(func() { | |
Attribute("a", Int, "Left operand") | |
Attribute("b", Int, "Right operand") | |
Required("a", "b") | |
}) | |
Result(MainType) | |
HTTP(func() { | |
GET("/add/{a}/{b}") | |
Response(StatusOK) | |
}) | |
}) | |
}) | |
var MainType = ResultType("vnd.application/main+json", func() { | |
ContentType("application/json") | |
Attributes(func() { | |
Attribute("version", String, "API version") | |
Attribute("SubType", SubType, "sub type") | |
Required("version") | |
}) | |
View("default", func() { | |
Attribute("version") | |
Attribute("SubType") | |
}) | |
}) | |
var SubType = Type("DSubTypeata", func() { | |
Attribute("ID", String) | |
Attribute("ThirdTypes", ThirdTypes) | |
Required("ID") | |
}) | |
var ThirdTypes = Type("ThirdTypes", func() { | |
Attribute("ThirdType", ArrayOf(ThirdType)) | |
}) | |
var ThirdType = Type("ThirdType", func() { | |
Attribute("Image", Image) | |
}) | |
var Image = Type("Image", func() { | |
Attribute("Width", Int, "width") | |
Attribute("Height", Int, "height") | |
Attribute("URL", String) | |
Required("Width") | |
Required("Height") | |
Required("URL") | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment