Comments (5)
Supporting extensible enums may be as simple as distinguishing in parseEnumType
between ChoiceSchema
and SealedChoiceSchema
objects. @autorest/codemodel will use SealedChoiceSchema
if an enum's modelAsString
property is set to false
(per the Autorest docs, this indicates that the enum is closed) and ChoiceSchema
otherwise.
For any ChoiceSchema
passed to parseEnumType
, the non-literal string type would be added to the union type defined for the enum.
from bicep-types-az.
Possibly related: Azure/bicep#3817 - use of a CSV list of enums raises a warning.
from bicep-types-az.
Possibly related: Azure/bicep#4064
from bicep-types-az.
Note that there's also the question of how we fit this into Bicep. I assume we could represent open enums as e.g. 'foo' | 'bar' | string
, but we'd need to make sure language features such as completions work well with this, and that we don't accidentally coerce the type down to string
. Feels like it's bound to break in a number of places without some work.
We should also think about whether we want to support the common convention of using a CSV-formatted list to support a multi-choice enum (e.g. 'foo, bar'
). I'd personally say "no", but I think it's worthy of a discussion.
from bicep-types-az.
Bicep does coerce the type down to string
when loading the type, but I was able to get completions working by removing the explicit downcast:
The change causes one test to fail, but it's one that explicitly checks to make sure that specific coercion happens.
I'm not sure I follow the comment about the CSV-formatted list. Would that be how we should display the type signature for a multi-choice enum (instead of however it shows now, presumably something like Array<'foo'|'bar'>
)?
from bicep-types-az.
Related Issues (20)
- Microsoft.Insights/scheduledQueryRules@2023-12-01 : missing HOT 1
- [Qumulo.Storage/fileSystems]: `storageSku` property enum values incorrect
- [Cosmos DB Account]: location should be required but it's not; properties.locations shouldn't be required, but it is
- [Microsoft.Web/hostingEnvironments]: identity + old version
- Microsoft.App/managedEnvironments: "identity" does not exist...
- Linter rule use-recent-api-versions suggests non-existent version for resource type HOT 1
- Container App with Prtivate Link in FD HOT 4
- Microsoft.AzureStackHCI/marketplaceGalleryImages doesn't work on 23H2
- microsoft.insights/components/ProactiveDetectionConfigs: Properties.name is showing warning eventhough it's valid.
- [Microsoft.Web/connections]: parameterValueType property not supported for system assigned managed identities
- [Microsoft.Web/staticSites/linkedBackends]: backendResourceId rejecting Microsoft.Web/containerApps even though supported by API/UI HOT 1
- Unable to run deployment script attached to storage account with AllowSharedKeyAccess false HOT 5
- front door rule
- [Microsoft.AAD/domainServices]: additional replicaSets are not applied
- [<DppIdentityDetails]: <description>
- bootstrapProfile property marked as IntelliSense error for Managed Cluster Properties (Visual Studio Bicep Extension)
- Microsoft.Web/sites: missing sshEnabled
- Microsoft.Kusto/clusters: 'properties.uri' is not available on ADX clusters unless it's on initial deployment
- Microsoft.RecoveryServices/vaults@2024-04-01: "monitoringSettings parameter is invalid" error
- SignalR privateEndpoints provided name ignored
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bicep-types-az.