M4 4.21.0 incorrectly changes const type to string
See original GitHub issueM4 version 4.21.0
This is presumably due to the behavior change of treating single-value enums as constants.
For operation bool_putFalse
, after fixing up the parameter as follows.
"parameters": [
{
"name": "boolBody",
"in": "body",
"schema" : {
"type": "boolean",
"enum": [false],
"x-ms-enum": { "name": "falseConst", "modelAsString": false }
},
"required": true
}
],
The schema.valueType.type
has a type of SchemaType.String
which is unexpected.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
warning: deprecated conversion from string constant to 'char*'
I believe passing -Wno-write-strings to GCC will suppress this warning. ... the problem and make it possible to perform the few remaining changes...
Read more >Type literal assertion `as const` to prevent type widening
When I declare a constant and assign a string literal or a number literal to it, type inference works differently than when I...
Read more >const - JavaScript - MDN Web Docs - Mozilla
The const declaration creates a read-only reference to a value. It does not mean the value it holds is immutable—just that the variable ......
Read more >String Literals and char - C++ Migration Guide
A string literal such as "Hello world" logically should be const in order to prevent nonsensical results, as in the following example. #define...
Read more >What is wrong with magic strings?
@Yogu Typescript won't rename all your strings for you if you change the static string literal type you're expecting. You'll get compile time ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Verified fix is working.
yeah so there was 2 issues:
type: string
when merging enumsname
was not provided butx-ms-enum
was it would either crash(before 3.5.0) or just act like if the name isundefined
and still merge it causing this issue but ifx-ms-enum
wasn’t there then it would use the auto generated nameBoth should be fixed in the PR linked. Can you verify it works https://github.com/Azure/autorest/pull/4295#issuecomment-920451075