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

Polymorphism #98

Open
andreaslarssen opened this issue Apr 26, 2019 · 2 comments
Open

Polymorphism #98

andreaslarssen opened this issue Apr 26, 2019 · 2 comments
Labels

Comments

@andreaslarssen
Copy link

andreaslarssen commented Apr 26, 2019

With:

export class ClientErrorResponse  {
  @serializable(alias('error', raw())) protected _error: {messages: [{message: string}]};
}
export class UnauthorizedResponse extends ClientErrorResponse {}

...and then deserializing UnauthorizedResponse:

deserialize(UnauthorizedResponse, data);

...i get an instance of ClientErrorResponse, not the UnauthorizedResponse I hoped for, but when defining schemas this way:

export const UnauthorizedResponseSchema = {
  factory: context => new UnauthorizedResponse(),
  extends: ClientErrorResponseSchema,
  props: {}
};
export const ClientErrorResponseSchema = {
  factory: context => new ClientErrorResponse(),
  extends: BaseResponseSchema,
  props: {
    error: raw()
  }
};

...and then:

deserialize(UnauthorizedResponseSchema, error);

...it gives me an instance of UnauthorizedResponse.

Is this cool? Is it something I'm missing?

@waliarubal
Copy link

I am facing exact same kind of issue, i am serializing child class and on de-serialization I am receiving object of base class which doesn't has additional properties defined in child class. Seems to me an issue, kindly provide a fix or a workaround.

@1R053 1R053 added the bug label Jun 25, 2019
@andreaslarssen
Copy link
Author

Thought I'd look into this. Are there any contrib docs I could look at?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants