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

Can't lunch Swagger if I use Vector2 for the communication #755

Open
locus84 opened this issue Apr 4, 2024 · 0 comments
Open

Can't lunch Swagger if I use Vector2 for the communication #755

locus84 opened this issue Apr 4, 2024 · 0 comments

Comments

@locus84
Copy link

locus84 commented Apr 4, 2024

  [MessagePackObject]
  public struct Vector2
  {
      public static readonly Vector2 zero = new Vector2(0, 0);
      public static readonly Vector2 up = new Vector2(0, 1);

      [Key(0)]
      public float x { get; set; }
      [Key(1)]
      public float y { get; set; }

      [SerializationConstructor]
      public Vector2(float x, float y)
      {
          this.x = x;
          this.y = y;
      }

      public static Vector2 right = new Vector2(1f, 0);

      [IgnoreMember, JsonIgnore]
      public Vector2 normalized => new Vector2(this.x / this.magnitude, this.y / this.magnitude); //if I comment out this member, it works
  }

above is part of my Vector2 struct on server.
When I use this structure data transfer, everything works fine except swagger.

async UnaryResult<bool> ShipFreeMoved(Vector2 pos);

above is my function signature that breaks swagger.

image
image

Imo, it looks like swagger trying to serialize the 'normalized' parameter even it's taged with Ignored/JsonIgnore.

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

No branches or pull requests

1 participant