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.

Incorrect enum values for boolean property with default values

See original GitHub issue

When generating Azure resource schema from swagger, boolean property with default values don’t have the correct enum value set.

Example property in swagger:

        "adminUserEnabled": {
          "description": "The value that indicates whether the admin user is enabled.",
          "default": false,
          "type": "boolean"
        },

Generated property in schema:

        "adminUserEnabled": {
          "oneOf": [
            {
              "type": "boolean",
              "enum": [
                "false"
              ]
            },
            {
              "$ref": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#/definitions/expression"
            }
          ],
          "description": "The value that indicates whether the admin user is enabled."
        },

The enum set should contain both true and false boolean values rather than one string value.

The same issue is seen in other published schema such as Storage.

This is blocking us from releasing resource schema https://github.com/Azure/azure-resource-manager-schemas/pull/370

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Nov 28, 2017

I don’t think there was a specific reason for this design. I most likely just hadn’t gotten around to supporting it yet. I suggest adding it in.

0reactions
olydiscommented, Nov 28, 2017

@daschult I see you initially added the above behavior here. Before touching it I wanted to quickly clarify, was there a reason for this design? The JsonSchema type doesn’t have a Default property (yet), so was this maybe just a workaround to somehow encode the information in the resulting schema? Why not model default in Swagger as default in JSON schema? 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Choosing the default value of an Enum type without having to ...
So what happens if a variable of type MyEnum { SingleMember = 10 } defaults to zero? The answer is nothing. C# has...
Read more >
Annotating properties with default decoding values
struct Article: Decodable { var title: String var body: String var isFeatured: Bool = false // This value isn't used when decoding }....
Read more >
Enum HOWTO — Python 3.11.1 documentation
An Enum is a set of symbolic names bound to unique values. ... starting number and not 0 is that 0 is False...
Read more >
Enum.TryParse Method (System) - Microsoft Learn
When this method returns true , contains an enumeration constant that represents the parsed value. Returns. Boolean. true if the conversion succeeded; false...
Read more >
Model field reference - Django documentation
If True , Django will store empty values as NULL in the database. Default is False . Avoid using null on string-based fields...
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