Skip to content

Commit

Permalink
go fmt ./... (#3507)
Browse files Browse the repository at this point in the history
  • Loading branch information
tchssk committed Apr 15, 2024
1 parent 13b11e0 commit 6804258
Show file tree
Hide file tree
Showing 35 changed files with 1,232 additions and 1,310 deletions.
16 changes: 8 additions & 8 deletions codegen/generator/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
Package generator contains the code generation algorithms for a service server,
client, and OpenAPI specification.
Server and Client
# Server and Client
The code generated for the service server and client includes:
- A `service` package that contains the declarations for the service
interfaces and endpoints which wrap the service methods.
- A `views` package that contains code to render a result type using a view.
- transport specific packages for each of the transports defined in the
design.
- An example implementation of the client, server, and the service.
- A `service` package that contains the declarations for the service
interfaces and endpoints which wrap the service methods.
- A `views` package that contains code to render a result type using a view.
- transport specific packages for each of the transports defined in the
design.
- An example implementation of the client, server, and the service.
OpenAPI
# OpenAPI
The OpenAPI generator generates a OpenAPI v2 specification for the service
REST endpoints. This generator requires the design to define the HTTP transport.
Expand Down
156 changes: 73 additions & 83 deletions dsl/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,31 @@ import (
//
// Example:
//
// var _ = API("adder", func() {
// Title("title") // Title used in documentation
// Description("description") // Description used in documentation
// Version("2.0") // Version of API
// TermsOfService("terms") // Terms of use
// Contact(func() { // Contact info
// Name("contact name")
// Email("contact email")
// URL("contact URL")
// })
// License(func() { // License
// Name("license name")
// URL("license URL")
// })
// Docs(func() { // Documentation links
// Description("doc description")
// URL("doc URL")
// })
// Server("addersvr", func() {
// Host("development", func() {
// URI("http://localhost:80")
// URI("grpc://localhost:8080")
// })
// })
// }
//
// var _ = API("adder", func() {
// Title("title") // Title used in documentation
// Description("description") // Description used in documentation
// Version("2.0") // Version of API
// TermsOfService("terms") // Terms of use
// Contact(func() { // Contact info
// Name("contact name")
// Email("contact email")
// URL("contact URL")
// })
// License(func() { // License
// Name("license name")
// URL("license URL")
// })
// Docs(func() { // Documentation links
// Description("doc description")
// URL("doc URL")
// })
// Server("addersvr", func() {
// Host("development", func() {
// URI("http://localhost:80")
// URI("grpc://localhost:8080")
// })
// })
// }
func API(name string, fn func()) *expr.APIExpr {
if name == "" {
eval.ReportError("API first argument cannot be empty")
Expand All @@ -63,10 +62,9 @@ func API(name string, fn func()) *expr.APIExpr {
//
// Example:
//
// var _ = API("divider", func() {
// Title("divider API")
// })
//
// var _ = API("divider", func() {
// Title("divider API")
// })
func Title(val string) {
if s, ok := eval.Current().(*expr.APIExpr); ok {
s.Title = val
Expand All @@ -83,10 +81,9 @@ func Title(val string) {
//
// Example:
//
// var _ = API("divider", func() {
// Version("1.0")
// })
//
// var _ = API("divider", func() {
// Version("1.0")
// })
func Version(ver string) {
if s, ok := eval.Current().(*expr.APIExpr); ok {
s.Version = ver
Expand All @@ -103,14 +100,13 @@ func Version(ver string) {
//
// Example:
//
// var _ = API("divider", func() {
// Contact(func() {
// Name("support")
// Email("support@goa.design")
// URL("https://goa.design")
// })
// })
//
// var _ = API("divider", func() {
// Contact(func() {
// Name("support")
// Email("support@goa.design")
// URL("https://goa.design")
// })
// })
func Contact(fn func()) {
contact := new(expr.ContactExpr)
if !eval.Execute(fn, contact) {
Expand All @@ -131,13 +127,12 @@ func Contact(fn func()) {
//
// Example:
//
// var _ = API("divider", func() {
// License(func() {
// Name("MIT")
// URL("https://github.com/goadesign/goa/blob/master/LICENSE")
// })
// })
//
// var _ = API("divider", func() {
// License(func() {
// Name("MIT")
// URL("https://github.com/goadesign/goa/blob/master/LICENSE")
// })
// })
func License(fn func()) {
license := new(expr.LicenseExpr)
if !eval.Execute(fn, license) {
Expand All @@ -162,18 +157,18 @@ func License(fn func()) {
//
// Example:
//
// var _ = API("divider", func() {
// Randomizer(expr.NewFakerRandomizer("different seed"))
// })
// var _ = API("divider", func() {
// Randomizer(expr.NewFakerRandomizer("different seed"))
// })
//
// There's also a deterministic randomizer which will only generate one example
// for each type, so all strings are "abc123", all ints are 1, etc.
//
// Example:
//
// var _ = API("divider", func() {
// Randomizer(expr.NewDeterministicRandomizer())
// })
// var _ = API("divider", func() {
// Randomizer(expr.NewDeterministicRandomizer())
// })
func Randomizer(randomizer expr.Randomizer) {
if s, ok := eval.Current().(*expr.APIExpr); ok {
s.ExampleGenerator = &expr.ExampleGenerator{Randomizer: randomizer}
Expand All @@ -191,13 +186,12 @@ func Randomizer(randomizer expr.Randomizer) {
//
// Example:
//
// var _ = API("cellar", func() {
// Docs(func() {
// Description("Additional documentation")
// URL("https://goa.design")
// })
// })
//
// var _ = API("cellar", func() {
// Docs(func() {
// Description("Additional documentation")
// URL("https://goa.design")
// })
// })
func Docs(fn func()) {
docs := new(expr.DocsExpr)
if !eval.Execute(fn, docs) {
Expand Down Expand Up @@ -227,10 +221,9 @@ func Docs(fn func()) {
//
// Example:
//
// var _ = API("github", func() {
// TermsOfService("https://help.github.com/articles/github-terms-of-API/"
// })
//
// var _ = API("github", func() {
// TermsOfService("https://help.github.com/articles/github-terms-of-API/"
// })
func TermsOfService(terms string) {
if s, ok := eval.Current().(*expr.APIExpr); ok {
s.TermsOfService = terms
Expand All @@ -247,13 +240,12 @@ func TermsOfService(terms string) {
//
// Example:
//
// var _ = API("divider", func() {
// License(func() {
// Name("MIT")
// URL("https://github.com/goadesign/goa/blob/master/LICENSE")
// })
// })
//
// var _ = API("divider", func() {
// License(func() {
// Name("MIT")
// URL("https://github.com/goadesign/goa/blob/master/LICENSE")
// })
// })
func Name(name string) {
switch def := eval.Current().(type) {
case *expr.ContactExpr:
Expand All @@ -273,12 +265,11 @@ func Name(name string) {
//
// Example:
//
// var _ = API("divider", func() {
// Contact(func() {
// Email("support@goa.design")
// })
// })
//
// var _ = API("divider", func() {
// Contact(func() {
// Email("support@goa.design")
// })
// })
func Email(email string) {
if c, ok := eval.Current().(*expr.ContactExpr); ok {
c.Email = email
Expand All @@ -293,10 +284,9 @@ func Email(email string) {
//
// Example:
//
// Docs(func() {
// URL("https://goa.design")
// })
//
// Docs(func() {
// URL("https://goa.design")
// })
func URL(url string) {
switch def := eval.Current().(type) {
case *expr.ContactExpr:
Expand Down

0 comments on commit 6804258

Please sign in to comment.