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

[tcgc] Descuss: shall we allow Optional property in clientInitialization Model #1795

Open
chunyu3 opened this issue Nov 4, 2024 · 0 comments
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@chunyu3
Copy link
Member

chunyu3 commented Nov 4, 2024

Shall we allow ClientIntialization Model contains optional property? as following:

namespace MyCustomizations;
model MyServiceClientOptions {
   id: string;
  blobName?: string;
}

@@clientInitialization(MyService, MyServiceClientOptions)

If so,
What's the rule to bump a operation parameter to client via @clientInitialization

  • scenario1: the parameter are all required in all operations
namespace MyService;

op upload(blobName: string): void;
op download(blobName: string): void;

// client.tsp
namespace MyCustomizations;
model MyServiceClientOptions {
  blobName: string;
}

@@clientInitialization(MyService, MyServiceClientOptions)

Then the bumped parameter blobName should be required property in ClientIntialization Model

  • scenario2: the parameter are all optional in all operations
namespace MyService;

op upload(blobName: string): void;
op download(blobName?: string): void;

// client.tsp
namespace MyCustomizations;
model MyServiceClientOptions {
  blobName: string;
  blobID?: string
}

Then the bumped parameter blobName should be optional property in ClientIntialization Model

  • scenario 3: optional in one operation, required in another one
namespace MyService;

op upload(blobName: string): void;
op download(blobName?: string): void;

// client.tsp
namespace MyCustomizations;
model MyServiceClientOptions {
  blobName: string;
  blobID?: string
}

@@clientInitialization(MyService, MyServiceClientOptions)

We should not allow this. Define a Linter rule to avoid this.

@chunyu3 chunyu3 changed the title [tcgc] Optional property in clientInitialization Model [tcgc] Descuss: shall we allow Optional property in clientInitialization Model Nov 4, 2024
@chunyu3 chunyu3 added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

1 participant