Open MaryGao opened 1 year ago
Seems like we have a typo in the docs, the example above show the correct syntax with :
instead of =
.
For the float part it is an a bit of a problem. We have numbers behind the scene in javascript, literals in typespec are just numeric it doesn't remember if it was defined with .0
.
edit: we actually have valueAsString
which "could" be used but is also not super clean and leave the job to every emitter to check if something is a float, int, etc.
@timotheeguerin Does that mean every emitter needs to check by themselves if they have requirement to distinguish 1.0
and 1
?
model Result {
prop: 1.0 // Here emitter may need to check if the devired type is int or float
}
yeah.. which is not ideal. Or we need to have at least an helper of the sort getNumericPrecision(numericType) // => int32, float64, etc.)
fix the above doc
Doc fixed in https://github.com/microsoft/typespec/pull/2245, this can remain as a design discussion
I opened this issue: https://github.com/microsoft/typespec/issues/2240 This would be an issue in csharp because adding a new value will cause breaking changes in C# for example, in one version we have:
enum Foo {
A: 1.0;
B: 2.0;
}
and everything will generate as integers. When they add a real float number, everything suddenly changed to generate as float:
enum Foo {
A: 1.0;
B: 2.0;
C: 3.3;
}
See the example for
FloatEnum
which has values1.0, 2.0, 3.0
would be mapped to1, 2, 3
. I think this is incorrect.swagger spec:
Another thing is I notice that the docs guides me following cases but it doesn't work, could you update the docs?