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

Cannot put metadata and doc to ResourceNameParameter #809

Open
pshao25 opened this issue May 9, 2024 · 4 comments
Open

Cannot put metadata and doc to ResourceNameParameter #809

pshao25 opened this issue May 9, 2024 · 4 comments
Assignees
Labels
docs Improvements or additions to documentation
Milestone

Comments

@pshao25
Copy link
Member

pshao25 commented May 9, 2024

Here is how I define a resource before:

model DataManagerForAgriculture extends TrackedResourceBase {
  /**
   * DataManagerForAgriculture resource name.
   */
  @maxLength(63)
  @minLength(1)
  @pattern("^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$")
  @path
  @key("dataManagerForAgricultureResourceName")
  @segment("farmBeats")
  @visibility("read")
  name: string;
}

I have customized document. I have length limitation by @maxLength and @minLength.

After I change it to

model DataManagerForAgriculture extends Foundations.TrackedResource {
  /**
   * DataManagerForAgriculture resource name.
   */
  ...ResourceNameParameter<
    DataManagerForAgriculture,
    "dataManagerForAgricultureResourceName",
    "farmBeats",
    "^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$"
  >;
}

The doc I added is ignored. And I cannot add more decorators to the spread ResourceNameParameter.

@markcowl
Copy link
Member

markcowl commented May 10, 2024

@pshao25 You can do this using an augment decorator on the name parameter, as in this playground.

I think we should mention this in the docs, though.

@markcowl markcowl added the needs-info Mark an issue that needs reply from the author or it will be closed automatically label May 10, 2024
@pshao25
Copy link
Member Author

pshao25 commented May 11, 2024

Thanks! Seems the link is wrong, but I already got your point! Augment decorator works!

My follow-up problem is the type of name in ResourceNameParameter is hard coded as string. What if the name is an enum? For this swagger, we previously defined its TypeSpec as

model Quota is ProxyResource<QuotaProperties> {
  /**
   * The quota name.
   */
  @path
  @key("name")
  @segment("quotas")
  @visibility("read")
  name: QuotaNames;
}

After I upgraded to the latest compiler, a non-string name is not allowed.

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-team-attention and removed needs-info Mark an issue that needs reply from the author or it will be closed automatically labels May 11, 2024
@pshao25 pshao25 removed their assignment May 11, 2024
@markcowl markcowl added the docs Improvements or additions to documentation label May 14, 2024
@markcowl markcowl added this to the [2024] June milestone May 14, 2024
@markcowl
Copy link
Member

est: 1
pri: 2

@pshao25
Copy link
Member Author

pshao25 commented May 17, 2024

@markcowl Just to confirm, your estimation is for the documentation or for the fix of enum name I put above? Do you want me to create a separate new issue for the enum name scenario?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants