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

Fixes #3083: properly generate attributes with meta struct:pkg:path #3084

Merged
merged 21 commits into from Jul 12, 2022

Conversation

ernesto-jimenez
Copy link
Contributor

What was the issue?

What was meant to be a check on the parentPkg to avoid recursive
definitions wasn't actually checking the parent package, but the package
of the field itself.

It was a bug that got introduced in #3022 and never worked as expected.

Solution:

Injecting the parent package for the initial definition seems to address
this.

…pkg:path`

What was the issue?

What was meant to be a check on the parentPkg to avoid recursive
definitions wasn't actually checking the parent package, but the package
of the field itself.

It was a bug that got introduced in goadesign#3022 and never worked as expected.

Solution:

Injecting the parent package for the initial definition seems to address
this.
codegen/scope.go Outdated Show resolved Hide resolved
@ernesto-jimenez
Copy link
Contributor Author

@raphael this fixes part of the issue in #3083

The gen/$svc/service.go generated is valid, however, the following files are invalid:

  • gen/http/$svc/client/encode_decode.go
  • gen/http/$svc/server/encode_decode.go

Instead of using the type from struct:pkg:path, it is still importing it from gen/$svc

Any suggestions on how to address the second part?

@raphael
Copy link
Member

raphael commented Jul 1, 2022

Thank you for this, will take a look

@ernesto-jimenez
Copy link
Contributor Author

ernesto-jimenez commented Jul 2, 2022

@raphael I have added a failing test to illustrate the remaining issue.

I reckon the issue might be with codegen.GoTransform. I just saw it contains no tests for types with Meta("struct:pkg:path")

raphael and others added 7 commits July 10, 2022 18:23
* Upgrade to Go 1.18

* Use Go 1.18 in CI

* sudo does not exist on Windows
The prior code didn't always take into consideration
the case where a type has a required validation that
does not apply (e.g. object with only primitive types
that are not pointers).

This refactor moves the logic to a common method
that handles all corner cases.
…pkg:path`

What was the issue?

What was meant to be a check on the parentPkg to avoid recursive
definitions wasn't actually checking the parent package, but the package
of the field itself.

It was a bug that got introduced in goadesign#3022 and never worked as expected.

Solution:

Injecting the parent package for the initial definition seems to address
this.
@raphael raphael merged commit ff403eb into goadesign:v3 Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants