Skip to content

[TCGC] [Bug] response/request header schema should not be generated #1749

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

Image

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

Metadata

Assignees

No one assigned

    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