question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

M4 4.21.0 incorrectly changes const type to string

See original GitHub issue

M4 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:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jhendrixMSFTcommented, Sep 15, 2021

Verified fix is working.

0reactions
timotheeguerincommented, Sep 15, 2021

yeah so there was 2 issues:

  1. as said above it would hard code type: string when merging enums
  2. if name was not provided but x-ms-enum was it would either crash(before 3.5.0) or just act like if the name is undefined and still merge it causing this issue but if x-ms-enum wasn’t there then it would use the auto generated name

Both should be fixed in the PR linked. Can you verify it works https://github.com/Azure/autorest/pull/4295#issuecomment-920451075

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found