Open
Description
Issue
For below case, RepeatabilityResult
is as response header model, and should not be generated. But TCGC returns access for the model as public
and usage = 4
, thus after adopting TCGC access and usage, it gets generated.
alias RepeatableOperationsWithTraits = global.Azure.Core.ResourceOperations<SupportsRepeatableRequests &
NoConditionalRequests &
NoClientRequestId>;
op repeatableAction is RepeatableOperationsWithTraits.ResourceAction<
User,
BodyParameter<UserActionParam>,
UserActionResponse
>;
/**
* Provides repeatable request headers for requests and responses.
* @template VersionAdded The version when the trait was added to the specification.
* Leave this empty if the trait is always supported.
*/
@trait("RepeatableRequests")
@traitAdded(VersionAdded)
model SupportsRepeatableRequests<VersionAdded extends EnumMember | null = null> {
#suppress "@azure-tools/typespec-providerhub/no-inline-model" "This inline model is never used directly in operations."
@traitContext(
TraitContext.Create | TraitContext.Update | TraitContext.Delete | TraitContext.Action
)
repeatableRequests: {
@traitLocation(TraitLocation.Parameters)
parameters: RepeatabilityRequestHeaders;
@traitLocation(TraitLocation.Response)
response: RepeatabilityResponseHeaders;
};
}
@doc("Provides the 'Repeatability-*' headers to enable repeatable requests.")
model RepeatabilityResponseHeaders {
@visibility("read")
@header("Repeatability-Result")
@doc("Indicates whether the repeatable request was accepted or rejected.")
repeatabilityResult?: RepeatabilityResult;
}
detailed test case
Solution
TCGC return usage as 0
to indicate the model should not be generated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment