Skip to content

[TCGC] Add @alternateType to change the type of a property (with scope) #1757

Open

Description

Example:

model Bar {
  name: utcDateTime;
}

@@Tcgc.alternateType(Bar.name, string, "python");

Rationale is to be able to express in TypeScript autorest Swagger directive rules like this one:

- from: swagger-document
  where: $.definitions.AccessPolicy.properties
  transform: >
    $.Start.format = "str";
    $.Expiry.format = "str";

Side note, if I understood @timotheeguerin correctly, we should be able to make this work as well:

scalar storageDateTime extends utcDataTime;
model Bar {
  name: storageDateTime;
}

@@Tcgc.alternateType(storageDateTime, string, "python");

which would avoid to replace all one by one.

I would expect this is done in a way that emitter do not need to change anything, since they will receive models with the new type auto-magically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

lib:tcgcIssues for @azure-tools/typespec-client-generator-core library

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions