question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Endpoint object serialisation overlooks a public field

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After returning from the endpoint GET /issue/1 i expect the json to contain the field project with the value 1. As this is the value set in the DTO.

But it holds {}

Expected Behavior

I expect the serialisation to contain all fields with their value as described in the DTO Project.

Steps To Reproduce

  1. Given the attached project, start the project
  2. Setup an issue at the endpoint
curl -X 'POST' \
  'https://localhost:7174/issue/1' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'author=a' \
  -F 'comment=b'
  1. Retrieve the issue via GET /issue/1. Now i expect that projectId is set to 1 in the first element of the list

bugreport.zip

Exceptions (if any)

No response

.NET Version

7.0.100-preview.6.22352.1

Anything else?

.NET SDK:
 Version:   7.0.100-preview.6.22352.1
 Commit:    492644e08e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.5
 OS Platform: Darwin
 RID:         osx.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.100-preview.6.22352.1/

Host:
  Version:      7.0.0-preview.6.22324.4
  Architecture: x64
  Commit:       d3fa592f6d

.NET SDKs installed:
  6.0.400 [/usr/local/share/dotnet/sdk]
  7.0.100-preview.6.22352.1 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-preview.6.22330.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.6.22324.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  /Users/user/Documents/backend/global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Hu1buergercommented, Sep 22, 2022

@brunolins16 will try that one out

0reactions
Hu1buergercommented, Sep 28, 2022

Works. @brunolins16 why isnt the implicit operation performed before the serialisation? IMHO the projection should be performed transparently. What edge case am i overlooking?

There should be an implicit operation defined on Issue with

    public static implicit operator IssueDto(Issue i) => new IssueDto(i.Project.ProjectId.ToString(), i.IssueId,
        i.Comments.Select(c => new IssueCommentDto(new Author(c.Author), c.CreatedAt, c.Comment)).ToList());
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set a custom serializer to ever API endpoint (spring ...
In the book object I like to only serialize some fields. class book{ @JsonView(Views.someClass.class) public String name; public String ...
Read more >
Everything You Need to Know About Java Serialization ...
Check out this post to learn everything you need to know about serialization in Java and what this looks like in code examples....
Read more >
Jackson's @JsonView with SpringBoot Tutorial
This is what tells Jackson which instance variable of the class to serialize/de-serialize. Example : @JsonView(Views.Public.class) private ...
Read more >
Serialization - .NET
In this article. Serialization is the process of converting the state of an object into a form that can be persisted or transported....
Read more >
ObjectOutputStream example: A Java object serialization ...
Java object serialization is a feature of the JDK that is far too often overlooked. When a developer puts together a prototype or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found