This article compares Goa v1 and v3 design DSL.
| v1 | v3 |
|---|---|
API |
API |
APIKeySecurity |
APIKeySecurity( APIKey)( APIKeyField) |
AccessCodeFlow |
- |
Action |
Method |
ApplicationFlow |
- |
ArrayOf |
ArrayOf |
Attribute |
Attribute |
Attributes |
Attributes |
BasePath |
Path |
BasicAuthSecurity |
BasicAuthSecurity( Password)( PasswordField)( Username)( UsernameField) |
CONNECT |
CONNECT |
CanonicalActionName |
CanonicalMethod |
CollectionOf |
CollectionOf |
Consumes |
Consumes |
Contact |
Contact |
ContentType |
ContentType |
Credentials |
- |
DELETE |
DELETE |
Default |
Default |
DefaultMedia |
- |
Description |
Description |
Docs |
Docs |
Email |
Email |
Enum |
Enum |
Example |
Example( Value) |
Expose |
- |
Files |
Files |
Format |
Format |
Function |
- |
GET |
GET |
HEAD |
HEAD |
HashOf |
MapOf |
Header |
Header |
Headers |
Headers |
Host |
HostServerURIVariable
|
ImplicitFlow |
ImplicitFlow |
JWTSecurity |
JWTSecurity( Token)( TokenField) |
License |
License |
Link |
- |
Links |
- |
MaxAge |
- |
MaxLength |
MaxLength |
Maximum |
Maximum |
Media |
Result |
MediaType |
ResultType |
Member |
- |
Metadata |
Meta |
Methods |
- |
MinLength |
MinLength |
Minimum |
Minimum |
MultipartForm |
MultipartRequest |
Name |
Name |
NoExample |
- |
NoSecurity |
NoSecurity |
OAuth2Security |
OAuth2Security( AccessToken)( AccessTokenField) |
OPTIONS |
OPTIONS |
OptionalPayload |
- |
Origin |
- |
PATCH |
PATCH |
POST |
POST |
PUT |
PUT |
Package |
- |
Param |
Param |
Params |
Params |
Parent |
Parent |
PasswordFlow |
PasswordFlow |
Pattern |
Pattern |
Payload |
Payload |
Produces |
Produces |
Query |
- |
ReadOnly |
- |
Reference |
Reference |
Required |
Required |
Resource |
Service |
Response |
Response |
ResponseTemplate |
- |
Routing |
- |
Scheme |
- |
Scope |
Scope |
Security |
Security |
Status |
Code |
TRACE |
TRACE |
TermsOfService |
TermsOfService |
Title |
Title |
TokenURL |
- |
Trait |
- |
Type |
Type |
TypeName |
TypeName |
URL |
URL |
UseTrait |
- |
Version |
Version |
View |
View |
| - | AuthorizationCodeFlow |
| - | Body |
| - | ClientCredentialsFlow |
| - | ConvertTo |
| - | CreateFrom |
| - | Elem |
| - | Error |
| - | Extend |
| - | Fault |
| - | Field |
| - | GRPC |
| - | HTTP |
| - | Key |
| - | MapParams |
| - | Message |
| - | Metadata |
| - | Services |
| - | StreamingPayload |
| - | StreamingResult |
| - | Tag |
| - | Temporary |
| - | Timeout |
| - | Trailers |
BasePath
- Replaced with
Path. - Describe in
HTTP.
// v1
BasePath("/users")
// v3
HTTP(func() {
Path("/users")
})
Consumes, Produces
- Describe in
HTTP. -
FunctionandPackageare obsolete.
// v1
Consumes("application/xml")
Consumes("application/json")
Produces("application/xml")
Produces("application/json")
// v3
HTTP(func() {
Consumes("application/xml")
Consumes("application/json")
Produces("application/xml")
Produces("application/json")
})
Format
- The argument type is
stringin v1. v3 usesexpr.ValidationFormatinstead. -
expr.ValidationFormats are defined ingoa.design/goa/exprasconst.
GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH
- The path parameters are described using colon (
:) in v1. v3 uses curly braces ({,}) instead.
// v1
GET("/users/:id")
// v3
GET("/users/{id}")
HashOf
- Replaced with
MapOf. - Describe an optional DSL for the key using
Key. - Describe an optional DSL for the value using
Elem.
// v1
HashOf(String, Integer,
func() {
MinLength(1)
MaxLength(16)
},
func() {
Minimum(1)
Maximum(5)
},
)
// v3
MapOf(String, Int, func() {
Key(func() {
MinLength(1)
MaxLength(16)
})
Elem(func () {
Minimum(1)
Maximum(5)
})
})
Headers
Request headers
- Describe
AttributeinPayload,HeadersinHTTP.
// v1
Action("show", func() {
Headers(func() {
Header("Authorization", String)
})
})
// v3
Method("show", func() {
Payload(func() {
Attribute("Authorization", String)
})
HTTP(func() {
Headers(func() {
Header("Authorization", String)
})
})
})
Host, Scheme
-
HostandScheme(andBasePath) are used in v1. v3 usesServer,HostandURIinstead.
// v1
Host("localhost:8080")
Scheme("http")
BasePath("/cellar")
// v3
Server("app", func() {
Host("development", func() {
URI("http://localhost:8080/cellar")
})
})
NoExample
- Obsolete.
-
Metacan be used as an alternative.
Meta("swagger:example", "false")
Params
Path parameters
- Describe
AttributeinPayload,ParamsinHTTP. -
Paramscan be omitted. It is implicitly defined.
// v1
Action("show", func() {
Params(func() {
Param("id", Integer)
})
})
// v3
Method("show", func() {
Payload(func() {
Attribute("id", Int)
})
HTTP(func() {
Params(func() { // Can be omitted
Param("id", Int) //
}) //
})
})
Query parameters
- Describe
AttributeinPayload,ParamsinHTTP. -
Paramscannot be ommited.
//v1
Action("list", func() {
Params(func() {
Param("name", String)
})
})
// v3
Method("list", func() {
Payload(func() {
Attribute("name", String)
})
HTTP(func() {
Params(func() { // Cannot be omitted
Param("name", String) //
}) //
})
})
Routing
- Obsolete.
- Describe DSLs which have same name as HTTP request methods in
HTTP.
// v1
Action("show", func() {
Routing(
GET("/:id"),
)
})
// v3
Method("show", func() {
HTTP(func() {
GET("/{id}")
})
})
Top comments (0)