Skip to content

[Bug]: Can't apply @minValue decorator on an named union member #9816

@artsiommiksiuk

Description

@artsiommiksiuk

Describe the bug

I can do this:

model A {
  @minValue(0)
  index: int32 | "auto";
}

but can't apply @minValue(0) decorator to the same union defined in a form of a named union.

Reproduction

union U {
  @minValue(0)
  number: int32;
  "auto";
}

model B {
  index: U
}

Decorator throws an error:

Cannot apply @minValue decorator to int32 since it is not assignable to numeric | utcDateTime | offsetDateTime | plainDate | plainTime | duration | ModelProperty

https://typespec.io/playground/?e=%40typespec%2Fopenapi3&c=bW9kZWwgQSB7CiAgQG1pblZhbHVlKDApCiAgaW5kZXg6IGludDMyIHwgImF1dG8iOwp9CgoKdW5pb24gVdQ2bnVtYmVyxzc7CiDMOMZtQsU3x15VCn0%3D&options=%7B%7D&vs=%7B%7D

Checklist

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions