Skip to content

Commit ece4912

Browse files
authored
[Key Vault] Optional parameter support in TSP (#34032)
1 parent e2b1a05 commit ece4912

File tree

7 files changed

+518
-20
lines changed

7 files changed

+518
-20
lines changed

specification/keyvault/Security.KeyVault.Certificates/client.tsp

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import "./main.tsp";
22
import "@azure-tools/typespec-client-generator-core";
33

44
using Azure.ClientGenerator.Core;
5-
using TypeSpec.Versioning;
65
using TypeSpec.Http;
6+
using TypeSpec.Versioning;
77

88
@versioned(KeyVault.Versions)
99
namespace Customizations;
@@ -14,6 +14,71 @@ namespace Customizations;
1414

1515
using KeyVault;
1616

17+
// Make optional path parameter required for all languages
18+
19+
/**
20+
* The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated are the certificate's attributes. This operation requires the certificates/update permission.
21+
*/
22+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
23+
@summary("Updates the specified attributes associated with the given certificate.")
24+
@route("/certificates/{certificate-name}/{certificate-version}")
25+
@patch(#{ implicitOptionality: true })
26+
op updateCertificate is KeyVaultOperation<
27+
{
28+
/**
29+
* The name of the certificate in the given key vault.
30+
*/
31+
@path("certificate-name")
32+
@clientName("name", "go")
33+
certificateName: string;
34+
35+
/**
36+
* The version of the certificate.
37+
*/
38+
@path("certificate-version")
39+
@clientName("version", "go")
40+
certificateVersion: string;
41+
42+
/**
43+
* The parameters for certificate update.
44+
*/
45+
#suppress "deprecated" "Property flattening is supported for legacy scenarios like Key Vault's"
46+
@body
47+
@flattenProperty
48+
parameters: CertificateUpdateParameters;
49+
},
50+
CertificateBundle
51+
>;
52+
53+
/**
54+
* Gets information about a specific certificate. This operation requires the certificates/get permission.
55+
*/
56+
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
57+
@summary("Gets information about a certificate.")
58+
@route("/certificates/{certificate-name}/{certificate-version}")
59+
@get
60+
op getCertificate is KeyVaultOperation<
61+
{
62+
/**
63+
* The name of the certificate in the given vault.
64+
*/
65+
@path("certificate-name")
66+
@clientName("name", "go")
67+
certificateName: string;
68+
69+
/**
70+
* The version of the certificate. This URI fragment is optional. If not specified, the latest version of the certificate is returned.
71+
*/
72+
@path("certificate-version")
73+
@clientName("version", "go")
74+
certificateVersion: string;
75+
},
76+
CertificateBundle
77+
>;
78+
79+
@@override(KeyVault.updateCertificate, updateCertificate);
80+
@@override(KeyVault.getCertificate, getCertificate);
81+
1782
// Java configuration
1883
@@usage(CertificateIssuerItem, Usage.input, "java");
1984
@@usage(CertificateOperation, Usage.input, "java");

specification/keyvault/Security.KeyVault.Certificates/routes.tsp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ op updateCertificatePolicy is KeyVaultOperation<
336336
* The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated are the certificate's attributes. This operation requires the certificates/update permission.
337337
*/
338338
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
339+
#suppress "@azure-tools/typespec-autorest/unsupported-optional-path-param" "Intentionally optional"
339340
@summary("Updates the specified attributes associated with the given certificate.")
340341
@route("/certificates/{certificate-name}/{certificate-version}")
341342
@patch(#{ implicitOptionality: true })
@@ -353,7 +354,7 @@ op updateCertificate is KeyVaultOperation<
353354
*/
354355
@path("certificate-version")
355356
@clientName("version", "go")
356-
certificateVersion: string;
357+
certificateVersion?: string;
357358

358359
/**
359360
* The parameters for certificate update.
@@ -370,6 +371,7 @@ op updateCertificate is KeyVaultOperation<
370371
* Gets information about a specific certificate. This operation requires the certificates/get permission.
371372
*/
372373
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Foundations.Operation is necessary for Key Vault"
374+
#suppress "@azure-tools/typespec-autorest/unsupported-optional-path-param" "Intentionally optional"
373375
@summary("Gets information about a certificate.")
374376
@route("/certificates/{certificate-name}/{certificate-version}")
375377
@get
@@ -387,7 +389,7 @@ op getCertificate is KeyVaultOperation<
387389
*/
388390
@path("certificate-version")
389391
@clientName("version", "go")
390-
certificateVersion: string;
392+
certificateVersion?: string;
391393
},
392394
CertificateBundle
393395
>;

specification/keyvault/Security.KeyVault.Common/common.tsp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import "@azure-tools/typespec-azure-core";
22
import "@typespec/openapi";
33

44
using Azure.Core;
5-
using TypeSpec.OpenAPI;
65

76
alias KeyVaultOperation<
87
TParams extends Reflection.Model,
98
TResponse,
10-
Traits extends Reflection.Model = {},
11-
TError = Error
9+
Traits extends Reflection.Model = {}
1210
> = Foundations.Operation<TParams, TResponse, Traits, KeyVaultError>;
1311

1412
/**

0 commit comments

Comments
 (0)