blackchoey/azure-cli-extensions

If binding two required metadata to api, will fail if only provide one custom-properties using cli to create api

hellyzh opened this issue · 1 comments

Describe the bug

If binding two required metadata to api, will fail if only provide one custom-properties using cli to create api. There are two Required properties testschema and testschema2 for following sample:
image

Related command

az apic api create -g hlytest424 --service-name hlyservice424 --api-id apitest3 --title "test api 2" --type rest --contacts "[{email:contact@example.com,name:test,url:example.com}]" --custom-properties '{"testschema2":"testvalue"}' --description "API description" --external-documentation "[{title:'onboarding docs',url:example.com}]" --license "{url:example.com}" --summary "summary"

Errors

(ValidationError) Metadata doesn't match the defined schema.
Code: ValidationError
Message: Metadata doesn't match the defined schema.
Exception Details: (None) Required properties are missing from object: testschema.
Code: None
Message: Required properties are missing from object: testschema.

Issue script & Debug output

(ValidationError) Metadata doesn't match the defined schema.
Code: ValidationError
Message: Metadata doesn't match the defined schema.
Exception Details: (None) Required properties are missing from object: testschema.
Code: None
Message: Required properties are missing from object: testschema.

Expected behavior

ok

Environment Summary

azure-cli 2.59.0

core 2.59.0
telemetry 1.1.0

Extensions:
apic-extension 1.0.0b5

Dependencies:
msal 1.27.0
azure-mgmt-resource 23.1.0b2

Python location '/opt/az/bin/python3'
Extensions directory '/home/helly/.azure/cliextensions'

Python (Linux) 3.11.8 (main, Mar 27 2024, 04:03:04) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

Provide more background: this issue was raised because if no --custom-properties specified, the API can be created successfully without setting the required metadata schema. So the user experience is strange: if it's possible to not specify required metadata schema when creating API, then user should also be able to only provide one required metadata schema value.

Converting to code:
az apic api create -g hlytest424 --service-name hlyservice424 --api-id apitest3 --title "test api 2" --type rest --contacts "[{email:[contact@example.com](mailto:contact@example.com),name:test,url:example.com}]" --description "API description" --external-documentation "[{title:'onboarding docs',url:example.com}]" --license "{url:example.com}" --summary "summary" is expected to fail from user (our test team)'s perspective because the metadata schemas are required and the command does not specify custom properties.