Git Product home page Git Product logo

examples's People

Contributors

akm avatar aslakknutsen avatar baccenfutter avatar bketelsen avatar brycereitano avatar dependabot[bot] avatar dobegor avatar dvictor avatar eric-isakson avatar ghoben avatar hnakamur avatar ikawaha avatar johnroesler avatar neenuavarghese avatar nitinmohan87 avatar nooproblem avatar raphael avatar skritchz avatar smessier avatar tchssk avatar tleyden avatar wukuan405 avatar yoshida-mediba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

multiple-value uuid.NewV4() in single-value context

Hi Please check some revisions I made.
examples/security/jwt.go
correct

token.Claims = jwtgo.MapClaims{
		"iss":    "Issuer",              // who creates the token and signs it
		"aud":    "Audience",            // to whom the token is intended to be sent
		"exp":    in10m,                 // time when the token will expire (10 minutes from now)
		"jti":    uuid.NewV4().String(), // a unique identifier for the token
		"iat":    time.Now().Unix(),     // when the token was issued/created (now)
		"nbf":    2,                     // time before which the token is not yet valid (2 minutes ago)
		"sub":    "subject",             // the subject/principal is whom the token is about
		"scopes": "api:access",          // token scope - not a standard claim
	}

to

u, err := uuid.NewV4()
token.Claims = jwtgo.MapClaims{
		"iss":    "Issuer",          // who creates the token and signs it
		"aud":    "Audience",        // to whom the token is intended to be sent
		"exp":    in10m,             // time when the token will expire (10 minutes from now)
		"jti":    u.String(),        // a unique identifier for the token
		"iat":    time.Now().Unix(), // when the token was issued/created (now)
		"nbf":    2,                 // time before which the token is not yet valid (2 minutes ago)
		"sub":    "subject",         // the subject/principal is whom the token is about
		"scopes": "api:access",      // token scope - not a standard claim
	}

./image.go:70: cannot use app.ImageMedia literal (type *app.ImageMedia) as type app.ImageMediaCollection in argument to ctx.OK

Hi,

Using goadesign/examples/gopherjs.

After go generate and then go build, the error ./image.go:70: cannot use app.ImageMedia literal (type *app.ImageMedia) as type app.ImageMediaCollection in argument to ctx.OK is generated. I am using the most recent committed version of goadesign/examples. I don't know enough about goa design components and code generation yet to be able to debug this easily, but I would be interested to know what the resolution might be!

Swagger/openapi endpoints do not work

Hello and thank you for the efforts to create and develop goa.

Unfortunately in the latest release it seems that the openapi/swagger stuff doesn't work anymore.

If you run any of the examples here and navigate to the HTTP address where the swagger/openapi JSON files should be exposed, you'll see that nothing is exposed there.

Note to streaming examples

Thanks for making those good examples to see how something is working. I tried to work with the streaming example chatter/chatter-cli and I was wondering in the beginning, why the client app did not work as described in the Readme. It took me some time to find the correct branch which had the chatter-cli implemented the functionality which is described.

In order for new people it would be easier if the master version of "chatter-cli.go" has the code of the branch: "testing_poc" included to have a working example out of the box.

I would be happy to prepare the changes to outsource the working on the stream into a new file in the package main which shows how to deal with the streams, if that's ok?

security/auth.go is not generated by 3.0.8 later

cd path/to/examples/security
rm auth.go
goa example goa.design/examples/security/design

I expect auth.go is generated but it was not.
I changed goa.design/goa/v3 v3.0.9 to goa.design/goa/v3 v3.0.7 in go.mod and try the previous steps again, auth.go is generated.

security/auth.go is out of date with goa v3

Noticed this while trying to reproduce an example to look at goadesign/goa#2116

The security example builds but has a runtime panic.

$ cd security/
$ GO111MODULE=on go build ./cmd/multi_auth
$ ./multi_auth
panic: interface conversion: *multiauth.securedServiceSvc is not securedservice.Auther: missing method APIKeyAuth

goroutine 1 [running]:
goa.design/examples/security/gen/secured_service.NewEndpoints(0xa80200, 0xc0000ac568, 0x0)
/home/eric/go/src/goa.design/examples/security/gen/secured_service/endpoints.go:30 +0x59
main.main()
/home/eric/go/src/goa.design/examples/security/cmd/multi_auth/main.go:53 +0x32a

No time to fix it tonight, I'll find a few minutes to create a PR tomorrow.

Build failure due to new version of staticcheck

Staticcheck added ST1021 which confirms the first word in a type comment matches the name of the type. This check should be disabled until the goa code generation templates are updated to conform with this validation.

dominikh/go-tools@2c70f90

Current lint target fails with:

make lint
LINTING CODE...
basic/gen/calc/service.go:15:1: comment on exported type Service should be of the form "Service ..." (with optional leading article) (ST1021)
cellar/gen/sommelier/service.go:17:1: comment on exported type Service should be of the form "Service ..." (with optional leading article) (ST1021)
cellar/gen/sommelier/service.go:83:1: comment on exported type NoCriteria should be of the form "NoCriteria ..." (with optional leading article) (ST1021)
cellar/gen/sommelier/service.go:86:1: comment on exported type NoMatch should be of the form "NoMatch ..." (with optional leading article) (ST1021)
cellar/gen/storage/service.go:17:1: comment on exported type Service should be of the form "Service ..." (with optional leading article) (ST1021)
...

Adder example panic

Following the README for the adder example to the letter does not produce the same result:

jeroen@develop ~/dev/src/local/goatest % go get github.com/goadesign/examples/adder
jeroen@develop ~/dev/src/local/goatest % cd ~/dev/src/github.com/goadesign/examples/adder
jeroen@develop ..rc/github.com/goadesign/examples/adder (git)-[master] % go generate
app
app/contexts.go
app/controllers.go
app/hrefs.go
app/media_types.go
app/user_types.go
main.go
operands.go
test
test/operands.go
client
client/adder-cli
client/adder-cli/main.go
client/adder-cli/commands.go
client/client.go
client/operands.go
client/hrefs.go
swagger
swagger/swagger.json
swagger/swagger.yaml
swagger/swagger.go
go generate  10.33s user 0.85s system 138% cpu 8.083 total
jeroen@develop ..rc/github.com/goadesign/examples/adder (git)-[master] % go build
jeroen@develop ..rc/github.com/goadesign/examples/adder (git)-[master] % ./adder&
[1] 21172
2016/04/24 09:55:50 [INFO] mount ctrl=Operands action=Add route=GET /add/:left/:right
2016/04/24 09:55:50 [INFO] mount file name=swagger/swagger.json route=GET /swagger.json
2016/04/24 09:55:50 [INFO] listen transport=http addr=:8080
jeroen@develop ..rc/github.com/goadesign/examples/adder (git)-[master] % curl http://localhost:8080/
2016/04/24 09:56:01 http: panic serving 127.0.0.1:48626: runtime error: index out of range
goroutine 6 [running]:
net/http.(*conn).serve.func1(0xc820010780)
        /usr/lib/go-1.6/src/net/http/server.go:1389 +0xc1
panic(0x840c40, 0xc82000a090)
        /usr/lib/go-1.6/src/runtime/panic.go:426 +0x4e9
github.com/goadesign/goa.(*adapter).logit(0xc8200bbcc0, 0x8cfea8, 0x7, 0xc820010880, 0x8, 0x8, 0x7fbc4216e700)
        /home/jeroen/dev/src/github.com/goadesign/goa/logging.go:95 +0x8af
github.com/goadesign/goa.(*adapter).Info(0xc8200bbcc0, 0x8cfea8, 0x7, 0xc820010880, 0x8, 0x8)
        /home/jeroen/dev/src/github.com/goadesign/goa/logging.go:50 +0x58
github.com/goadesign/goa.LogInfo(0x7fbc4216e798, 0xc82014a3f0, 0x8cfea8, 0x7, 0xc820010880, 0x8, 0x8)
        /home/jeroen/dev/src/github.com/goadesign/goa/logging.go:107 +0x126
github.com/goadesign/goa/middleware.LogRequest.func1.1(0x7fbc4216e798, 0xc82014a3f0, 0x7fbc4216fd40, 0xc8200e6c30, 0xc82014e000, 0x0, 0x0)
        /home/jeroen/dev/src/github.com/goadesign/goa/middleware/log_request.go:33 +0x777
github.com/goadesign/goa/middleware.RequestID.func1.1(0x7fbc4216e798, 0xc82014a3c0, 0x7fbc4216fd40, 0xc8200e6c30, 0xc82014e000, 0x0, 0x0)
        /home/jeroen/dev/src/github.com/goadesign/goa/middleware/request_id.go:50 +0x40f
github.com/goadesign/goa.New.func2(0x7fbc4216fd40, 0xc8200e6c30, 0xc82014e000, 0x0)
        /home/jeroen/dev/src/github.com/goadesign/goa/service.go:97 +0x539
github.com/goadesign/goa.(*mux).HandleNotFound.func1(0x7fbc4216fd40, 0xc8200e6c30, 0xc82014e000)
        /home/jeroen/dev/src/github.com/goadesign/goa/mux.go:67 +0x42
github.com/dimfeld/httptreemux.(*TreeMux).ServeHTTP(0xc8200602a0, 0x7fbc4216fd40, 0xc8200e6c30, 0xc82014e000)
        /home/jeroen/dev/src/github.com/dimfeld/httptreemux/router.go:190 +0x2d1
github.com/goadesign/goa.(*mux).ServeHTTP(0xc82000bb30, 0x7fbc4216fd40, 0xc8200e6c30, 0xc82014e000)
        /home/jeroen/dev/src/github.com/goadesign/goa/mux.go:83 +0x42
net/http.serverHandler.ServeHTTP(0xc820010700, 0x7fbc4216fd40, 0xc8200e6c30, 0xc82014e000)
        /usr/lib/go-1.6/src/net/http/server.go:2081 +0x19e
net/http.(*conn).serve(0xc820010780)
        /usr/lib/go-1.6/src/net/http/server.go:1472 +0xf2e
created by net/http.(*Server).Serve
        /usr/lib/go-1.6/src/net/http/server.go:2137 +0x44e
curl: (52) Empty reply from server

I am completely new to GOA and relatively new to GO, so I have no idea how to fix this.

Appengine Example : Unable to use make commond

Hi ,

I am using windows and installed Google SDK and get this appengine example folder to src folder,

In Makefile , I have mentioned the path which is in src folder

REPO:=examples-master/appengine

Then I have run the below command and getting error

Make Example

Error:
'make' is not recognized as an internal or external command, operable program or batch file.

Editablegrid integration please

The EditableGrid is

an open source JavaScript library aimed at turning tables into fully editable components. Its API is focused on simplicity : only a few lines of code are necessary to get your first editable grid up and running.

Together with goa, the two make perfect tool for a quick CRUD system.
So please provide an example that integrates well with EditableGrid.

Thanks

secure-cli run jwt example failed

./secure-cli --key eyJhbGciOiJSUz[15/301$
R5cCI6IkpXVCJ9.eyJhdWQiOiJBdWRpZW5jZSIsImV4cCI6MTQ3MzM5MzAxNCwiaWF0IjoxNDczMzkyNDE0LCJpc3MiOiJJc3N1ZXIiLCJqdGkiOiI3ODU5YWRhYy02MTk0LTRlMTUtODFkMy0wZTI5NzNlOWQ
3ZDciLCJuYmYiOjIsInNjb3BlcyI6ImFwaTphY2Nlc3MiLCJzdWIiOiJzdWJqZWN0In0.kEB3aXKq9cPO3P9jELHj5MD6Xz6nbafuuankOT5IQTSioWrHPQROjlNzqPM4Rcfp05qcGIYVIvdSkkPMRZKl2Oci7
-gShsu7m0gsG7KFyOKtCw4Hwq21F7nNAQg29IXe5c2sxVa2QAQmK_eiAjWSDpuhHcq9J0iC6DFQgTVJ-JukvYZJYXqm1kn9qoyyJ2gSA6YggxxzZ2WKvdKFiaYB4Wmdvkeeef0S1srRd91OqF--G1I82-7NIOB
Gl-NgzGH7L5e1VUIgWnK5aizM4bLTTNDdf4G7jc4uCc7Pk8IKzFKocAlQT6ARGv1YuS5Govyx1HgUSUcMWi4hnWwHQiW2zA secure jwt
2016/09/09 11:40:55 [EROR] argument parse failed err=strconv.ParseBool: parsing "": invalid syntax

I check secure-cli source code, there is only one boolean var.
line 29:
app.PersistentFlags().BoolVar(&c.Dump, "dump", false, "Dump HTTP request and response.")

then I add --dump option, try to run again, the error is not gone.

I don't know if there is bug in "github.com/spf13/cobra"

gopherjs example fails to build.

go 1.7
osx
all code is latest from Master

golang code builds ok.
actual error on gopherjs build is:

public/main.go:129:17: cannot use hc (variable of type *net/http.Client) as github.com/goadesign/goa/client.Doer value in argument to client.New: wrong type for method Do

firstly lets do a generate....

x-MacBook-Pro:examples apple$ pwd
/Users/apple/workspace/go/src/github.com/goadesign/examples
x-MacBook-Pro:examples apple$ cd gopherjs/
x-MacBook-Pro:gopherjs apple$ go generate
app
app/contexts.go
app/controllers.go
app/hrefs.go
app/media_types.go
app/user_types.go
app/test
app/test/image_testing.go

tool/upload-cli
tool/upload-cli/main.go
tool/cli
tool/cli/commands.go
client
client/client.go
client/image.go
client/user_types.go
client/media_types.go
swagger
swagger/swagger.json
swagger/swagger.yaml
cannot find package "github.com/goadesign/examples/upload/client" in any of:
    /usr/local/go/src/github.com/goadesign/examples/upload/client (from $GOROOT)
    /Users/apple/workspace/go/src/github.com/goadesign/examples/upload/client (from $GOPATH)
generate.go:5: running "gopherjs": exit status 1


Ok, so it has a dependency on the upload example. No problem lets gen that...


x-MacBook-Pro:upload apple$ go generate
app
app/contexts.go
app/controllers.go
app/hrefs.go
app/media_types.go
app/user_types.go
app/test
app/test/image_testing.go
main.go
tool/upload-cli
tool/upload-cli/main.go
tool/cli
tool/cli/commands.go
client
client/client.go
client/image.go
client/user_types.go
client/media_types.go
swagger
swagger/swagger.json
swagger/swagger.yaml

Ok, so we got our upload generated and working.
Now back to the gopherjs example, and run the gen again...


x-MacBook-Pro:gopherjs apple$ go generate
app
app/contexts.go
app/controllers.go
app/hrefs.go
app/media_types.go
app/user_types.go
app/test
app/test/image_testing.go

tool/cli
tool/cli/commands.go
client
client/client.go
client/image.go
client/user_types.go
client/media_types.go
swagger
swagger/swagger.json
swagger/swagger.yaml
public/main.go:129:17: cannot use hc (variable of type *net/http.Client) as github.com/goadesign/goa/client.Doer value in argument to client.New: wrong type for method Do
generate.go:5: running "gopherjs": exit status 1

Looking at the public/main.go at line 129, its seems there is a missmatch in the structs.
hc := &http.Client{} is the wrong type of struct to be passed in.

Not sure how to fix this. Kind of feels like gopherjs generated code need to respect the context

Include some tests in the examples

I'd love to see the cellar example fleshed out with some tests. Being somewhat new to the language this would just be helpful to get at least a baseline for how to make sure that tests are properly wired in to a new project from the beginning.

Proposal: Modualize the samples so that they can be gonew

Proposal

I thought it would be good to be able to use goa examples with gonew to make it easier to run examples.

see. https://go.dev/blog/gonew

gonew goa.design/examples/basic@latest github.com/ikawaha/calc example

PoC

github.com/ikawaha/examples has a modularized version.

gonew github.com/ikawaha/examples/basic@latest github.com/<your_repo>/calc <your_dir>

You can try it like this.

Draft

Draft PR: #130

note: The tracing sample could not be modularized until it is released because it depends on the base module included in this repository. I hope to work on it later.

Missing schemas in OpenAPI spec when using union types

When using OneOf, I've noticed that some schemas are missing from the OpenAPI specification. In the example below, you can see that PackageCreatedEvent is listed in the OpenAPI document, but PackageUpdatedEvent is not. This issue appears to be linked to the fact that both event types use the same attribute names.

var Event = Type("Event", func() {
	// ...
	OneOf("details", func() {
		Field(4, "package_created", PackageCreatedEvent)
		Field(5, "package_updated", PackageUpdatedEvent)
	})
})

var Item = Type("Item", func() {
	Field(1, "description", String)
})

// PackageCreatedEvent is included in the OpenAPI schema.
var PackageCreatedEvent = Type("PackageCreatedEvent", func() {
	Field(1, "id", Int, "Identifier of package")
	Field(2, "item", Item)
	Required("id")
	Meta("type:generate:force")
})

// PackageUpdatedEvent is ___NOT___ included in the OpenAPI schema ___UNLESS___ "item" is renamed.
var PackageUpdatedEvent = Type("PackageUpdatedEvent", func() {
	Field(1, "id", Int, "Identifier of package")
	Field(2, "item", Item)
	Required("id")
	Meta("type:generate:force")
})

Full example here: master...sevein:examples:dev/union-openapi-missing-schemas.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.