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 augment properties in nested anonymous model #4818

Open
3 tasks done
MaryGao opened this issue Oct 22, 2024 · 3 comments
Open
3 tasks done

Cannot augment properties in nested anonymous model #4818

MaryGao opened this issue Oct 22, 2024 · 3 comments
Labels
bug Something isn't working compiler:core Issues for @typespec/compiler triaged:core
Milestone

Comments

@MaryGao
Copy link
Member

MaryGao commented Oct 22, 2024

Clear and concise description of the problem

This is an idea when we tried to solve the breaking issue during migrating swagger to typespec for anonymous model. The naming rule is different between them and one solution would be to location that model and use clientName decorator to rename it.

model Foo {
  bar: {
    baz: string;
  }
}

Then in decorator we could have a way likeFoo.bar.Type to location that model then we could add decorator like other models.

// add doc into that model
@@doc(Foo.bar.Type, "This is demo for doc with anonymous model");
// give a name for that model
@@clientName(Foo.bar.Type, "NamedBarType");

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@timotheeguerin
Copy link
Member

timotheeguerin commented Oct 22, 2024

Did talk with people about that recently, the main problem is that the anonymous model can have multiple parent when using alias. But maybe then its ok to try to resolve the alias name or it is an antipattern.

sorry misunderstood, we have that but its broken with Foo.bar::type.baz should be solved by the symbol refactor

@markcowl
Copy link
Contributor

@MaryGao You should be able to use type metadata to do this (Foo.bar::type) but this is currently broken and may be fixed by the attached issue.

@markcowl markcowl added this to the Backlog milestone Oct 22, 2024
@markcowl markcowl added bug Something isn't working compiler:core Issues for @typespec/compiler triaged:core and removed needs-area labels Oct 22, 2024
@timotheeguerin timotheeguerin changed the title Can we allow to location anonymous model in decorator? Cannot augment properties in nested anonymous model Oct 22, 2024
@MaryGao
Copy link
Member Author

MaryGao commented Oct 23, 2024

Got it and thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler:core Issues for @typespec/compiler triaged:core
Projects
None yet
Development

No branches or pull requests

3 participants