Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooling to have schema aware outputs #3196

Open
nianton opened this issue Jun 12, 2021 · 2 comments
Open

Tooling to have schema aware outputs #3196

nianton opened this issue Jun 12, 2021 · 2 comments
Labels

Comments

@nianton
Copy link

nianton commented Jun 12, 2021

It would be great when a module has a "strongly typed" object output, to be able to reference its properties from the bicep file consuming the module.

Sample module:

param message string

output foo object = {
  bar: 'xxxx'
  anotherProperty: 1234
  input: message
}

So the desired output would be to list the properties of the output object ('bar', 'anotherProperty' and 'input') in the following usage of the above module:

image

An ARM Template has the limitation of allowing only 64 outputs, and when working around this limitation by including those values to an object output, there is no intellisense/help during coding on its schema to reference the values/properties.

@nianton nianton added the enhancement New feature or request label Jun 12, 2021
@ghost ghost added the Needs: Triage 🔍 label Jun 12, 2021
@anthony-c-martin
Copy link
Member

This is a really good suggestion and would significantly improve the module authoring experience!

I've also been wondering the same thing about validating param inputs, but it's a little more tricky as you may end up with false positives or ambiguous cases.

For example in the following file, we know that the only properties accessed off foo are abc and def, so you could offer them as completions when validating inputs:

param foo object

var test = foo.abc
var test2 = foo.def

I imagine this could be useful in conjunction with typed resource definitions - e.g. in the following, you could offer pipPrefix and pip as completions, but you could also offer the correct set of enum values for each sku in calling modules:

param skus object

resource ipprefix 'Microsoft.Network/publicIPPrefixes@2020-05-01' = {
  sku: {
    name: skus.pipPrefix
  }
  ...
}

resource publicip 'Microsoft.Network/publicIPAddresses@2020-05-01' = {
  sku: {
    name: skus.pip
  }
  ...
}

Here's an example where it's not possible to give an accurate list of completions/validation:

// type would have to be 'any'
param unused object

// type would have to be 'any'
param runtimeAccess object
var test = runtimeAccess[resourceGroup().location]

@jeskew
Copy link
Contributor

jeskew commented Jun 8, 2023

User-defined types can be applied to outputs, which will enable output property completions.

The team previously discussed and decided not to implement output type inference in #10421. Bicep can infer rich type information about an output in a module authored in Bicep, but the compiler's ability to do so in a JSON module (which includes any registry module) is very limited. If type inference in JSON modules improves, this can be revisited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

5 participants