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

Mixed array of custom type #101

Open
matte0080 opened this issue Feb 7, 2023 · 0 comments
Open

Mixed array of custom type #101

matte0080 opened this issue Feb 7, 2023 · 0 comments

Comments

@matte0080
Copy link

matte0080 commented Feb 7, 2023

export class ActivityEventVisibilityRequest {
  @IsNumber({
    maxDecimalPlaces: 0,
  })
  @IsDefined()
  version: number;

  @ValidateNested({ each: true })
  @Type(() => ActivityEvent, {
    keepDiscriminatorProperty: true,
    discriminator: {
      property: 'name',
      subTypes: [
        { value: ActivityEventVisibility, name: EActivityType.VISIBILITY },
        { value: ActivityEventCiccio, name: EActivityType.TEST },
      ],
    },
  })

  @JSONSchema({
    type: 'array',
    items: {
      anyOf: [
        {
          $ref: '#/components/schemas/ActivityEventCiccio',
        },
        { $ref: '#/components/schemas/ActivityEventVisibility' },
      ],
    },
  })
  events: ActivityEvent[];
}

ActivityEventVisibility e ActivityEventCiccio are subclass of ActivityEvent. In OpenApi doc i see this.

Screenshot 2023-02-07 alle 13 38 27

What i need to do for see ActivityEventVisibility e ActivityEventCiccio in events: ActivityEvent[]; type? Actually i see ActivityEvent in schema space and in example area.

In debug i see this. I think it is wrong.
Screenshot 2023-02-07 alle 13 42 25

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