-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
Accessing API using CLI gives incorrect result when ResultType has multiple views #2671
Comments
Thank you for the report! This behavior is a result of the design behind views and what the generated CLI does. A view defines which fields in the result struct to initialize and validate but there is still a single type defined for the method result. The CLI prints the service method level result which has these fields defined. The generated code takes care of validating that fields present in a view definition (and only these) have valid values. So TL;DR the JSON serialized by the server is as you would expect: {
"companies": [
{
"id": 1,
"location": "India",
"name": "Symantec"
},
{
"id": 2,
"location": "India",
"name": "Red Hat"
}
],
"id": 1,
"latestCompany": {
"name": "Redhat"
},
"name": "abc"
} This JSON gets unmarshaled into the result type by the client code which is what the CLI prints. Hopes that make sense. |
@raphael Thanks for the explanation. :)
This is similar to what I am getting in another project. |
The above is clearly a bug, thank you for putting together a repro. Would you mind creating a new issue for the panic? thank you. |
Created a Issue #2681 |
I have an example here.
If you run the service and invoke the API using CLI.
this returns response
Here, view used for
LatestCompany
istiny
which is supposed to return onlyName
but it returns all fields.I am currently using goa in one other project where if the value for other fields are not defined then it breaks the API and returns
I think this is similar to #2613.
@raphael
The text was updated successfully, but these errors were encountered: