Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3: Fix the case where non-unified package names are generated #2172

Merged
merged 2 commits into from Jul 4, 2019

Conversation

@ikawaha
Copy link
Contributor

commented Jul 2, 2019

Fix #2153

Example design

package design

import (
	. "goa.design/goa/v3/dsl"
)

var _ = API("calc", func() {
	Title("Calculator Service")
	Description("Service for adding numbers, a Goa teaser")
	Server("calc", func() {
		Host("localhost", func() {
			URI("http://localhost:8000")
			URI("grpc://localhost:8080")
		})
	})
})

var _ = Service("calc", func() {
	Description("The calc service performs operations on numbers.")

	Method("add", func() {
		Payload(func() {
			Field(1, "a", Int, "Left operand")
			Field(2, "b", Int, "Right operand")
			Required("a", "b")
		})

		Result(Int)

		HTTP(func() {
			GET("/add/{a}/{b}")
		})

		GRPC(func() {
		})
	})

	Files("/openapi.json", "./gen/http/openapi.json")
})

var _ = Service("calcapi", func() {
	Description("The calc service performs operations on numbers.")

	Method("add", func() {
		Payload(func() {
			Field(1, "a", Int, "Left operand")
			Field(2, "b", Int, "Right operand")
			Required("a", "b")
		})

		Result(Int)

		HTTP(func() {
			GET("/add/{a}/{b}")
		})

		GRPC(func() {
		})
	})

	Files("/openapi.json", "./gen/http/openapi.json")
})

var _ = Service("calcapi1", func() {
	Description("The calc service performs operations on numbers.")

	Method("add", func() {
		Payload(func() {
			Field(1, "a", Int, "Left operand")
			Field(2, "b", Int, "Right operand")
			Required("a", "b")
		})

		Result(Int)

		HTTP(func() {
			GET("/add/{a}/{b}")
		})

		GRPC(func() {
		})
	})

	Files("/openapi.json", "./gen/http/openapi.json")
})

goa gen & goa example

$ goa gen calc/design
gen/calc/client.go
gen/calc/endpoints.go
gen/calc/service.go
gen/calcapi/client.go
gen/calcapi/endpoints.go
gen/calcapi/service.go
gen/calcapi1/client.go
gen/calcapi1/endpoints.go
gen/calcapi1/service.go
gen/grpc/calc/client/cli.go
gen/grpc/calc/client/client.go
gen/grpc/calc/client/encode_decode.go
gen/grpc/calc/client/types.go
gen/grpc/calc/pb/calc.proto
gen/grpc/calc/server/encode_decode.go
gen/grpc/calc/server/server.go
gen/grpc/calc/server/types.go
gen/grpc/calcapi/client/cli.go
gen/grpc/calcapi/client/client.go
gen/grpc/calcapi/client/encode_decode.go
gen/grpc/calcapi/client/types.go
gen/grpc/calcapi/pb/calcapi.proto
gen/grpc/calcapi/server/encode_decode.go
gen/grpc/calcapi/server/server.go
gen/grpc/calcapi/server/types.go
gen/grpc/calcapi1/client/cli.go
gen/grpc/calcapi1/client/client.go
gen/grpc/calcapi1/client/encode_decode.go
gen/grpc/calcapi1/client/types.go
gen/grpc/calcapi1/pb/calcapi1.proto
gen/grpc/calcapi1/server/encode_decode.go
gen/grpc/calcapi1/server/server.go
gen/grpc/calcapi1/server/types.go
gen/grpc/cli/calc/cli.go
gen/http/calc/client/cli.go
gen/http/calc/client/client.go
gen/http/calc/client/encode_decode.go
gen/http/calc/client/paths.go
gen/http/calc/client/types.go
gen/http/calc/server/encode_decode.go
gen/http/calc/server/paths.go
gen/http/calc/server/server.go
gen/http/calc/server/types.go
gen/http/calcapi/client/cli.go
gen/http/calcapi/client/client.go
gen/http/calcapi/client/encode_decode.go
gen/http/calcapi/client/paths.go
gen/http/calcapi/client/types.go
gen/http/calcapi/server/encode_decode.go
gen/http/calcapi/server/paths.go
gen/http/calcapi/server/server.go
gen/http/calcapi/server/types.go
gen/http/calcapi1/client/cli.go
gen/http/calcapi1/client/client.go
gen/http/calcapi1/client/encode_decode.go
gen/http/calcapi1/client/paths.go
gen/http/calcapi1/client/types.go
gen/http/calcapi1/server/encode_decode.go
gen/http/calcapi1/server/paths.go
gen/http/calcapi1/server/server.go
gen/http/calcapi1/server/types.go
gen/http/cli/calc/cli.go
gen/http/openapi.json
gen/http/openapi.yaml

$ gen example calc/design
calc.go
calcapi.go
calcapi1.go
cmd/calc-cli/grpc.go
cmd/calc-cli/http.go
cmd/calc-cli/main.go
cmd/calc/grpc.go
cmd/calc/http.go
cmd/calc/main.go

Example service package name

$ ls *.go|xargs head -1
==> calc.go <==
package calcapi2

==> calcapi.go <==
package calcapi2

==> calcapi1.go <==
package calcapi2
@raphael

This comment has been minimized.

Copy link
Member

commented Jul 3, 2019

Thank you for the great issue report and the PR! It all makes sense. I am wondering if it would be possible to add a test that would fail without your fix?

@raphael

This comment has been minimized.

Copy link
Member

commented Jul 4, 2019

Perfect, thank you! aloha :)
One last request - could you please port this fix to v2 as well? thanks again.

@raphael raphael merged commit 85024eb into goadesign:v3 Jul 4, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
ikawaha added a commit to ikawaha/goa that referenced this pull request Jul 4, 2019
V3: Fix the case where non-unified package names are generated (goade…
…sign#2172)

* Fix the case where non-unified package names are generated

* Add tests
raphael added a commit that referenced this pull request Jul 5, 2019
V2 back port: Fix the case where non-unified package names are genera…
…ted (#2172) (#2178)

* V3: Fix the case where non-unified package names are generated (#2172)

* Fix the case where non-unified package names are generated

* Add tests

* Remove v3 from the import package paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.