Skip to content

Conversation

AllyW
Copy link
Contributor

@AllyW AllyW commented Mar 20, 2025

tsp model:

@doc("Resource configuration instance for a Flex Consumption based Azure Function App.")
model FunctionFlexConsumptionResourceConfiguration {
@doc("Memory size of the instance. Supported values are 2048, 4096.")
instanceMemoryMB: int64;

@doc("HTTP Concurrency for the function app.")
httpConcurrency?: int64;
}


@doc("Configurations of a target resource. This varies with the kind of resource.")
@discriminator("kind")
model TargetResourceConfigurations {
  @doc("Kind of the resource for which the configurations apply.")
  @visibility(Lifecycle.Create, Lifecycle.Read)
  kind: ResourceKind;
}

@doc("Configurations for a Function App using Flex Consumption Plan.")
model FunctionFlexConsumptionTargetResourceConfigurations
  extends TargetResourceConfigurations {
  @doc("""
    The kind value to use when providing configuration.
    This should typically be not changed from its value.
    """)
  kind: ResourceKind.FunctionsFlexConsumption;

  @doc("A map of configurations for a Function app using Flex Consumption Plan.")
  configurations?: Record<FunctionFlexConsumptionResourceConfiguration>;
}

output:


{
    "type": "object",
    "discriminators": [
        {
            "property": "kind",
            "value": "FunctionsFlexConsumption",
            "props": [
                {
                    "type": "object",
                    "additionalProps": {
                        "item": {
                            "type": "object",
                            "props": [
                                {
                                    "type": "integer64",
                                    "name": "instanceMemoryMB",
                                    "description": "Memory size of the instance. Supported values are 2048, 4096.",
                                    "required": true
                                },
                                {
                                    "type": "integer64",
                                    "name": "httpConcurrency",
                                    "description": "HTTP Concurrency for the function app."
                                }
                            ]
                        }
                    },
                    "name": "configurations",
                    "description": "A map of configurations for a Function app using Flex Consumption Plan."
                }
            ]
        }
    ],
    "props": [
        {
            "type": "string",
            "enum": {
                "items": [
                    {
                        "value": "FunctionsFlexConsumption"
                    }
                ]
            },
            "name": "kind",
            "description": "Kind of the resource for which the configurations apply.",
            "required": true
        }
    ],
    "name": "targetResourceConfigurations",
    "description": "Configurations of the target resource on which the test profile ran.",
    "readOnly": true
}


@AllyW AllyW changed the title Adjust discriminator for reduce duplicated props Adjust discriminator to reduce duplicated props Mar 24, 2025
Comment on lines -753 to -913
discProperty.enum ??= {
items: [],
};
discProperty.enum.items.push({
value: childDiscriminatorValue.value,
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the discProperty varient

Copy link
Contributor Author

@AllyW AllyW Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part adds all enums of discriminator property, by iterating through all its possible children value, however, discriminator property gets its all enums already when parsing this property using convert2CMDSchema above.

If these six lines added, then, the enums for this discriminator property would be doubled.

@AllyW AllyW force-pushed the discriminator-check branch from cc827f9 to 2fac6e2 Compare April 22, 2025 09:24
@AllyW AllyW merged commit 08263ea into Azure:dev Apr 23, 2025
3 checks passed
@AllyW AllyW deleted the discriminator-check branch May 21, 2025 08:56
@necusjz necusjz mentioned this pull request Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants