Incorrect enum values for boolean property with default values
See original GitHub issueWhen generating Azure resource schema from swagger, boolean property with default values don’t have the correct enum value set.
"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:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top 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 >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
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.
@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 aDefault
property (yet), so was this maybe just a workaround to somehow encode the information in the resulting schema? Why not modeldefault
in Swagger asdefault
in JSON schema? 🙂